Alan Carvalho de Assis acassis@gmail.com [nuttx]
2016-12-14 18:24:31 UTC
Greg,
According with this CSD decoder:
http://goughlui.com/static/csdecode2.htm the csize should be 0x0073a7
instead of 0x005b59 see:
Decoded Result:
CSD Structure: describes version of CSD structure
0b01 [Interpreted: Version 2.0 SDHC]
Data Read Access Time 1: defines Asynchronous part of the read access time
0x0e [Interpreted: 1.0 x 1ms]
Data Read Access Time 2: worst case clock dependent factor for data access time
0x00 [Decimal: 0 x 100 Clocks]
Max Data Transfer Rate: sometimes stated as Mhz
0x32 [Interpreted: 2.5 x 10Mbit/s]
Card Command Classes:
0x5b5 [Interpreted: Class 0: Yes. Class 1: No. Class 2: Yes. Class 3:
No. Class 4: Yes. Class 5: Yes. Class 6: No. Class 7: Yes. Class 8:
Yes. Class 9: No. Class 10: Yes. Class 11: No. ]
Max Read Data Block Length:
0x9 [Interpreted: 512 Bytes]
Partial Blocks for Read Allowed:
0b0 [Interpreted: No]
Write Block Misalignment:
0b0 [Interpreted: No]
Read Block Misalignment:
0b0 [Interpreted: No]
DSR Implemented: indicates configurable driver stage integrated on card
0b0 [Interpreted: No]
Device Size: to calculate the card capacity excl. security area
((device size + 1)* 512kbytes
0x0073a7 [Decimal: 29607]
Erase Single Block Enabled:
0x1 [Interpreted: Yes]
Erase Sector Size: size of erasable sector in write blocks
0x7f [Interpreted: 128 blocks]
Write Protect Group Size:
0x7f [Interpreted: 128 sectors]
Write Protect Group Enable:
0x0 [Interpreted: No]
Write Speed Factor: block program time as multiple of read access time
0x2 [Interpreted: x4]
Max Write Data Block Length:
0x9 [Interpreted: 512 Bytes]
Partial Blocks for Write Allowed:
0x0 [Interpreted: No]
File Format Group:
0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT
without Partition Table/Universal File Format/Other/Unknown]
Copy Flag:
0b0 [Interpreted: Original]
Permanent Write Protection:
0b0 [Interpreted: No]
Temporary Write Protection:
0b0 [Interpreted: No]
File Format:
0x0 [Interpreted: Hard Disk with Partition Table]
CRC7 Checksum + always 1 in LSB:0x01
(29607+1) * 512KB = 15523119104 => 15523119104 / 1024 = 15159296 KB
This is exactly the value reported by Linux.
I think it should consider the bit 0 as the MSB:
40 0e 00 32 5b 59 000073a7 7f 80 0a 40 00 01
Do you agree?
BR,
Alan
According with this CSD decoder:
http://goughlui.com/static/csdecode2.htm the csize should be 0x0073a7
instead of 0x005b59 see:
Decoded Result:
CSD Structure: describes version of CSD structure
0b01 [Interpreted: Version 2.0 SDHC]
Data Read Access Time 1: defines Asynchronous part of the read access time
0x0e [Interpreted: 1.0 x 1ms]
Data Read Access Time 2: worst case clock dependent factor for data access time
0x00 [Decimal: 0 x 100 Clocks]
Max Data Transfer Rate: sometimes stated as Mhz
0x32 [Interpreted: 2.5 x 10Mbit/s]
Card Command Classes:
0x5b5 [Interpreted: Class 0: Yes. Class 1: No. Class 2: Yes. Class 3:
No. Class 4: Yes. Class 5: Yes. Class 6: No. Class 7: Yes. Class 8:
Yes. Class 9: No. Class 10: Yes. Class 11: No. ]
Max Read Data Block Length:
0x9 [Interpreted: 512 Bytes]
Partial Blocks for Read Allowed:
0b0 [Interpreted: No]
Write Block Misalignment:
0b0 [Interpreted: No]
Read Block Misalignment:
0b0 [Interpreted: No]
DSR Implemented: indicates configurable driver stage integrated on card
0b0 [Interpreted: No]
Device Size: to calculate the card capacity excl. security area
((device size + 1)* 512kbytes
0x0073a7 [Decimal: 29607]
Erase Single Block Enabled:
0x1 [Interpreted: Yes]
Erase Sector Size: size of erasable sector in write blocks
0x7f [Interpreted: 128 blocks]
Write Protect Group Size:
0x7f [Interpreted: 128 sectors]
Write Protect Group Enable:
0x0 [Interpreted: No]
Write Speed Factor: block program time as multiple of read access time
0x2 [Interpreted: x4]
Max Write Data Block Length:
0x9 [Interpreted: 512 Bytes]
Partial Blocks for Write Allowed:
0x0 [Interpreted: No]
File Format Group:
0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT
without Partition Table/Universal File Format/Other/Unknown]
Copy Flag:
0b0 [Interpreted: Original]
Permanent Write Protection:
0b0 [Interpreted: No]
Temporary Write Protection:
0b0 [Interpreted: No]
File Format:
0x0 [Interpreted: Hard Disk with Partition Table]
CRC7 Checksum + always 1 in LSB:0x01
(29607+1) * 512KB = 15523119104 => 15523119104 / 1024 = 15159296 KB
This is exactly the value reported by Linux.
I think it should consider the bit 0 as the MSB:
40 0e 00 32 5b 59 000073a7 7f 80 0a 40 00 01
Do you agree?
BR,
Alan
Hi Greg,
I'm trying to use a 16GB SD Card with the driver I'm writing, but I
noted that the default way to get the card size is not working for my
SDCard.
lpc43_recvlong: Entry!
lpc43_recvlong: rlong[0] = 0a4000eb
lpc43_recvlong: rlong[1] = 73a77f80
lpc43_recvlong: rlong[2] = 5b590000
lpc43_recvlong: rlong[3] = 400e0032
mmcsd_decodeCSD: CSD_STRUCTURE: 0 SPEC_VERS: 2 (MMC)
mmcsd_decodeCSD: TAAC {TIME_UNIT: 0 TIME_VALUE: 8} NSAC: 0
mmcsd_decodeCSD: TRAN_SPEED {TRANSFER_RATE_UNIT: 3 TIME_VALUE: 13}
mmcsd_decodeCSD: CCC: 1850
mmcsd_decodeCSD: READ_BL_LEN: 7 READ_BL_PARTIAL: 0
mmcsd_decodeCSD: WRITE_BLK_MISALIGN: 1 READ_BLK_MISALIGN: 1
mmcsd_decodeCSD: DSR_IMP: 1
mmcsd_decodeCSD: C_SIZE: 23385 SD_ER_BLK_EN: 0
mmcsd_decodeCSD: SD_SECTOR_SIZE: 0 SD_WP_GRP_SIZE: 0
mmcsd_decodeCSD: WP_GRP_EN: 0 MMC DFLT_ECC: 2 (MMC) R2W_FACTOR: 0
mmcsd_decodeCSD: WRITE_BL_LEN: 0 WRITE_BL_PARTIAL: 0
mmcsd_decodeCSD: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decodeCSD: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decodeCSD: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 25
23947264 wrprotect: 0
(96:127)
rlong[0] = 0a400001
(64:95)
rlong[1] = 73a77f80
(32:63)
rlong[2] = 5b590000
(0:31)
rlong[3] = 400e0032
uint32_t csize = ((csd[1] & 0x3f) << 16) | (csd[2] >> 16);
priv->capacity = ((uint64_t)(csize + 1)) << 19;
csize = 0x5b59 = 23385
Calculating: (23385 + 1) * 512KB = 12260999168 => 12260999168 / 1024 =
11973632 KB !
Then I compared this CSD with the CSD returned by Linux for this card
$ cat /sys/class/mmc_host/mmc0/mmc0\:0007/csd
400e00325b59000073a77f800a400001
$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14,5 GiB, 15523119104 bytes, 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 30318591 30310400 14,5G c W95 FAT32 (LBA)
I think Linux is using some other way to detect the card size.
What do you think?
BR,
Alan
I'm trying to use a 16GB SD Card with the driver I'm writing, but I
noted that the default way to get the card size is not working for my
SDCard.
lpc43_recvlong: Entry!
lpc43_recvlong: rlong[0] = 0a4000eb
lpc43_recvlong: rlong[1] = 73a77f80
lpc43_recvlong: rlong[2] = 5b590000
lpc43_recvlong: rlong[3] = 400e0032
mmcsd_decodeCSD: CSD_STRUCTURE: 0 SPEC_VERS: 2 (MMC)
mmcsd_decodeCSD: TAAC {TIME_UNIT: 0 TIME_VALUE: 8} NSAC: 0
mmcsd_decodeCSD: TRAN_SPEED {TRANSFER_RATE_UNIT: 3 TIME_VALUE: 13}
mmcsd_decodeCSD: CCC: 1850
mmcsd_decodeCSD: READ_BL_LEN: 7 READ_BL_PARTIAL: 0
mmcsd_decodeCSD: WRITE_BLK_MISALIGN: 1 READ_BLK_MISALIGN: 1
mmcsd_decodeCSD: DSR_IMP: 1
mmcsd_decodeCSD: C_SIZE: 23385 SD_ER_BLK_EN: 0
mmcsd_decodeCSD: SD_SECTOR_SIZE: 0 SD_WP_GRP_SIZE: 0
mmcsd_decodeCSD: WP_GRP_EN: 0 MMC DFLT_ECC: 2 (MMC) R2W_FACTOR: 0
mmcsd_decodeCSD: WRITE_BL_LEN: 0 WRITE_BL_PARTIAL: 0
mmcsd_decodeCSD: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decodeCSD: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decodeCSD: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 25
23947264 wrprotect: 0
(96:127)
rlong[0] = 0a400001
(64:95)
rlong[1] = 73a77f80
(32:63)
rlong[2] = 5b590000
(0:31)
rlong[3] = 400e0032
uint32_t csize = ((csd[1] & 0x3f) << 16) | (csd[2] >> 16);
priv->capacity = ((uint64_t)(csize + 1)) << 19;
csize = 0x5b59 = 23385
Calculating: (23385 + 1) * 512KB = 12260999168 => 12260999168 / 1024 =
11973632 KB !
Then I compared this CSD with the CSD returned by Linux for this card
$ cat /sys/class/mmc_host/mmc0/mmc0\:0007/csd
400e00325b59000073a77f800a400001
$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14,5 GiB, 15523119104 bytes, 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 30318591 30310400 14,5G c W95 FAT32 (LBA)
I think Linux is using some other way to detect the card size.
What do you think?
BR,
Alan