2024-09-06 02:10 AM - last edited on 2024-09-06 04:42 AM by SofLit
Hallo, this is my code.
I create a directory, and then a file in this directory. If, in another point of the code, I check if the file is present or not, I can read/write it correctly and so on.
Instead, if I stop the execution of the program, when I restart it, I don't find the file above, only the directory.
Any suggestion please? I'm struggling with it...
fxRes = fx_media_open(
&disk1,
"FS",
fx_stm32_levelx_nor_driver,
(VOID *)LX_NOR_OSPI_DRIVER_ID,
(VOID *) fx_nor_ospi_media_memory,
sizeof(fx_nor_ospi_media_memory));
if (FX_SUCCESS != fxRes) {
return;
}
if (!FolderExists(&disk1, (char*)"/DATA"))
{
fxRes=_fx_directory_create(&disk1, (char*)"/DATA");
if (FX_SUCCESS != fxRes)
{
return;
}
}
if (!FileExists(&disk1, (char*)"/DATA/file.txt"))
{
fxRes=_fx_file_create(&disk1, (char*)"/DATA/file.txt");
if (FX_SUCCESS != fxRes)
{
return;
}
}
fx_media_flush(&disk1);
fx_media_close(&disk1);
2024-09-06 04:43 AM
Hello @IVent.1 ,
Please kindly use </> button to paste your code. I've edited your post then.
2024-09-06 08:25 AM - last edited on 2024-09-06 08:29 AM by SofLit
To resolve this issue, we need to ensure that we correctly test the FX_ALREADY_CREATED condition when creating directories and files.
fxRes = fx_media_open(&disk1, "FS",
fx_stm32_levelx_nor_driver,
(VOID *)LX_NOR_OSPI_DRIVER_ID,
(VOID *) fx_nor_ospi_media_memory,
sizeof(fx_nor_ospi_media_memory));
if (FX_SUCCESS != fxRes)
{
return;
}
fxRes=_fx_directory_create(&disk1, (char*)"/DATA");
if (FX_SUCCESS != fxRes)
{
if (FX_ALREADY_CREATED != fxRes)
{
return;
}
}
fxRes=_fx_file_create(&disk1, (char*)"/DATA/file.txt");
if (FX_SUCCESS != fxRes)
{
if (FX_ALREADY_CREATED != fxRes)
{
retrun;
}
}
fx_media_flush(&disk1);
fx_media_close(&disk1);
2024-09-09 01:40 AM
<fxRes=_fx_directory_create(&disk1, (char*)"/DATA"); if (FX_SUCCESS != fxRes) { if (FX_ALREADY_CREATED != fxRes) { return; } } fxRes=_fx_file_create(&disk1, (char*)"/DATA/file.txt"); if (FX_SUCCESS != fxRes) { if (FX_ALREADY_CREATED != fxRes) { retrun; } }>
these 2 _fx_file_create result successfully.
But if I switch off and then on the board, the file created inside the directory is not present anymore.
This is my issue.
2024-09-09 01:56 AM
Could you please tell me which version of the FileX middleware you are currently using?
2024-09-09 02:00 AM
<
#define FILEX_MAJOR_VERSION 6
#define FILEX_MINOR_VERSION 2
#define FILEX_PATCH_VERSION 0
>
2024-09-09 08:50 AM
I conducted an exercise on the B-U585I-IOT02A board using FileX middleware version 6.2.0.
The exercise involved creating a directory and then a file within that directory. The file is correctly written and read in the directory.
However, if I switch the board off and then on again, the file created inside the directory remains present.