2025-05-02 1:12 PM
I'm putting together a small test program in CubeIDE 1.18.1, CubeMX 6.14.1, on Intel MacOS 15.4.1 on a STM32F469I-DISCO and I've noticed some (possibly) incorrect SDIO initialization code.
Cube generated this:
void MX_SDIO_SD_Init(void)
{
/* USER CODE BEGIN SDIO_Init 0 */
/* USER CODE END SDIO_Init 0 */
/* USER CODE BEGIN SDIO_Init 1 */
/* USER CODE END SDIO_Init 1 */
hsd.Instance = SDIO;
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_4B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 0;
if (HAL_SD_Init(&hsd) != HAL_OK)
{
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SDIO_Init 2 */
/* USER CODE END SDIO_Init 2 */
}
and it always calls Error_Handler at line 24 with an error value of 0x0400'0000 (SDMMC_ERROR_REQUEST_NOT_APPLICABLE).
Notice that the HAL_SD_Init call on line 18 uses the .BusWide value of SDIO_BUS_WIDE_4B on line 15. Notice that on line 22 it calls to set up the bus for the same 4B width. It doesn't like that. I suspect that the bus is already set up for 4-bit width and doesn't like being told to set it up for 4-bit width.
If you look in the demo program that works, Fx_uSD_File_Edit, you can see that they initially use SDIO_BUS_WIDE_1B for the Init, then switch to 4B. If I change my code to use 1B, it succeeds and the card can be opened successfully.
A regression at some point?
Thanks,
Andrei (Your neighbour from The Great White North)