xlnx4.0中关于SPI-nor-flash的一个小bug

最经搞关于zynq7000,用到了petalinux,其中用的内核版本为xlnx4.0。再处理nandflash问题是,发现如下问题,阅读关于与扩展地址操作的原代码,从纸面上看应该属于一个小bug。原代码如下:

行号:333

/*
 * Update Extended Address/bank selection Register.
 * Call with flash->lock locked.
 */
static int write_ear(struct spi_nor *nor, u32 addr)
{
u8 code;    //操作代码声明
u8 ear;
int ret;


/* Wait until finished previous write command. */
if (spi_nor_wait_till_ready(nor))
return 1;


if (nor->mtd->size <= (0x1000000) << nor->shift)
return 0;


addr = addr % (u32) nor->mtd->size;
ear = addr >> 24;


if ((!nor->isstacked) && (ear == nor->curbank))
return 0;


if (nor->isstacked && (nor->mtd->size <= 0x2000000))
return 0;


if (nor->jedec_id == CFI_MFR_AMD)
code = SPINOR_OP_BRWR;      //amd器件的操作代码
if (nor->jedec_id == CFI_MFR_ST) {
write_enable(nor);
code = SPINOR_OP_WREAR;   //st的操作代码
}
nor->cmd_buf[0] = ear;


ret = nor->write_reg(nor, code, nor->cmd_buf, 1, 0);
if (ret < 0)
return ret;


nor->curbank = ear;


return 0;
}

以上代码中不难看出,code没有默认值,中途只处理了AMD和ST器件的操作码,应该是一个bug,同样的问题在read_ear函数中也存在,摘录源码如下:

行号:240

/**
 * read_ear - Get the extended/bank address register value
 * @nor: Pointer to the flash control structure
 *
 * This routine reads the Extended/bank address register value
 *
 * Return: Negative if error occured.
 */
static int read_ear(struct spi_nor *nor, struct flash_info *info)
{
int ret;
u8 val;
u8 code;   //code未初始化


/* This is actually Spansion */
if (JEDEC_MFR(info) == CFI_MFR_AMD)
code = SPINOR_OP_BRRD;    //amd操作码
/* This is actually Micron */
else if (JEDEC_MFR(info) == CFI_MFR_ST)
code = SPINOR_OP_RDEAR;  //st操作码
else
return -EINVAL;         //其他的推出,此处应该有问题


ret = nor->read_reg(nor, code, &val, 1);
if (ret < 0)
return ret;


return val;
}

不难看出代码中code没有默认值,而且只处理了AMD和ST的器件,应属于bug,

至于怎么处理,大家是大牛,见仁见智,就不在此赘述了



linux-xlnx-xilinx-v2017.4是指xilinx公司发布的Linux操作系统版本,该版本发布于2017年4月。它是基于xilinx公司的FPGA(现场可编程门阵列)芯片的开发平台,为用户提供了丰富的软件和硬件驱动支持。 该版本的Linux操作系统具有很多特点和功能。首先,它是一个开源的操作系统,用户可以自由使用、修改和分发,同时也能够通过社区共享和得到支持。其次,它具有良好的可移植性和扩展性,可以在不同的硬件平台上运行,并支持各种各样的应用程序开发和运行环境。此外,该操作系统还提供了强大的多任务处理和网络功能,以及高效的文件系统和设备驱动支持,能够满足用户对于高性能和可靠性的需求。 由于linux-xlnx-xilinx-v2017.4是基于xilinx FPGA芯片的开发平台,它还提供了专门针对FPGA开发的工具和库。用户可以使用这些工具和库进行FPGA的逻辑设计、验证和验证,以及与其他硬件组件的交互和通信。这些工具和库包括Xilinx的Vivado开发套件、SDK(软件开发套件)和PetaLinux工具,用户可以通过它们进行FPGA编程和软件开发。 总的来说,linux-xlnx-xilinx-v2017.4是一款强大的开源操作系统,适用于xilinx FPGA芯片的开发和应用。它提供了丰富的软件和硬件支持,以及专门的FPGA开发工具和库,能够满足用户对于高性能和可靠性的需求,并支持各种各样的应用程序开发和运行环境。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值