Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card size reported incorrectly for SDHC cards causing SdReadTest to fail. #6

Open
ericzundel opened this issue Oct 15, 2022 · 0 comments

Comments

@ericzundel
Copy link

ericzundel commented Oct 15, 2022

  • Arduino board: Arduino Uno

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.0

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

Run the SdReadTest example with a 32GB or larger SdCard

init time: 29

Card type: SDHC

Manufacturer ID: 3
OEM ID: SD
Product: SB32G
Version: 8.0
Serial number: 1159489440
Manufacturing date: 6/2020

card size: 4290192384 (512 byte blocks)
partion,boot,type,start,length
1,0,C,8192,62325760
2,0,0,0,0
3,0,0,0,0
4,0,0,0,0
Read test starting. Please Wait.

Read 291 blocks
mills: 288

Read Failure
lbn: 62422119
nRead: 291/20000
SD error
errorCode: 10
errorData: 8

type any character to start

Note that the card size is improbably large.

The problem is a missing cast in the size() method.

   } else if (csd.v2.csd_ver == 1) {
-    uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16) |
-                      (csd.v2.c_size_mid << 8) | csd.v2.c_size_low;
+    uint32_t c_size = ((uint32_t)csd.v2.c_size_high) << 16 |
+                      ((uint32_t)csd.v2.c_size_mid) << 8 | csd.v2.c_size_low;
     return (c_size + 1) << 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant