lpcware

Bugreport: SD-Card on LPC18xx, LPC43xx, LPC17xx

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by jschlichting on Wed May 13 02:58:36 MST 2015
SDXC functionality with the LPCOpen drivers and LPC18xx/LPC43xx suffers from a bug in sdmmc_18xx_43xx.c. I found the same bug also in the implementations for LPC17xx, so it's safe to assume NXP has that problem in all implementations of SD-Card Interfaces. Current release of LPCOpen which I am looking at is 2.15 for LPC18xx.
Around line 228 in sdmmc_18xx_43xx.c there is this:
c_size = prv_get_bits(48, 63, (uint32_t *) g_card_info->card_info.csd) + 1;


This should extract size information from the SD-Card CSD register. According to the SD Specifications Part 1 Physical Layer Simplified Specification Version 4.10, on page 122, the C_SIZE information spans not from bit 48 to bit 63. It spans from bit 48 to bit 69. This means, the NXP Lib cuts away the higher bits of the size information. This works fine for SD Cards up to 32 GB, but if you have bigger cards you get an truncated size which leads a host to the assumption that something has to be wrong with the card.

If you change the above line 228 in sdmmc_18xx_43xx.c to the following, bigger SD-Cards do also work fine:

c_size = prv_get_bits(48, 69, (uint32_t *) g_card_info->card_info.csd) + 1; //BUGFIX



Another remark:
Chip_SDMMC_GetDeviceSize()
overflows with Card sizes bigger than 4GB. workaround would be changing the return value to unsigned 64-bit, or only use
Chip_SDMMC_GetDeviceBlocks()
and modify that to not rely on
Chip_SDMMC_GetDeviceSize()


also posted here: electronics.stackexchange

Outcomes