2021-05-06 01:03 PM
Howdy, im very new with filesystems and SD cards in general.
I am trying to develop a system that can manage files from a SD card (images ) and also interface between the PC and the SD card trough USB.
I managed to get my stm32f4-discovery working with an USB mass storage device and a SD card conected via SDIO.
It works but my stm32f4 blindly writes and reads the sd card when USB mass storage asks for it.
I want my stm32f4 to be able to search folders and read/write files from the SD card also ,so i am trying (unsuccesfully) to add the FATFS middleware.
I find tutorials about USB+SD card and FATFS+SD card but not all of them together.
Am i trying to do something weird here?
res=f_mount(&SDFatFS, (TCHAR const*)SDPath, 0);//this returns FR_OK
HAL_Delay(200);
//Open file for writing (Create)
res=f_open(&SDFile, "F7FILE2.TXT", FA_CREATE_ALWAYS | FA_WRITE);//this returns FR_NO_FILESYSTEM
Solved! Go to Solution.
2021-05-10 11:53 PM
So... my issue was not declaring the SIO detection pin in cubeMX
https://community.st.com/s/question/0D53W00000mlP0wSAE/detectsdio-in-cubemx-no-solution
Now it works (sometimes)
2021-05-07 12:21 AM
From youtube: https://www.youtube.com/watch?v=sVgKUhkwnAQ
Hi Javi, Check you MX_FATFS_Init() Make sure it is called properly beforehand.
@Mutex Embedded - Education hi :), what do you mean by properly? The autogenerated code in cubemx places it right before my code:
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USB_DEVICE_Init();
MX_SDIO_SD_Init();
MX_FATFS_Init();
/* USER CODE BEGIN 2 */
//5. File Operations
res=f_mount(&SDFatFS, (TCHAR const*)SDPath, 0); HAL_Delay(200);
//Open file for writing (Create)
res=f_open(&SDFile, "F7FILE2.TXT", FA_CREATE_ALWAYS | FA_WRITE);
2021-05-10 11:53 PM
So... my issue was not declaring the SIO detection pin in cubeMX
https://community.st.com/s/question/0D53W00000mlP0wSAE/detectsdio-in-cubemx-no-solution
Now it works (sometimes)
2024-03-11 08:40 AM
Dear @Javier1 I am working on a simmilar project and i cannot get the usb msc working with fatfs. Is ther a possiblility that you can share your working code?
Thanks in advance
2024-03-13 10:21 AM
@Laurens wrote:Dear @Javier1 I am working on a simmilar project and i cannot get the usb msc working with fatfs. Is ther a possiblility that you can share your working code?
Thanks in advance
sorry, long time has passed, no clue, maybe come back if you figure it out and paste a link
2024-03-14 12:36 AM
Thank you for the response. If i figured it out i will post it here.
2024-03-14 12:43 AM
I just realised i provided a link to the Code in the post, no gusrantees that Will world for you tough
2024-03-14 12:45 AM
aha great i will try it out. Thanks a lot