The Pi SDcard has a standard FAT16 or FAT32 file system and you are required to implement that or use a library from someone who has.
At it's most basic you have functions to read and write to given raw sector on the SD card. Sitting over that is the file system which controls the linking and data held in each raw sector as it does in any FAT implementation.
I did a minimal cut down read version if it helps to look at the code
https://github.com/LdB-ECM/Raspberry-Pi ... r/SD_FAT32
In my implementation the raw SDcard sector being read or written is controlled by this function
Code: Select all
SDRESULT sdTransferBlocks (uint32_t startBlock, uint32_t numBlocks, uint8_t* buffer, bool write );
That is I provide the raw start sector number, how many blocks I am going to read/write provide the buffer for or with the data and a flag as to read or write.There is a lot of code sitting under that call and it has one simple requirement that before you use that call in anyway you first call the function sdInitCard which initializes the SD card system. Optionally you can set the mount flag in that call and it will initialize and read the FAT system.
If you need more detail a good start would be
I also like to remind people if you are using FAT32 commercially, Microsoft has patents on the FAT32 format and use of them requires a license even on embedded systems. I refer you to
https://en.wikipedia.org/wiki/Microsoft ... TomTom_Inc