过年回家没带开发板。终于可以搞一搞了。更新petaLinux到2019.2。重建项目,flash调整一下。启动过程中提示:
m25p80 spi0.0: found w25q256, expected n25q512a
m25p80 spi0.0: failed to read ear reg
m25p80 spi0.0: w25q256 (32768 Kbytes)
主要是flash的型号不正确。全局搜索n25q512a
,上次的2018版本可以定位到build/tmp/work-shared/plnx-zynq7/kernel-source/drivers/mtd/spi-nor/spi-nor.c
,这次居然找不到这个路径了。当时怎么操作的没有记录,找来找去,需要在这里开启:
petalinux-config
# → Linux Components Selection → linux-kernel(remote)
# → Linux Components Selection → Remote linux-kernel settings ---> Remote linux-kernel git URL (https://github.com/Xilinx/linux-xlnx)
# → Linux Components Selection → Remote linux-kernel settings ---> Remote linux-kernel git TAG/Commit ID (xlnx_rebase_v4.19)
petalinux-build
编译过程中会自动下载内核代码。
现在就可以看到文件了,这回使用了VS CODE,将build文件夹直接隐藏掉。源代码直接可以从components
里找到。上次找偏了。这次在components/plnx_workspace/sources/linux-xlnx/drivers/mtd/spi-nor/spi-nor.c
这个里面有很多FLASH。找到w25q256
:
1661: { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
看看INFO,计算一下
{
name: "w25q256",
id: {0xef, 0x40, 0x19, 0, 0},
id_len: 3,
sector_size: 65536,
n_sectors: 512,
page_size: 256,
flags: SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ
},
写到设备树里:
&flash0 {
compatible = "w25q256";
};
另一个"micron,m25p80"在文章开头有说明,这个s个文件是基于m25p80所写的。删了编译一下。
m25p80 spi0.0: failed to read ear reg
m25p80 spi0.0: w25q256 (32768 Kbytes)
还有一个failed。这个ear reg的警告在 spi-nor.c
的函数spi_nor_scan
中。前面有这么一段代码:
3453: dev_warn(dev, "found %s, expected %s\n",
3454: jinfo->name, info->name);
就是一开始的那个警告。已经解决了。回到正题
3664: int status;
3665:
3666: nor->addr_width = 3;
3667: set_4byte(nor, info, 0);
3668: status = read_ear(nor, info);
3669: if (status < 0)
3670: => dev_warn(dev, "failed to read ear reg\n");
3671: else
3672: nor->curbank = status & EAR_SEGMENT_MASK;
前面设置了addr_width
为3,这个是寻址宽度,3个字节。应该是16M
,而这个芯片是32M
的。
看看手册吧。
有个3bit和4bit寻址模式。4bit可以支持到512M。
使用13h
和 0Ch
来设置 4bit 和 3bit模式。一头雾水。
在这里找到一些东西:使用四字节命令读写256Mb QSPI Flash
在手册 ug821-zynq-7000-swdev.pdf
中也能找到这样一段内容:
This QSPI boot mode is for x4 mode. The BootROM searches the first 256 Mb in x8 mode. In QSPI boot mode (where the QSPI device is >128Mb), to use MultiBoot, place the multiple images in such a way that they fit in memory locations less than 128Mb. To effect this mode, the images should have only (FSBL+U-Boot) to fit in the <128Mb memory. Then, the rest of the partitions, possibly residing in a portion of memory that is >128Mb, must be handled by U-Boot. In this case, update the zynq_common.h file to add the commands to load the required partitions. You can find further details on the usage, along with an example, in the Xilinx Zynq-7000 AP SoC Solution Center。
直接找到QSPI的控制器说明上。在手册 ug585-Zynq-7000-TRM.pdf
中:
16 MB addressing per device (32 MB for two devices)
这里就是更本原因了。所以说,为什么ZYNQ就不支持4bit呢。。。。
继续往下看。有点意思,这个函数里面有个注释是专门针对这块FLASH的。
static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info,
int enable)
{
int status;
bool need_wren = false;
u8 cmd;
switch (JEDEC_MFR(info)) {
case SNOR_MFR_ST:
case SNOR_MFR_MICRON:
need_wren = true;
case SNOR_MFR_MACRONIX:
case SNOR_MFR_WINBOND:
if (need_wren)
write_enable(nor);
cmd = enable ? SPINOR_OP_EN4B : SPINOR_OP_EX4B;
status = nor->write_reg(nor, cmd, NULL, 0);
if (need_wren)
write_disable(nor);
if (!status && !enable &&
JEDEC_MFR(info) == SNOR_MFR_WINBOND) {
write_enable(nor);
nor->cmd_buf[0] = 0;
nor->write_reg(nor, SPINOR_OP_WREAR, nor->cmd_buf, 1);
write_disable(nor);
}
return status;
default:
nor->cmd_buf[0] = enable << 7;
return nor->write_reg(nor, SPINOR_OP_BRWR, nor->cmd_buf, 1);
}
}
看起来就是将FLASH设置为了3bit模式。下一段:
static int read_ear(struct spi_nor *nor, struct flash_info *info)
{
int ret;
u8 val;
u8 code;
if (JEDEC_MFR(info) == CFI_MFR_AMD)
code = SPINOR_OP_BRRD;
else if (JEDEC_MFR(info) == CFI_MFR_ST ||
JEDEC_MFR(info) == CFI_MFR_MACRONIX ||
JEDEC_MFR(info) == SNOR_MFR_ISSI)
code = SPINOR_OP_RDEAR;
else
return -EINVAL;
ret = nor->read_reg(nor, code, &val, 1);
if (ret < 0)
return ret;
return val;
}
这里面没有支持WINBOND,给他添加上,这里是要读设置BANK的寄存器。这个指令在手册上有说明,不知为何这里不支持。后面的定义SPINOR_OP_RDEAR
就是C8h
,修改一下。
- JEDEC_MFR(info) == SNOR_MFR_ISSI)
+ JEDEC_MFR(info) == SNOR_MFR_ISSI ||
+ JEDEC_MFR(info) == SNOR_MFR_WINBOND)
再编译一次,跑一下。
root@ax7021:/dev
m25p80 spi0.0: w25q256 (32768 Kbytes)
4 fixed-partitions partitions found on MTD device spi0.0
Creating 4 MTD partitions on "spi0.0":
OK,SPI-FLASH这边就没有问题了。
中间还有这样的一个报错:
[INFO] building project
[INFO] sourcing bitbake
ERROR: Failed to source bitbake
ERROR: Failed to build project
不管使用任何petalinux的命令都是这样。
查看日志:/home/godenfreemans/FTP_Folder/project_1/project_1.petalinux/build/build.log
,发现这么一段:
ERROR: No space left on device or exceeds fs.inotify.max_user_watches?
ERROR: To check max_user_watches: sysctl -n fs.inotify.max_user_watches.
ERROR: To check max_user_watches: sysctl -n fs.inotify.max_user_watches.
ERROR: To modify max_user_watches: sysctl -n -w fs.inotify.max_user_watches=<value>.
ERROR: To modify max_user_watches: sysctl -n -w fs.inotify.max_user_watches=<value>.
ERROR: Root privilege is required to modify max_user_watches.
ERROR: Root privilege is required to modify max_user_watches.
按照操作执行后得到8192,这个东西感觉像是文件的监视器??一个用户可以同时监视(比方说打开)的文件数量。
使用下面的命令把它改大一点,128000,然后就可以正常编译了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)