adafruit / adafruit/WaveHC

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

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
20
Forks
19
PR merge metrics
No merged PRs in 30d

Description

- 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;
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the size() method and inspect the SDHC card-size calculation shown in the issue. Run the SdReadTest example with a 32GB or larger SD card; done means the reported card size is plausible and the read test no longer fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.