FW v1.16.1 broke HAL MMC Driver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-04 10:07 AM
Using a custom board with an STM32F769 I had successfully interfaced to an eMMC with the HAL-MMC driver. The limitations of the driver's ability to query the extended CSD were clearly noted on this forum. I implemented my own routines to retrieve this information and correct the block sizes (after HAL_MMC_Init call). After upgrading to F7 FW v1.16.1 (released mid February) I noticed this functionality had been added to the driver itself so I removed my version.
The out of the box driver fails when calling MMC_ReadExtCSD() from HAL_MMC_GetCardCSD() with a command timeout (CTIMEOUT) error. After quite a bit of debuggin I compared the driver to the STM32L series driver and noticed in that version the SDMMC_CmdSelDesel() call was made prior to HAL_MMC_GetCardCSD(). After making the modification the code runs successfully. I'm by no means an SDMMC expert but I believe this fix needs to be made in the next firmware release. I would appreciate ST/Community confirming the issue. The "fixed" and suspect code is below:
/////// Working Code //////////
/* Select the Card */
errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
if(errorstate != HAL_MMC_ERROR_NONE)
{
return errorstate;
}
/* Get CSD parameters */
if (HAL_MMC_GetCardCSD(hmmc, &CSD) != HAL_OK)
{
return hmmc->ErrorCode;
}
/////// Suspect Code //////////
/* Get CSD parameters */
if (HAL_MMC_GetCardCSD(hmmc, &CSD) != HAL_OK)
{
return hmmc->ErrorCode;
}
/* Select the Card */
errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
if(errorstate != HAL_MMC_ERROR_NONE)
{
return errorstate;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-04 11:00 AM
Pretty sure the method that works most robustly is
Get CID from card
Select w/Relative Address Zero
Get RCA from card
Get CSD from card using RCA as parameter
Select w/RCA
if (BlockCount == 0x200000) Get EXTCSD from card
Depends what "HAL_MMC/SD_GetCardCSD()" does, most implementations just decode the CSD into structure variables, they don't actually call anything, but obviously ST continually shuffles things around
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-04 11:08 AM
Thanks for the info, I'll use that order in my modified driver. The HAL_MMC_GetCardCSD() first decodes the CSD and then midway through actually makes a call to retrieve the extended CSD. It's a bit misleading but at least ST is making progress on the driver.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-03-04 01:18 PM
>>at least ST is making progress on the driver.
I suppose. Not clear to me why they need an SD and MMC fork, I just merged in a handful of changes to the old SDIO drivers.
The speed and bus-width stuff is still a huge mess.
And the shipping FatFs library is broken.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-09 06:13 AM
Safed my day, thanks a lot
