[Announcement] SDFileSystem available soon on Pokitto

Hello all!

I just concluded porting and testing SDFileSystem to Pokitto.

SDFileSystem is a much more advanced SD file handling library, that allows things like:

  • full directory support (open to directory, make directory, delete directory)
  • creating and writing new files on card
  • opening multiple files at the same time
  • FAT32 SDHC support, up to 32GB
  • long filenames
  • standard C-style file manipulation (fprintf)

More on this soon!

Meanwhile, you can look at the documentation:

https://docs.mbed.com/docs/trying-new-skeletong-for-apis/en/latest/APIs/memory_files/SDFileSystem/

10 Likes

I cannot find their actual documentation, just an example.

The example seems like to be standard C file i/o thought, so it won’t be difficult to use anyway :slight_smile:
That’s great news for games with lots of content!

yes sounds great
i do wonder what the speed is compared to the current system for loading files

Alot faster. First I thought it did not work, then I realized the test had already run through

BUT: the SD card program “bootloader” will not use this library. It takes too much memory.

1 Like

iv been trying out SDFileSystem and i hit very odd behavior
it writes a file fine in main but it cant do the same thing in the game loop (it softlocks)

#include "Pokitto.h"
Pokitto::Core game;
#include "SDFileSystem.h"
SDFileSystem sd(P0_9,P0_8, P0_6, P0_7,"sd");

void save(){
    FILE *fp = fopen("/sd/test.dat", "w");
    if(fp == NULL) { return; }
    fprintf(fp, "test");
    fclose(fp);
}
int main(){
    game.begin();
    //save(); //works fine here
    while(game.isRunning()){
       if(game.update(true)){
          if (game.buttons.pressed(BTN_A)){
                save(); //game crash
          }
       }
    }
}

Is there some way for me to get your entire project so that I can step through the problem with a hardware debugger?

i stripped it down as much as i can for the problem
though stripping it down like this it seem to not crash but its still not working
it wont create or save the file and im stumbed why this is

@jonne during testing this it though i got it working but no it only works if its the first time it enters the loop, see here if you press a it wont make the 3rd file

#include "Pokitto.h"
Pokitto::Core game;
#include "SDFileSystem.h"
SDFileSystem sd(P0_9,P0_8, P0_6, P0_7,"sd");


int main(){
    game.begin();

    FILE *fp = fopen("/sd/test.dat", "w");
    if(fp == NULL) { return; }
    fprintf(fp, "outside loop");
    fclose(fp);

    bool once = true;
    bool onceagain = true;
    while(game.isRunning()){
       if(game.update(true)){
            if(once){
              once = false;
              FILE *fp = fopen("/sd/test2.dat", "w");
              if(fp == NULL) { return; }
              fprintf(fp, "inside loop");
              fclose(fp);
           }
           if (game.buttons.repeat(BTN_A,0)){
           if(onceagain){
              onceagain = false;
              FILE *fp = fopen("/sd/test3.dat", "w");
              if(fp == NULL) { return; }
              fprintf(fp, "inside loop again");
              fclose(fp);
           }
           }
       }
    }
}

sorry im using mbed online ide i cant seem to download the project

Ok. I have NOT tested sdfatfilesystem in mbed online

But put your my_settings.h and I will sew if I can reproduce the problem

my_settings.h is just this


#define PROJ_HIRES 0
#define PROJ_ENABLE_SOUND 0

I haven’t had any issues saving/loading a file outside of the main loop. I wouldn’t know where to start in debugging that issue.

yes i have no idea whats going on i first though its loading the file every frame and that might be an isue but the code i show as example specificly tries to run it a single time

I think you need to write “#define POK_ENABLE_SD 1” in my_settings file

i think thats part of the PokittoDisk not SDFileSystem

1 Like

@jonne any idea whats going on? you are getting this problems also wright?

Yes I know whats going on. I am at my hotel in Minneapolis totally flattened by jetlag. I will try to look at this later today

1 Like

If you don’t get chance to fix it, perhaps link to the area that’s causing the issue with a brief explanation of the issue so someone else can attempt to fix it.

(Unfortunately that probably won’t be me since Minneapolis is 5 hours behind my time zone, unless it remains untouched for 10-14 hours.)

That said, it’s probably not an urgent issue.

Open the wavplayer example in embitz, copy my_settings and look at list of files included in the compilation

I’ve got those:

I’m guessing @adekto needs to #define NOPETITFATFS (because petit FAT causes conflicts, probably) and make sure that the relevant files are being included in compilation?