2022-12-15 11:10 AM - last edited on 2024-11-04 03:10 AM by Andrew Neil
As I wrote in the subject, Upgrading STM32CubeMX from version 6.6.1 to 6.7.0 The SDCARD stops working.
During mounting :
fr=f_mount(&FatFs,"/",1);
if(fr==FR_OK)
{
...
....
}
returns "FR_NOT_READY"
The micro is an STM32F4, I use SDIO in SD 4 bits Wide bus mode and it has always worked fine.
Regards
Domenico
Solved! Go to Solution.
2023-10-29 01:19 PM
@Ghofrane GSOURI After the comments you received, are you still under the impression that this is not a bug? As has been explained, SD card must be initialized in 1 bit mode before switching to 4 bits. This is per the SD specification. Could we get it fixed?
10 months later.
2023-10-30 12:15 AM - edited 2023-10-30 03:01 AM
I think that this is not a bug fix, it was correct and new version introduces a bug
https://community.st.com/t5/stm32cubemx-mcus/sdcard-does-not-work-with-4bits-wide-bus/m-p/602631/highlight/true#M26324
It should initialize with 1B like it was before and it switches to 4B later (the code is generated if choosing 4B mode):
/* Configure SD Bus width (4 bits mode selected) */
if (sd_state == MSD_OK)
{
/* Enable wide operation */
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
{
sd_state = MSD_ERROR;
}
}
It was correct in 6.6.1 version and the bug is introduced in newer versions! Please fix this!
In worst case I guess you could introduce "initialization bus width mode" option in CubeMX?
2024-02-27 08:34 AM
Thank you!
static void MX_SDIO_SD_Init(void)
{
...
/* USER CODE BEGIN SDIO_Init 2 */
hsd.Init.BusWide = SDIO_BUS_WIDE_1B; //add this line, so that the automatic code generetation with STM32CubeIDE does not override the configuration
/* USER CODE END SDIO_Init 2 */
}
I confirm this also solves the SDIO issue with STM32F446RE, CubeMX 6.10.0 and STM32F4 package 1.28.0.