Function FS Init

From Uzebox Wiki
Jump to: navigation, search

uint8_t FS_Init(sdc_struct_t* sds);


Detects and initializes SD card and FAT filesystem over it.

  • sds: SD data structure. The bufp field must point to a valid 512 byte buffer.

Zero on success, error code on failure.

Video Modes



V.5.x.x bootloaders


This takes a few dozen milliseconds. It populates the SD data structure according to the results, which means setting the Filesystem type flag in addition to SDC_Init().

The error codes returned by this function:

  • 1: CMD0 failed (possibly no card in socket)
  • 2: CMD59 failed (couldn't enable CRC checking)
  • 3: ACMD41 failed (not possible to initialize, bad card)
  • 4: ACMD41 timed out
  • 5: CMD58 failed (couldn't query card)
  • 6: SD read fault
  • 7: No usable FAT filesystem found

When the library is operating in compatibility mode (no bootloader detected), it does not return error code 2, rather tries to enable CRC checking twice and ignore failure. This is used to support the Uzem emulator which doesn't emulate SD CRC.