AnsweredAssumed Answered

Why does f_write not work in CubeMX project

Question asked by greenwood.greg on Mar 18, 2018
Latest reply on Mar 18, 2018 by Clive One

I have two projects, one from the F746G-Discovery Projects repo called FatFs_uSD_RTOS, and one created from CubeMX based on the template for the F746G-Discovery board with FatFS and FreeRTOS enabled.  The CubeMX project code fails to write to the SD card with the f_write function timing out after 30 seconds.  Of course, the FatFs_uSD_RTOS example works.  I have spent a week now comparing the code execution and I am very confused about how the example project is even working at all. 

 

First, the CubeMX project, is timing out because the write complete callback is not being called and that is because the os message for the call back is not being set.

 

Second, in the example project (FatFs_uSD_RTOS), the SD card is not being initialized as it is in the Cube project with MX_SDMMC1_SD_Init.  However, it appears that as a result of the example project call to link the SD card to Fatfs the SDMMC_Init call in the stm32f7xx_ll_sdmmc.c seems to do the same thing.  But if I comment out the the MX_SDMMC1_SD_Init in the Cube project then the f_open call fails.  Odd since f_open also calls the HAL SDMMC_Init function. 

 

I am not sure the timeout issue is related to the init function difference. 

Has anyone successfully built code using CubeMX based on the F476G discovery board template that uses FreeRTOS, FatFS, SDMMC that writes and reads files to the SD card on the discovery board?

 

This post is a continuation of one I made a couple of weeks back but that post seems to be corrupted as it keeps crashing the web server with a 409 permissions issue.

Outcomes