用QSPI驱动W25Q128.驱动应该没问题。但是读取的时候,数据超过512K就会失败。
512K以内就正常,1M就失败。
我把FLSH分区,一个512K分区,一个1M分区,同时跑fal bench。结果如下:
msh />fal bench 4096 yes
Erasing 524288 bytes data, waiting...
Erase benchmark success, total time: 1.896S.
Writing 524288 bytes data, waiting...
Write benchmark success, total time: 2.048S.
Reading 524288 bytes data, waiting...
Read benchmark success, total time: 0.144S.
msh />fal probe update2
Probed a flash partition | update2 | flash_dev: norflash0 | offset: 1048576 | len: 1048576 |.
msh />fal bench 4096 yes
Erasing 1048576 bytes data, waiting...
Erase benchmark success, total time: 3.844S.
Writing 1048576 bytes data, waiting...
Write benchmark success, total time: 4.096S.
Reading 1048576 bytes data, waiting...
585728 3057 f1 ff.
585728 3058 f2 ff.
585728 3059 f3 ff.
...
...
585728 4090 fa ff.
585728 4091 fb ff.
585728 4092 fc ff.
585728 4093 fd ff.
585728 4094 fe ff.
Data check ERROR! Please check you flash by other command.
Read benchmark has an error. Error code: -1.
This operate has an error. Error code: -1.
msh />
不知道什么原因。
而且分区擦除和写入都成功了,读取失败了!
我单独做sf bench测试正片flash,也失败了,但是提示已经读取了7M左右。
msh />sf probe qspi20
[I/SFUD] Find a Winbond flash chip. Size is 16777216 bytes.
[I/SFUD] sf_cmd flash device is initialize success.
[I/SFUD] Probe SPI flash sf_cmd by SPI device qspi20 success.
16 MB sf_cmd is current selected device.
msh />sf bench yes
Erasing the sf_cmd 16777216 bytes data, waiting...
Erase benchmark success, total time: 41.318S.
Writing the sf_cmd 16777216 bytes data, waiting...
Write benchmark success, total time: 65.537S.
Reading the sf_cmd 16777216 bytes data, waiting...
Data check ERROR! Please check you flash by other command.
Read sf_cmd failed, already rd for 788480 bytes, read 256 each time
Read benchmark has an error. Error code: 3.
This flash operate has an error. Error code: 3.
我修改了一下sf的代码,对读取检测错误的数据做一次重新读取检测,再次读取的数据竟然又是正确的,而且每隔一段时间就会出现一次读取错误的情况!间隔不等
result = sfud_read(sfud_dev, addr + i, cur_op_size, read_data);
/* data check */
if (memcmp(write_data, read_data, cur_op_size))
{
rt_kprintf("sf read error(%i),try read again.\r\n",addr + i);
result = sfud_read(sfud_dev, addr + i, cur_op_size, read_data);
if (memcmp(write_data, read_data, cur_op_size))
{
rt_kprintf("Data check ERROR! Please check you flash by other command.\n");
rt_kprintf("write_data:\r\n");
for(int m = 0; m < cur_op_size; m += 16)
{
for(int n = 0; n < 15; n++)
{
rt_kprintf("%X ", write_data[m + n]);
}
rt_kprintf("\r\n");
}
rt_kprintf("read_data:\r\n");
for(int m = 0; m < cur_op_size; m += 16)
{
for(int n = 0; n < 15; n++)
{
rt_kprintf("%X ", read_data[m + n]);
}
rt_kprintf("\r\n");
}
result = SFUD_ERR_READ;
}
}
然后发现每隔一段时间读数据就会出错一次,而且我重新读取,数据竟然又正确了!!
msh />sf bench yes
Erasing the sf_cmd 16777216 bytes data, waiting...
Erase benchmark success, total time: 40.494S.
Writing the sf_cmd 16777216 bytes data, waiting...
Write benchmark success, total time: 65.537S.
Reading the sf_cmd 16777216 bytes data, waiting...
sf read error(71168),try read again.
sf read error(791296),try read again.
sf read error(798720),try read again.
sf read error(899584),try read again.
sf read error(1871616),try read again.
sf read error(2818048),try read again.
sf read error(3482880),try read again.
sf read error(3781376),try read again.
sf read error(4128768),try read again.
sf read error(4473856),try read again.
sf read error(4682496),try read again.
sf read error(8348416),try read again.
sf read error(8379136),try read again.
sf read error(8563968),try read again.
sf read error(9972480),try read again.
sf read error(10003200),try read again.
sf read error(10796800),try read again.
sf read error(11395584),try read again.
sf read error(13328640),try read again.
sf read error(13967360),try read again.
sf read error(14754816),try read again.
sf read error(15545600),try read again.
Read benchmark success, total time: 5.630S.