2022-08-21 5:22 PM
Yes, I use Cube.
In the documentation I read that eMMC is connected to SDMMC1.
SDMMC1 can be configured either as SD or MMC. I get the SD option in FATFS only when SDMMC1 is configured as SD.
OK, I found the example to use MMC driver, I configured it.
Anyway - it doesn't work. I get SDMMC_ERROR_CMD_RSP_TIMEOUT.
Here's my SDMMC1 initialization:
static void MX_SDMMC1_MMC_Init(void)
{
/* USER CODE BEGIN SDMMC1_Init 0 */
/* USER CODE END SDMMC1_Init 0 */
/* USER CODE BEGIN SDMMC1_Init 1 */
/* USER CODE END SDMMC1_Init 1 */
hmmc1.Instance = SDMMC1;
hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hmmc1.Init.BusWide = SDMMC_BUS_WIDE_8B;
hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hmmc1.Init.ClockDiv = 2;
if (HAL_MMC_Init(&hmmc1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SDMMC1_Init 2 */
/* USER CODE END SDMMC1_Init 2 */
}
UPDATE:
Now I'm confused. The initialization passes after reset or power cycle. I get the error only directly after flashing the board. Why is that?
Solved! Go to Solution.
2023-08-01 9:26 AM
IIRC, the H747 SD works very different from eMMC on H745. You should configure it as SD, not MMC. I'm surprised you get the error on f_write() and not earlier on f_mount(). Anyway, configure it as SD, ensure you don't have any conflicts on pins, check the clock and it should just work. Be careful to not call FATFS functions from ISR. But when I called FATFS from ISR I got FR_TIMEOUT most of the times.
2023-08-01 9:51 PM - edited 2023-08-01 9:53 PM
Oh no. I insert external eMMC into the slot of SD card and I expect eMMC work with FATFS same as SD card. But it's hard so now, looks like it can't work properly.
2023-08-02 5:20 AM
Check your external eMMC datasheet on what interface does it use. I'd guess it uses SD interface and as such, it doesn't provide benefits of internal eMMC chips that just use more data lines for extra speed, but I might be wrong. From what I read they just emulate a SD card. They can be a little faster by themselves, but their speed is limited to the interface speed. As you connect it to SD card slot, it should probably work as a SD card. If it doesn't, maybe try different clock speeds. Also check the power supply, I once had an issue with USB disk because it got the power supply from a data pin instead of dedicated chip that was not enabled with code. Check the board schematics to be sure.
2025-06-27 12:44 AM
Almost 3 years later, Cube is still unable to generate FatFs for eMMC. Is that so exotic that is has no priority for the Cube Team? Can't be that hard since it works quite well with SD card?
@FBLplease add to Cube
2025-06-30 6:56 AM
Hi @MMenz.1
CubeMX does not natively support configuring FatFS for eMMC memory directly. The APIs for card initialization, read, and write operations are BSP dependent. This means that CubeMX cannot automatically generate the necessary configurations for each eMMC card with FatFS.
However, it is possible to adapt an SD/FatFS project to an MMC/FatFS project by manually importing the MMC driver and replacing the SD card APIs with eMMC-specific APIs. This requires modifications in files such as: bsp_driver_sd.c/.h and sd_diskio.c/.h.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.