2023-10-25 04:08 AM
Hi all,
I am using FileX with my Nucleo-U575ZI-Q, and I want to be able to open multiple files at the same time.
Now every time I try to do this, the first file opens fine no problems but when I try to open another file (without closing the first) I get the error - FX_NOT_FOUND.
When I use FATFS there is an option in the IOC to increase the number of files allowed open (FS_LOCK). But with FileX I cannot seem to find anything in the IOC or in the headers files.
Also Google is not useful at all for any FileX related information, its very sparse!
Thanks!
Solved! Go to Solution.
2023-11-02 02:16 AM
Hi all,
Firstly the code snippet was very rough code and is not used, it was me just grabbing little bits of code to show what I was doing, there is wrapper code around all of it that I could not share.
The solution to this problem was... a bit of user error. Turns out the system, which is a big project, was searching the SD card in folders when something else triggered and wanted to read a file from root, meaning the default directory was not as expected. Fixed by adding a "/" to the file name as it was in root.
The big question that no one can seem to answer is, what is the max number of files allowed to be open at the same time. There is no FX_MAX_FILE_OPTIONS or filex.cfg anywhere, is filex using a dynamic approach and is limited by memory instead?
2023-10-25 09:16 AM
Hi @joeSD
Thanks for reaching out :smiling_face_with_smiling_eyes:!
Could you please share a code snippet how are you opening the files in FileX?
regards
Haithem.
2023-10-26 01:18 AM
static uint8_t media_memory[SECTOR_SIZE / sizeof(uint8_t)];
fx_media_open(&fxmSDCard, "/", fx_stm32_sd_driver, (VOID *)FX_NULL, (VOID *) media_memory, sizeof(media_memory));
FX_FILE fx_file1;
uint32_t result = fx_file_open(&fxmSDCard, fx_file1, "test1.txt", FX_OPEN_FOR_READ);
ULONG bytesRead = 0u;
uint8_t* data = {0}
fx_file_read(fx_file1, data, 512, &bytesRead))
FX_FILE fx_file2;
result = fx_file_open(&fxmSDCard, fx_file2, "test2.txt", FX_OPEN_FOR_READ);
This is a rough code snippet. Opening files is fine, it just only allows me one at a time.
Thanks.
2023-10-26 01:31 AM
Thank you for your response.
Few questions. I have searched for the define and cfg file and cannot find it at all. Where is it located?
And if its a define, surely something must be using it, which I cannot find either.
I am using FileX in standalone mode as well.
Thanks.
2023-10-26 01:32 AM
Hi @joeSD
Except the "uint8_t* data" declaration, I can't see any issues in this snippet.
you may try to compare your code to the following one where two threads are accessing 2 files in R/W modes on the smae uSD.
https://github.com/STMicroelectronics/STM32CubeU5/blob/main/Projects/STM32U575I-EV/Applications/FileX/Fx_MultiAccess/FileX/App/app_filex.c
Hope This Helps.
regards
haithem.
2023-10-26 03:54 AM
Hi @joeSD
I've updated the following example, that uses FileX in standalone mode, to open 2 files and it works correctly.
https://github.com/STMicroelectronics/STM32CubeU5/blob/main/Projects/STM32U575I-EV/Applications/FileX/Fx_File_Edit_Standalone/FileX/App/app_filex.c
below the screenshot of the uSD content and attached the modified source code.
hope this helps.
regards
Haithem.
2023-10-26 08:12 AM
Thank you for your response. I have tried to see any differences and I do not think there is.
The only thing I can note is my first file is in a directory where as my second file is in the root directory. When I open the first file I use the full path to it, does this change the default directory by itself? So when I try to open the second file its looking in the same directory as the first file - which it isn't.
Thanks.
2023-10-26 09:13 AM
Hi,
Opening a file using the full path, doesn't alter the default directory.
you can check yourself by calling the fx_directory_default_get().
https://learn.microsoft.com/en-us/azure/rtos/filex/chapter4#prototype-3
2023-10-26 09:53 AM - edited 2023-10-26 09:53 AM
> Except the "uint8_t* data" declaration, I can't see any issues in this snippet.
Did you fix that line [EDIT: as mentioned by @Haithem Rahmani)? As written in your post above, you create a pointer to uint8_t then assign zero to it, making it a NULL pointer. The read function then tries to write data to address zero - which is NOT what you want. What happens when that write occurs depends on your CPU and how you have memory mapped. If 0 is mapped to RAM then you are overwriting other variables.
2023-11-02 02:16 AM
Hi all,
Firstly the code snippet was very rough code and is not used, it was me just grabbing little bits of code to show what I was doing, there is wrapper code around all of it that I could not share.
The solution to this problem was... a bit of user error. Turns out the system, which is a big project, was searching the SD card in folders when something else triggered and wanted to read a file from root, meaning the default directory was not as expected. Fixed by adding a "/" to the file name as it was in root.
The big question that no one can seem to answer is, what is the max number of files allowed to be open at the same time. There is no FX_MAX_FILE_OPTIONS or filex.cfg anywhere, is filex using a dynamic approach and is limited by memory instead?