2023-01-19 11:17 AM
I'm trying to create and write a file in a USB stick as a USB MSC Host + FatFs using FreeRTOS my MCU is a STM32F413
I'm using the code generated by STM32CubeMX and added the following functions:
f_mount(&USBHFatFS, (TCHAR const*)USBHPath, 1));
f_open(&USBHFile, "Test.TXT", FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
f_mount always returns FR_DISK_ERR, so the file is never created.
However, the USB stick is correctly detected when plugged, and in the generated UserProcess function, the Appli_state variable is set to APPLICATION_START
static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id)
{
/* USER CODE BEGIN CALL_BACK_1 */
switch(id)
{
case HOST_USER_SELECT_CONFIGURATION:
break;
case HOST_USER_DISCONNECTION:
Appli_state = APPLICATION_DISCONNECT;
break;
case HOST_USER_CLASS_ACTIVE:
Appli_state = APPLICATION_READY;
break;
case HOST_USER_CONNECTION:
Appli_state = APPLICATION_START;
break;
default:
break;
}
/* USER CODE END CALL_BACK_1 */
}
I found similar issues in other forums, and set the stack size of USBH_PROCESS to 265 words, heap size to 0x400 and stack size to 0x800 and the FreeRTOS generates all tasks without issue, but I don't know what could be causing the problem with the f_mount function
2023-02-16 02:20 AM
Hello @MRey.1 ,
you can refer to the following example provided under the F4 Firmware Package:
I hope this helps.
BeST Regards,
Walid