greiman / Fat16

Smaller FAT16 only library for Arduino
28 stars 12 forks source link

4GB FAT16 is not supported #6

Open Obaid-ur-Rehman opened 4 years ago

Obaid-ur-Rehman commented 4 years ago

Hi, I have used your library with 2GB SD cards and it works fine. It seems the library is not working with 4GB SD cards though. Could you guide me if library code needs some kind of changing? Regards

PMKrol commented 1 year ago

I had same problem so I wrote to Author, here's his and my conversation:

My first email:

Thanks for this library. I have some questions: Will this work for 3.68 MHz clocked ATmega8 CPU? On issues page of GitHub there is one comment about problematic 4gb card while 2gb works fine. Is this a software problem or hardware? Is it fixable?

And my second:

sob., 4 lut 2023, 16:00 użytkownik Bill Greiman [fat16lib@sbcglobal.net](mailto:fat16lib@sbcglobal.net) napisał: You must use a "Standard" SD card. These are 2GB or smaller. "High Capacity" Cards have a different protocol.

This is perfectly reasonable. I thought 4gb is limit for standard SD. My mistake.

Fat16 was developed for a 168 board with KB of RAM. 512 bytes will be used for a sector buffer. This is necessary since updating file system structures requires reading a sector, modifying the data and writing the sector back to the SD.

Except for SD my program is currently highly optimised, it is my challenge now to fit it into ATmega8. If I fail, I'll try with 168 or even 328, but with those two I'll probably stitch to standard SD.

The ATmega8 will be marginal with 8 kB of flash. Very little RAM was available on the ATmega168.

I know about limitations, I read at arduinos forum. It's probably that I sometimes I loke to make my life harder, that's why I try with A8. Please don't judge ;)

The library should work for 3.68 MHz clock. SD cards work for SPI clocks as slow as 200 kHz.

Oh, that's very comforting as I'm trying to make it as less as possible in power consumption. (Yeah, again, A8 is not smart choice, I know...)

Additional note: I checked with 1GB SD and it works perfectly fine with ATmega8a@3.68MHz.