External file ressource on embedded system (C language with FAT) -


my application/device running on arm cortex m3 (stm32), without os fatfs) , needs access many resources files (audio, image, etc..)

  • the code runs internal flash (rom, 256kb).
  • the resources files stored on external flash (sd card, 4gb).
  • there not ram (32kb), malloc complete file package not option.

as user has access resources folder atomic update, package theses resources files in single (.dat, .rom, .whatever) user doesn't mishandle theses data.

can point me nice solution so?

i don't mind remapping fopen, fread, fseek , fclose in application, not starting scratch (coding serializer, table of content, parser, etc...). system quite limited (no malloc, no framework, stdlib , fatfs)

thanks input can give me.

note: i'm not looking solution resources embedded in code (rom) way big that.

it should possible use fatfs recursively.

drive 0 real device, , drive 1 file on drive 0. can implement disk_* functions this

#define blocksize 512 fil imagefile; dstatus disk_initialize(byte drv) {   uint r;   if(drv == 0)     return sd_initialize();   else if(drv == 1) {     r = f_open(&image, "0:/resource.dat", fa_read);     if(r == fr_ok)       return 0;   }   return sta_noinit; } dresult disk_read(byte drv, byte *buff, dword sector, dword count) {   uint br, r;   if(drv == 0)     return sd_read_blocks(buff, sector, count);   else if(drv == 1) {     r = f_seek(&imagefile, sector*blocksize);     if(r != fr_ok)       return res_error;     r = f_read(&imagefile, buff, count*blocksize, &br);     if((r == fr_ok) && (br == count*blocksize))       return res_ok;   }   return res_error; } 

to create filesystem image on linux or other similar systems you'd need mkfs.msdos , mtools package. see post on how it. might work on windows cygwin, too.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -