-
Notifications
You must be signed in to change notification settings - Fork 79
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
Full Usage Example fails on Feather M4 Express #21
Comments
I put CircuitPython on the M4 via .UF2 to format the flash via OS as it looked like that helped with prior closed issues that I thought might be related. A successful OS flash did not appear to help anything. Also on the exposed USB drive when running CircuitPython showed /test directory was created, also a boot_out.txt which looks like it's from CircuitPython. Before I formatted it, it had the same contents, but also "foo" but as a file and not as a directory, but as a file (according to Windows Explorer). These seems to indicate that when trying to create "/test/foo/bar" it can create 1 directory "/test" and then the next part "/foo" either fails or gets created as a file and fails. |
The stability of Serial output also seems really bad for some reason when running the examples provided with this library. Some of them seem to run fine in terms of the code, but Serial output just stops and not everything gets printed. As far as I know this behavior is particular to the examples in this library. |
I was playing with this last night. Tested on M4 ItsyBitsy and Grand Central. Both had circuit python loaded. . Win7, latest IDE, this lib and Fork of SDfat The code Locks up on line 88 |
I'm having the exact same problem. Feather M4 Express |
Running the same demo on PlatformIO, the problem seems to occur here in Adafruit_FlashCache.cpp, beginning at line 98:
dst_off is an unsigned integer but, when run at the offending portion of the demo, it underflows becoming an inappropriate value. A few lines down, the comparison in the IF statement is never true, so the code to adjust the offsets never gets executed. This causes memcopy() to be called with values outside of existing memory, leading to the crash. @hathach Would it be possible to fix this? |
If i comment out create deep directory, then the code proceeds to create |
FYI |
Additional observations hopefully to help @hathach track down the problem(s):
Additional comments:
@hathach, please help us! |
Sorry guys, I am currently in the middle of something else. I will look at this in the next week. Meanwhile please make sure you git clone the master branch to test with. There is a fix for flash cache read a couple of week ago that isn't released yet for following bug https://github.com/adafruit/Adafruit_SPIFlash/blob/master/src/Adafruit_FlashCache.cpp#L98
|
Thanks, @hathach, for your quick reply. Much appreciated. However, I forgot to mention in my prior post that I had already included your latest Adafruit_SPIFlash master branch (from Aug 5, 2019, 10:12PM PDT) before I listed the problems I mentioned above. Thank you in advance, and we eagerly await your continued help with this issue. |
OK thanks for the update, I will try to reproduce the issue and catch up in the next week. |
@hathach Thanks for the link to the upcoming updates for Adafruit_FlashCache.cpp. I was wondering if, in that version, it would still be possible to have out-of-range values passed to 'memcpy' due to the arithmetic for cache_bytes from line 107 (and passed to 'readBuffer' on line 117) due to 'count' being unsigned? `
` |
after doing lots of tests with lots of print for flash caching and sdfat, I couldn't find any issue with those module. Also the example work fine with Feather nRF52840, there is probably issue with QSPI driver implementation on samd51. To be continue .... |
update: spend lots of time to carry more tests, it seems to be related to how the FAT is formatted. The sketch works well when formatted using PC (ubuntu 18.04), but failed if format with example sketch using fatfs. Probably related to 1 vs 2 FAT. Maybe it is not fully covered yet. Continue to test..... |
hathach, thanks for the updates. We're rooting for you to resolve this issue! Regarding your post yesterday that the issue might be with the QSPI driver, please note that in item 3 in my post above on August 19, I mentioned I had the same problematic results when using the "Adafruit Feather nRF52832" with an additional external GD25Q16C chip that I wired separately to the '832 SPI (whereas, the '840 uses QSPI with the on-board GD25Q16C chip). So I feel the problem might go beyond the QSPI driver. Possibly the problem is formatting with fatfs as you suggested in your post today. |
SdFat assume filesystem always have 2 FAT (which is true for SD Card), but optional for other type of storage (in our case external flash). We did you modification to add 1-FAT support to SdFat but not complete. the SdFat PR will hopefully nail it. Once 2 above PRs are merge, please give it a test again and close the issue if it is fixed. Thanks PS: troubleshooting this issue is too problematic ~ . ~ |
Thanks, @hathach! From my initial tests, the issues I mentioned above appear to be resolved. Great work, and we appreciate your time and effort! |
thank for confirming, we will release the fix for both library asap |
@hathach, while the issue above is still somewhat fresh in your mind, I want to let you know that there might still be a small bug when using SPI with an external flash chip; although, using QSPI with flash seems fine now. When I wire up an external GD25Q16 flash chip to the SPI of an nRF52832, SdFat_ReadWrite prints out two copies of "testing 1, 2, 3." (Note that only one copy of "testing 1, 2, 3." is correctly printed when using the on-board GD25Q16 and QSPI of the nRF52840.) When using the SPI on the nRF52832 with an external GD25Q16 flash chip, it's also odd that SdFat_full_usage correctly prints only one copy of "Hello world!" as long as it is written to a directory other than the root, such as written to /test/test.txt. However, if you edit SdFat_full_usage to write "Hello world!" to the root directory, i.e., to write to text.txt, rather than to write to /test/test.txt, then two copies will again be printed when using the SPI (whereas, only one copy is correctly printed when using QSPI on the nRF52840). As I mentioned, the QSPI seems to work fine now with the nRF52840. You previously thought there might have been an issue with the QSPI driver implementation. Is it possible that you recently made some fixes to the QSPI driver that should equivalently be made to the SPI driver? Thanks in advance for your help with this! |
The code haven't tested with nrf52832 so there is no surprised that it didn't work well. The reason is I don't have an board with nrf52832 with GD25Q16 flash chip to test with since Adafruit didn't make one. If you could figure it out, feel free to submit a PR for it :) |
On all versions tested from 3.0.0 to 3.1.1 The "Full Usage Example" is failing on a Feather M4 Express. It's failing on line 88 of the .ino and entering the error conditional there.
When this happens I'm getting some instability in 3.1.1 as well, for example the Serial.println on line 89 would not show up in the serial console sometimes. And other times when I set the LED on pin 13 high before/after line 89 it would not illuminate. When this would happen the board would also appear unresponsive the the Arduino IDE could not longer connect to the port or reset it automatically for uploading a new sketch. At this point only option is to double click reset and upload a new sketch via that route. Maybe this is expected from
while(1)
in the error condition there but I feel like the answer is "no", otherwise why use this as an error catching technique? Either way I'm getting breaking hangs in this part of the code.A good bit of the library functionality does work, but I've not yet had a chance to go through and test everything.
Useful Info/Assumptions:
Here's what I get printed out on the serial console until it hangs:
Initially I wasn't even getting that last error line - the stability when it enters the inside of that error checking conditional seems unpredictable for some reason. In some other example .ino files I was testing I was also not getting Serial output but did verify the code was running by setting pin 13 high. However in the full usage example file it definitely dies inside of that error condition trying to create deep directory structure.
I'm going to test more functionality further and I'll add additional comments if I found more related information. Since
fatfs.exists()
is used in the example code without issue I'm going to assume the error is related to!fatfs.mkdir("/test/foo/bar")
- as it seems testing the existing of and create directories without nesting (/test) isn't an issue and it seems to fail when trying to create nested files/folders.The text was updated successfully, but these errors were encountered: