2022-08-21 05: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 09: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 09:51 PM - edited 2023-08-01 09: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 05: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.