Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spi flash write file #10236

Open
xiaotailang opened this issue Aug 16, 2023 · 1 comment
Open

spi flash write file #10236

xiaotailang opened this issue Aug 16, 2023 · 1 comment

Comments

@xiaotailang
Copy link

Hello everyone! I have developed an SPI flash W25Q16 driver on STM32F767. The upper-level interface is managed by the MTD device, with the W25Q16 device mounted on the /mnt/ directory. I transfer the file "1.txt" through FTP or socket, and then open the W25Q16 device using the open function. After that, I write "1.txt" to the W25Q16 using the write function. In general, the write operation works fine,However, I have found that after a power loss and system reboot, when I transfer "1.txt" through FTP or socket and then write it to the W25Q16, the file is often not visible when using the ls command to check the contents of the W25Q16. This issue is more likely to occur if "1.txt" already existed in the W25Q16 flash before the power loss, and I attempt to write it again after reboot. I have confirmed that the file was accurately transmitted through FTP or socket..I have tried debugging and tracing this issue, but I haven't been able to pinpoint the specific problem. Since you have extensive development experience, can you provide some solutions or suggestions for troubleshooting?

The specific phenomenon:
+++++create socket sucess ++++
+++++ connect sucess ++++
+++++++++++++nxffs_open++++++++++++++++++
nxffs_open_oflags:38
+++++++maybe into nxffs_wropen++++
pos123_oflags:38
pos12_oflags:38
nxffs_findinode_ret:0
pos3_oflags:38
pos1234_oflags:38
pos12345_oflags:38
spi_send:43
spi_send:43
+++++open /mnt/w25a/ sucess ++++
++++++++++++++++++start wrtie+++++++++++++++++++++++++++
spi_send:43
spi_send:43
spi_send:43
ofile->crefs:1
ofile->oflags:38
spi_send:43
spi_send:43
spi_send:43
wrfile->truncate:1
start---nxffs_rminode
spi_send:43
spi_send:43
spi_send:43
spi_send:43
spi_send:43
spi_send:43
receive file name: 1.txt
receive file size 5
From the printed information flow above, it can be seen that the file has been successfully transferred and written. However, when I navigate to the "/mnt/w25a/" directory using the "cd" command and check with "ls", I find that "1.txt" does not exist. I have tried writing "1.txt" to an SD card via the SPI interface, and I did not encounter this issue. Upon examining the system, I found that reading and writing to the SPI flash and SPI SD card are implemented using different interfaces. Therefore, I can only confirm that there is likely no problem with the SPI bus driver. However, I cannot completely rule out the possibility of hidden flaws in the interface responsible for managing the SPI flash within the system. As you have a wealth of development experience, I hope get some insights or suggestions.

@xiaotailang
Copy link
Author

After further debugging the issue, I found that after powering on, when I first successfully download the file "1.txt", I can see it when I execute "ls /mnt/w25a/". However, when I execute "ls /mnt/w25a/" for the second time, the "1.txt" file is no longer present. I also tested with "cat /mnt/w25a/" and "cd /mnt/w25a/", and the same phenomenon occurs. I traced the execution and found that there is a point where the node of the file is freed. It seems that after the first "ls" command, the node of the file is freed, causing subsequent "ls" commands to not be able to see "1.txt". However, I didn't fully understand the logic and reason behind this. Do any developers in the community know why this is happening?

The specific phenomenon:
pi_send:43
spi_send:43
spi_send:43
spi_send:43
========================end close=============================
receive file name: 1.txt
receive file size 5

sh> ls /mnt/w25/
nxffs_stat: Entry
/mnt/w25:
nxffs_opendir: relpath: ""
nxffs_nextentry: Found a valid fileheader, offset: 10140
nxffs_readdir: Offset 10140: "1.txt"
1.txt
w25_bread: startblock: 00000028 nblocks: 1
w25_read: offset: 00002800 nbytes: 256
w25_byteread: address: 00002800 nbytes: 256
w25_read: return nbytes: 256
nxffs_nextentry: No entry found
sh>
sh>
sh> ls /mnt/w25/
nxffs_stat: Entry
/mnt/w25:
nxffs_opendir: relpath: ""
w25_bread: startblock: 00000027 nblocks: 1
w25_read: offset: 00002700 nbytes: 256
w25_byteread: address: 00002700 nbytes: 256
w25_read: return nbytes: 256
w25_bread: startblock: 00000028 nblocks: 1
w25_read: offset: 00002800 nbytes: 256
w25_byteread: address: 00002800 nbytes: 256
w25_read: return nbytes: 256
nxffs_nextentry: No entry found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant