From 0d48820ed6401fe7ec3fba22044ceef3e1e797bd Mon Sep 17 00:00:00 2001 From: Phil Dennis-Jordan Date: Wed, 28 Aug 2019 15:00:15 +0200 Subject: [PATCH] Fixes location of high card size bits in V2.00 CSD The SD card size is encoded in 22 bits in the V2.00 CSD block. Due to the way bits are numbered in the spec and C bitfields are laid out on little-endian systems, the 6-bit `c_size_high` field must be listed before the `reserved3` dummy field to include the low 6 bits of the byte. This bug only affected cards over 32GiB in size, as the `c_size_high` field is zero on smaller cards anyway. --- src/utility/SdInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/SdInfo.h b/src/utility/SdInfo.h index 6a0e087..6e04bc1 100644 --- a/src/utility/SdInfo.h +++ b/src/utility/SdInfo.h @@ -190,8 +190,8 @@ typedef struct CSDV2 { unsigned write_blk_misalign : 1; unsigned read_bl_partial : 1; // byte 7 - unsigned reserved3 : 2; unsigned c_size_high : 6; + unsigned reserved3 : 2; // byte 8 uint8_t c_size_mid; // byte 9