Small SDCard library

is it correct that you can only have 2GB max partition size with fat16?

The SD standard requires FAT16 formatted cards to be 2GB or less.

The standard requires SDHC cards, 4GB - 32GB, to be formatted FAT32.

fat16lib. Thanks for the library. I will try your library too. I just started using SD card and am using SD library from adafruit. I can't find manual to the library. Your library is documented with doxygen. Awesome!

With adafruit SD library, the sample write code takes 1.1KB of SRAM.

Hello!

Try to get work sdfat16 with Arduino Ethernet with no luck :frowning: init return error.
Meanwhile SD and sdfat16/32 are working good! Any ideas?
Thanks!

Format a Standard SD card, 2GB or less with SdFotmatter https://www.sdcard.org/downloads/formatter_3/.

Change line 187 of the fat16info.pde example to:

  if (!card.init(0, 4)) {

This selects full SPI speed and pin 4 as chipselect.

Run the fat16info example and post the output.

Post your the init code for Fat16 and any output.

Hello!

Okay, I've made some magic gestures:

  1. Arduino Ethernet board with inserted microSD card (SanDisk, 2GB, formatted with SDFormatter)
  2. fat16info.pde with if (!card.init(0, 4)) {
  3. Result is:

Fat16 version: 20111205
FreeRam: 1261

type any character to start
card.init failed
SD error
errorCode: 1
errorData: 0

type any character to start

And next test:

  1. Same Arduino Ethernet board with same microSD card.
  2. SdInfo.pde (from sdfat16/32 library) with const uint8_t SdChipSelect = 4;
  3. And result is:

SdFat version: 20121203

type any character to start

init time: 12 ms

Card type: SD2

Manufacturer ID: 0X3
OEM ID: SD
Product: SU02G
Version: 8.0
Serial number: 1408082784
Manufacturing date: 6/2010

cardSize: 1977.61 MB (MB = 1,000,000 bytes)
flashEraseSize: 32 blocks
eraseSingleBlock: true

SD Partition Table
part,boot,type,start,length
1,0X0,0X6,135,3858489
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60281
freeClusters: 60281
freeSpace: 1975.29 MB (MB = 1,000,000 bytes)
fatStartBlock: 136
fatCount: 2
blocksPerFat: 236
rootDirStart: 608
dataStartBlock: 640

type any character to start

What I'm doing wrong with fat16 library? :frowning:
Btw, I tried 4 Arduino boards with same result, except one which has custom bootloader with TFTP support, here is result of fat16info.pde:

Fat16 version: 20111205
FreeRam: 1261

type any character to start

init time: 237

Manufacturer ID: 3
OEM ID: SD
Product: SU02G
Version: 8.0
Serial number: 1408082784
Manufacturing date: 6/2010

Card Size(blocks): 3862528

Partition Table:
part,boot,type,start,size
1,0,6,135,3858489
2,0,0,0,0
3,0,0,0,0
4,0,0,0,0

FAT Volume info for partition: 1
Volume is FAT16
clusterSize: 64
clusterCount: 60281
fatCount: 2
fatSize: 236
totalBlocks: 3858489

Root Directory:
name ext att size

Done

type any character to start

And same board with SdInfo.pde:

SdFat version: 20121203

type any character to start

card.init failed
SD errorCode: 0X1
SD errorData: 0X0

type any character to start

That's really odd for me :frowning:
Hope you could help.
Thank you!

Looks like the Ethernet controller is causing the problem. It's chip select is pin 10 which is also SS for 328 Arduinos. In SdFat I set SS as an output and set it high. SD.h also is based on SdFat so it's O.K. In Fat16 I only make SS an output so it will be low.

To disable the Ethernet controller put his before the line with card.init().

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

I will add this to Fat16. The Ethernet shield didn't exist when I wrote Fat16 so I didn't make SS high when it was not chip select.

Thank you very much! It works!

I am using Pin (2) as my chip select pin and change the first line in the demo code to:

const uint8_t CHIP_SELECT = 2;

I also added pinMode to 10.

pinMode(10, OUTPUT);
digitalWrite(10, HIGH);

if (!card.init(0, 2)) {
PgmPrintln("card.begin failed");
sdError();
return;
}

I keep getting the following error:

Fat16 version: 20140806
FreeRam: 1270

type any character to start
card.begin failed
SD error
errorCode: 2
errorData: 1

type any character to start

Any help would be appreciated?

Hello,

My program is to big(22.5Kb) so I can't use the arduino SD.h library and i want to try fat16.h.
I downloaded the "Smaller FAT16 only library for Arduino" from here GitHub - greiman/Fat16: Smaller FAT16 only library for Arduino but i get compilation error for the example files (fat16write,fat16read,fat16AnalogLogger...).
I`m using Arduino 1.0.6 and an arduino uno bord with this type https://s15.postimg.org/kfxyhv23f/microsd_breakout_board.jpg of SD card reader.
2GB uSD card formated FAT16.

i get this compilation error:

fat16write.ino: In function 'void setup()':
fat16write:50: error: 'class SdCard' has no member named 'begin'

What can i do to resolve the compilation problem?

What can i do to resolve the compilation problem?

Are you sure that you don't have another library of the same name? The SdCard class does have a method called begin().

Are you sure that you don't have another library of the same name?

I search on my computer for "Fat16.h" and i found in two location:

  • ...\My Documents\Arduino\libraries\Fat16-master\Fat16
  • ...\Program Files\Arduino\libraries\Robot_Control

I deleted the Robot_Control folder and after I try to compile the fat16write.ino and i get these errors:

fat16write:12: error: 'SdCard' does not name a type
fat16write:13: error: 'Fat16' does not name a type
fat16write.ino: In function 'void error_P(const char*)':
fat16write:19: error: 'PgmPrint' was not declared in this scope
fat16write:20: error: 'SerialPrintln_P' was not declared in this scope
fat16write:21: error: 'card' was not declared in this scope
fat16write.ino: In function 'void writeNumber(uint32_t)':
fat16write:40: error: 'file' was not declared in this scope
fat16write.ino: In function 'void setup()':
fat16write:46: error: 'PgmPrintln' was not declared in this scope
fat16write:50: error: 'card' was not declared in this scope
fat16write:53: error: 'Fat16' has not been declared
fat16write:53: error: 'card' was not declared in this scope
fat16write:63: error: 'file' was not declared in this scope
fat16write:63: error: 'O_CREAT' was not declared in this scope
fat16write:63: error: 'O_EXCL' was not declared in this scope
fat16write:63: error: 'O_WRITE' was not declared in this scope
fat16write:65: error: 'file' was not declared in this scope
fat16write:66: error: 'PgmPrint' was not declared in this scope
fat16write:71: error: 'file' was not declared in this scope
fat16write:78: error: 'file' was not declared in this scope

I suspect that you'll learn more if you enable verbose mode when compiling.

I suspect that you'll want to rename the library folder to remove the -master crap.

Hello.
I found an old post in the forum (Small SDCard library) where talk about your FAT16 library.
I'm having the same space issues and your library seems to be small enough to work for my project, but I can't find a way to format a micro SD card to work with the library examples.
I formatted it in FAT16 but the fat16info.ino example gives an error (because the card size blocks is 512).
Do you know of any utility you could use to format today's SDs to work with the library?

The Fat16 library only works with “Standard SD card” these are 2GB or smaller. SDHC cards require a different protocol and won’t work even if they are formatted FAT16.

Thanks for the quick reply!!
I understand.
Is there any alternative library to sd/sdfat libraries that can handle today's SDHC cards that has a smaller footprint?

SdFat is the smallest SDHC Arduino SD library, the official SD.h library is just a wrapper for a 2009 version of SdFat.

You can reduce the size of SdFat by about 2,000 bytes by editing SdFatConfig.h.

For the BackwardCompatibility example in:

https://github.com/greiman/SdFat-beta

The unmodified size for Uno is:

Sketch uses 11150 bytes (34%) of program storage space. Maximum is 32256 bytes.
Global variables use 997 bytes (48%) of dynamic memory, leaving 1051 bytes for local variables. Maximum is 2048 bytes.

With these settings in SdFatConfig.h
#define USE_FAT_FILE_FLAG_CONTIGUOUS 0
#define ENABLE_DEDICATED_SPI 0
#define USE_LONG_FILE_NAMES 0
#define SDFAT_FILE_TYPE 1

The size is:

Sketch uses 8966 bytes (27%) of program storage space. Maximum is 32256 bytes.
Global variables use 991 bytes (48%) of dynamic memory, leaving 1057 bytes for local variables. Maximum is 2048 bytes.

Great! I'll try those.
I'm also having trouble to get this microSD adapter to work, no matter what library I use.


According to the research I've done online it should work (I tried with an Arduino Mega 2560 and Arduino Pro mini ATmega328) and several different microSD cards, even an old 2gb card.
Does it require any special settings?
I'm trying the examples in the sd and sdfat libraries and can't get them to work with this adapter. They all work with no problem in a SD Shield (with SD to microSD adaptor)

SDFAT beta seems to work better with this microSD module.
I need to do more testing, but I believe there's some issue if you change the CS pin (at least using an Arduino Pro Mini). I had problems trying to use pin A0.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.