I've been playing around with FatFs for about 1 mounth now.
I succefully used SDMMC and SPI protocol to save and read data from an SD card.
I order to improve the system (it's a improvement for the project)
We decided to add an UDB Mass Storage Key. (approx 8Giga)
I found this : [FATFs] Opening file on USB stick returns FR_DISK_ERR
And it describe exaclty my error.
I'm able to mount the USB stick but I couldn't f_open() it.
most of my code is a copy paste of the example provided by ST.
I copy what i made at the end of the message.
if some of you have or had the same issue could you provide me some help. or in other case explain me more precisely what smrtkai describes in the post i link at the begining.
thanks in advance
edit : forget to say that i m working with an STM32H743zi on a nucleo board
if(FATFS_LinkDriver(&USBH_Driver, "") ==0)
/* USB Host Background task */
/* Mass Storage Application State Machine */
FS_FileOperations(); <-- I got issues here
Appli_state = APPLICATION_IDLE;
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_SET); //put it on if linkdriver fail
static void FS_FileOperations(void)
FRESULT res; /* FatFs function common result code */
uint8_t wtext = "This is STM32 working with FatFs + USB/FS"; /* File write buffer */
/* Register the file system object to the FatFs module */
if(f_mount(&USBHFatFS, "", 0) == FR_OK)
/* Create and Open a new text file object with write access */
res = f_open(&USBHFile, "STM32.TXT", FA_CREATE_NEW); <- Biggest issue is here
if(res == FR_OK)
/* Write data to the text file */
res = f_write(&USBHFile, wtext, sizeof(wtext), (void *)&byteswritten);
if((byteswritten > 0) && (res == FR_OK))
/* Close the open text file */
//HAL_GPIO_WritePin(GPIOB,GPIO_PIN_7,GPIO_PIN_SET); //Led de debug pour confimer la bonne fermeture du fichier
/* Error */
// HAL_GPIO_WritePin(GPIOB,GPIO_PIN_14,GPIO_PIN_SET); //Led de debug pour confimer la bonne fermeture du fichier