数据写入bug

发布于 2020-02-15 00:01:09
附上调试log
sh >sf probe spi30
set spi freq 67166666
[SFUD] Find a GigaDevice flash chip. Size is 16777216 bytes.
[SFUD] sf_cmd flash device is initialize success.
16 MB sf_cmd is current selected device.
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] 01 02 03 04 05 FF FF FF FF FF FF FF FF FF FF FF ................
[00200010] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................

msh >sf write 0x200000 8 8 8 8 8 8
Write the sf_cmd flash data success. Start from 0x00200000, size is 6.
Write data: 8 8 8 8 8 8 .
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] 00 00 00 00 00 08 FF FF FF FF FF FF FF FF FF FF ................
[00200010] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................

msh >sf write 0x200010 8 8 8 8 8 8
Write the sf_cmd flash data success. Start from 0x00200010, size is 6.
Write data: 8 8 8 8 8 8 .
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] 00 00 00 00 00 08 FF FF FF FF FF FF FF FF FF FF ................
[00200010] 08 08 08 08 08 08 FF FF FF FF FF FF FF FF FF FF ................

msh >sf erase 0x200000 1
Erase the sf_cmd flash data success. Start from 0x00200000, size is 1.
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00200010] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................

msh >sf write 0x200010 8 8 8 8 8 8
Write the sf_cmd flash data success. Start from 0x00200010, size is 6.
Write data: 8 8 8 8 8 8 .
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00200010] 08 08 08 08 08 08 FF FF FF FF FF FF FF FF FF FF ................

msh >sf write 0x200000 8 8 8 8 8 8
Write the sf_cmd flash data success. Start from 0x00200000, size is 6.
Write data: 8 8 8 8 8 8 .
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] 08 08 08 08 08 08 FF FF FF FF FF FF FF FF FF FF ................
[00200010] 08 08 08 08 08 08 FF FF FF FF FF FF FF FF FF FF ................

msh >sf write 0x200000 7 7 7 7 7
Write the sf_cmd flash data success. Start from 0x00200000, size is 5.
Write data: 7 7 7 7 7 .
msh >sf read 0x200000 32
Read the sf_cmd flash data success. Start from 0x00200000, size is 32. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00200000] 00 00 00 00 00 08 FF FF FF FF FF FF FF FF FF FF ................
[00200010] 08 08 08 08 08 08 FF FF FF FF FF FF FF FF FF FF ................
在这个测试中发现,写入数据,若写入的位置原本是FF的话,则可以写入,但若不是FF ,则无法写入,重新erase之后,存储的位置又变成FF,则可以再次写入
在调试SFUD中发现的问题。有人清楚这是怎么一回事么?


查看更多

关注者
0
被浏览
319
3 个回答
freedom195
freedom195 2020-02-15
第二个问题,SFUD宏配置中使能了SFDP,然后调用erase ,直接擦除4096个字节。是这样的么?
_Tony_
_Tony_ 2020-02-17
spi flash的物理特性就是write的时候可以把 bit 由1变为0,可以简单的理解成与上你写的数据。
erase的时候,把bit 由0变成1。
freedom195
freedom195 2020-02-17
_Tony_ 发表于 2020-2-17 16:07
spi flash的物理特性就是write的时候可以把 bit 由1变为0,可以简单的理解成与上你写的数据。
erase的时候 ...


明白了,那就是每次写入前都需要擦除。sfud只是提供了底层的函数,要实现产品上的读取,写入,还需要fal和文件系统来完成吧。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友