jonne
January 29, 2018, 1:49pm
1
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
That’s great news for games with lots of content!
adekto
January 29, 2018, 3:08pm
3
yes sounds great
i do wonder what the speed is compared to the current system for loading files
jonne
January 29, 2018, 3:10pm
4
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
adekto
March 22, 2018, 5:17am
5
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
}
}
}
}
jonne
March 22, 2018, 8:56am
6
Is there some way for me to get your entire project so that I can step through the problem with a hardware debugger?
adekto
March 22, 2018, 9:08am
7
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
adekto
March 22, 2018, 9:13am
8
@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);
}
}
}
}
}
adekto
March 22, 2018, 9:34am
9
sorry im using mbed online ide i cant seem to download the project
jonne
March 22, 2018, 9:50am
10
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
adekto
March 22, 2018, 9:56am
11
my_settings.h is just this
#define PROJ_HIRES 0
#define PROJ_ENABLE_SOUND 0
spinal
March 22, 2018, 10:36am
12
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.
adekto
March 22, 2018, 11:13am
13
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
adekto
March 22, 2018, 12:00pm
15
i think thats part of the PokittoDisk not SDFileSystem
1 Like
adekto
March 22, 2018, 4:50pm
16
@jonne any idea whats going on? you are getting this problems also wright?
jonne
March 22, 2018, 8:39pm
17
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
Pharap
March 22, 2018, 9:08pm
18
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.
jonne
March 22, 2018, 9:54pm
19
Open the wavplayer example in embitz, copy my_settings and look at list of files included in the compilation
Pharap
March 22, 2018, 10:30pm
20
I’ve got those:
PokittoWavePlayerLog.txt
-------------- Build: WavePlayer in PokittoEmBitz ---------------
Compiling: Examples\WavePlayer\main.cpp
Compiling: Examples\WavePlayer\wave_player.cpp
Compiling: Pokitto\mbed-pokitto\common\assert.c
Compiling: Pokitto\mbed-pokitto\common\board.c
Compiling: Pokitto\mbed-pokitto\common\BusIn.cpp
Compiling: Pokitto\mbed-pokitto\common\BusInOut.cpp
Compiling: Pokitto\mbed-pokitto\common\BusOut.cpp
This file has been truncated. show original
PokittoWavePlayerSettings.h
/**************************************************************************/
/*!
@file My_settings.h
@author XX
@section HOW TO USE My_settings
My_settings can be used to set project settings inside the mbed online IDE
*/
/**************************************************************************/
This file has been truncated. show original
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?