microSD write issue


shahabamo

Recommended Posts

Hi.

I have ported my custom board to designlab and have run various desginlab examples on it. One problem I could not solve yet is writing files to SD card usign SD examples. The sd card could successfully being initialized and even list the files inside it. but the file open and write fails. any suggestion to solve this is appreciated! 

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Alvie,

thanks for the replay,

yes, Only write is not working. I am able to read the files easily. but I cant open any file for writing.

for instance, the "readwrite" example initializes the SD successfully, but it fails at "opening test.txt" step. Although If I manually create the "test.txt" file on the microSD (by connecting it to my PC via a memory-reader), It passes the write step (no write actually!) and reads the contents of test.txt successfully!

Quote

Note that often "writing" is disabled, to save code space

I didn't know that at-all! How can I enable it? 

 

Link to comment
Share on other sites

On 25/03/2017 at 5:47 AM, shahabamo said:

Alvie,

thanks for the replay,

yes, Only write is not working. I am able to read the files easily. but I cant open any file for writing.

for instance, the "readwrite" example initializes the SD successfully, but it fails at "opening test.txt" step. Although If I manually create the "test.txt" file on the microSD (by connecting it to my PC via a memory-reader), It passes the write step (no write actually!) and reads the contents of test.txt successfully!

I didn't know that at-all! How can I enable it? 

 

I assume you're using the SD library. If so, try creating a file named "config.h" in your sketch folder, and add the following line:
 

#define SD_WRITE_SUPPORT 1

That should enable write support.

Sorry this is not documented anywhere. It should be, but unclear where I'd put such information...

Alvie

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.