-
Notifications
You must be signed in to change notification settings - Fork 388
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
SD card FILE_WRITE issue #214
Comments
I believe this is just the way the updated SdFAT library behaves. I need to wire it up but I have a vague recollection that it "optimizes" unwritten files out to minimize flash wear. It'll be a few days before I have the time. I believe you should be fine actually writing and using files, though. Is that fine for you? |
I am seeing this issue as well. The library can't create a new file. |
Issue is confirmed. Writing new file is not OK. Writing to / Reading from existing file is OK I'm testing with this code
the debug output
|
Try appending to a file, that's broken as well. I'm happy that there is some support for the RP2040 but without the ability to append to a file...its going to be really tough to do anything all that useful. |
I tested and saw appending is OK. Just seek using
|
Thanks! I'll give it a shot. |
Very odd, but thanks for the report. The SD.h is taken from the ESP8266 where, AFAIK, we have been running just fine for over a year w/o any changes. I need to blue-wire up a testbed this weekend to look at it. |
Thanks, guys. I am able to reproduce this and will look into it. The issue seems to be in SDFS or SdFat, not SD, so that at least narrows things down a tiny bit. |
Great. I'm just finished porting Arduino SD library to use for both this core and Arduino-mbed RP2040 core. Just a back up solution in case you don't have time to spend on. If you'd like, I'll create PR later if everything is OK. This arduino-pico core
Arduino-mbed core
|
The O_CREAT/etc. flags on the Pico are a full 32-bits in size, but the core was generating a flag for SdFat using an 8-bit type, so all the O_CREAT, O_TRUNC, O_APPEND, etc. flags got cut off. Fix the flag size. Fixes #214
Thanks @khoih-prog , but it was a pretty silly bug on my part which resulted in a 2-line fix in my own code. Basically, the POSIX flags need a full 32bits to represent them (i.e. O_CREAT=0x400), but I was using a uint8_8 type (since on the ESP8266 where this came from, we defined them that way). When CI finishes I'll push a bugfix release. @kenb2054 and @khoih-prog if you could verify yourselves afterwards, it would be much appreciated. I ran the code here and it does work fine now:
|
The O_CREAT/etc. flags on the Pico are a full 32-bits in size, but the core was generating a flag for SdFat using an 8-bit type, so all the O_CREAT, O_TRUNC, O_APPEND, etc. flags got cut off. Fix the flag size. Fixes #214
Reopening for your feedback on 1.8.6 |
Amazingly fast. I test and report to you ASAP. |
Confirmed the bug is gone using core v1.8.6 |
Thx for confirming! |
Thanks for the fix. It's through things like this that newbies like me learn what's under the hood. |
Hi,
I am trying to create a new file for writing on an SD card from my Pico using:
I can successfully initialize the SD Card reader and can open a file for reading and read the data OK but cannot create a new file with the FILE_WRITE command.
I am using code based on the example file known as Files.ino within the Arduino IDE with core ver 1.8.4. I have slightly modified the file to configure the pins for the SPI bus. The fact that I can initialize and read files means the SPI bus is working ok.
Below is the example code I am using and the result is shown further down:
The result I am getting is
![FILE_WRITE Result](https://user-images.githubusercontent.com/22980611/122196176-589feb80-ceda-11eb-8d55-e4544cbc6d03.png)
The text was updated successfully, but these errors were encountered: