Small SDCard library

Hello

Is there anybody hwo knows a small library for SDCards? My program is to big so I can't use the arduino library. I found "filelogger" but it runs not on my arduino 1.01. I make all changes and get no compiler errors but I only get an initialisation error.

Can anybody help me?

Is there anybody hwo knows a small library for SDCards?

The limit on the size is the fact that SD cards are written to in blocks of 512 characters at a time.

Can anybody help me?

Get a Mega.

It's not always meaningful to take the biggest prozessor :) The 328 is better for normal layouts and 10kb memory only for logging is unacceptable for my applikation.

Exactly which library are you using? If using the SD try switching to SDfat (leaner faster and better supported).

Paul

You might want to look at my Fat16 library http://code.google.com/p/fat16lib/downloads/list.

It’s smaller than my SdFat library but only supports FAT16 on standard SD cards.

SdFat16 works great. You can download it here

I try the library and it works really good. Thank you very much for help. The library save over 5 KB space.

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.

https://github.com/adafruit/SD

Hello!

Try to get work sdfat16 with Arduino Ethernet with no luck :( 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? :( 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 :( 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 "[u]Smaller FAT16 only library for Arduino[/u]" from here https://github.com/greiman/Fat16 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.