SD reader Arduino

27 views
Skip to first unread message

George-Eric Amparis

unread,
May 9, 2016, 3:53:55 AM5/9/16
to connected-commu...@googlegroups.com
Hi all,

I have recently purchased an SD card reader from Tronixlabs and then tried using the SD library that comes with the Arduino IDE, however, it takes up a lot of memory on the ATMega chip. Consequenly, I am getting strangely named bad files saved to the SD card that I wouldn't be able to delete, I will have to reformat the card to clear it. I have downloaded some other alternative SD library, but they are not working or not being recognized by the IDE.

Has anyone been using an Arduino compatible SD card reader and used a library that works reliably? If so, do you know of a link as to where I could find it?

Thanks in Advance,


GE

Brett Downing

unread,
May 9, 2016, 5:31:17 AM5/9/16
to connected-commu...@googlegroups.com

Hey,

I found that one building the door at the Artifactory.
Are you using files as function arguments?
The default arduino sd card library has issues with memory leaks in odd circumstances. I found that when you pass a file handle as an argument, it calls new() again and you can never fully free the memory.
Then the stack collides with the heap and you get undocumented results.

It might be worth skim reading the source for that lib, there really was quite a bit of weirdness in the memory management that dictates how it should be used.
(Oh, and the default example leaks like a sieve)

Cheers,
Brett

--
You received this message because you are subscribed to the Google Groups "Connected Community HackerSpace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to connected-community-h...@googlegroups.com.
To post to this group, send email to connected-commu...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/connected-community-hackerspace/BLU180-W46B4799721B48188A76ED1B8700%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.

George-Eric Amparis

unread,
May 9, 2016, 6:58:26 AM5/9/16
to connected-commu...@googlegroups.com
Hi,

I appreciate your explanation on the matter, but while that may explain why I am getting some weird result as you may have pointed Brett, it doesn't really help me all that much. Given that there are issues with this library that was provided with the IDE, I am looking for an alternative library which does what the IDE library supposed to do, but doesn't have memory leaks, i.e. has much superior memory management.

Regards,

GE


Date: Mon, 9 May 2016 17:30:25 +0800
Subject: Re: [CCHS] SD reader Arduino
From: brett.d...@gmail.com
To: connected-commu...@googlegroups.com

Brett Downing

unread,
May 9, 2016, 8:10:48 AM5/9/16
to connected-commu...@googlegroups.com

I've not found a better library.
The memory leak only occurs in very specific uses, so the workaround is not hard.
If you skim read the library, you'll find the constraints and it's smooth sailing from there.
iirc, it takes only a thousand or so lost file handles to blow the stack and crash the main loop, so testing for leaks is pretty easy: Cycle the open/close code and print a counter to serial until it crashes or reaches 10k.

Regards
Brett

George-Eric Amparis

unread,
May 9, 2016, 8:53:56 AM5/9/16
to connected-commu...@googlegroups.com
Hi Brett,

Will you be at the Hackerspace tomorrow? 

GE


Date: Mon, 9 May 2016 20:10:45 +0800
Subject: RE: [CCHS] SD reader Arduino

Brett Downing

unread,
May 9, 2016, 10:34:17 AM5/9/16
to connected-commu...@googlegroups.com
Hi George,

I'd love to be there, but I'm in Perth.
I just lurk on the list from time to time.

Brett

Reply all
Reply to author
Forward
0 new messages