cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube SDHC capacity bug (solved)

yada2
Associate II
Posted on May 11, 2014 at 17:21

Hello, in stm32f4xx_hal_sd.c line 1554 :

pCardInfo->CardCapacity  = ((pCardInfo->SD_csd.DeviceSize + 1)) * 512 * 1024;should be :

pCardInfo->CardCapacity  = (uint64_t) ((pCardInfo->SD_csd.DeviceSize + 1)) * 512 * 1024;or pCardInfo->CardCapacity (which is uint64_t) is blocked at uint32_t maximum.
4 REPLIES 4
joe
Associate II
Posted on May 11, 2014 at 19:30

Nice catch...Thx

Posted on May 23, 2014 at 15:17

Hi,

You're right, although CardCapacity is a uint64_t, the math on the right side is all done in 32-bit land and thus all capacity bits above 4GB will be lost. The issue is confirmed and will be fixed in the next release of STM32Cube_FW_F4.

With regards.

jasonp4113
Associate II
Posted on June 13, 2014 at 06:13

Hi all

This capacity bug also extends to the ''STORAGE_GetCapacity_xx()'' functions where it enters with a pointer to a uint32_t value instead of uint64_t.

This needs to be changed in a few locations within the HAL source code so that any card > 4GB will be shown (formatted) correctly in windows.
Posted on July 23, 2014 at 15:03

Hi JasonP,

Thanks for the feedback. We’ve noted this as a problem. In the meantime, please continue to report bugs and submit valuable feedback.

With regards.