2025-11-10 2:35 PM - edited 2025-11-10 2:36 PM
Hi there! Not entirely sure if I'm missing anything here: I've been running issue when usign FatFs library with SDMMC1 on a STM32H755ZI due to the MBR sector readback been partially incorrect. Specifically during check_fs() where we check location where the ASCII for "FAT32" is store in the MBR sector (first 512bytes). The card can be verified to function correctly using HxD tool on Windows:
However, through SDIO on the STM32 platform, I was getting different result for the byte [82:86], as the location is completely cleared. byte[32:24] seems to be offset to a completely different location instead:
Here is the code snippet where I used HAL library to grab the first (block) 512bytes:
const uint32_t BlockAdd = 0;
const uint32_t NumberOfBlocks = 1;
HAL_StatusTypeDef status = HAL_SD_ReadBlocks(
hsd,
(uint8_t*)pData,
BlockAdd,
NumberOfBlocks,
Timeout
);
if (status == HAL_OK)
{
if (HAL_SD_GetCardState(hsd) != HAL_SD_CARD_TRANSFER)
{
return HAL_ERROR;
}
}If anyone have any pointers as to why I'm seeing this behavior that would be amazing. Curiously the 0xAA55 endmark can be read back correctly.
I'm using an 8GB Sandisk HS microsd card for testing, same behavior can be observed with a 64GB UHS Samsung microsd card as well.
2025-11-10 3:34 PM
The latter is an MBR, the Partition Table, this will typically live at Block 0, the former is the BPB for a FAT Volume