Repository navigation
Commit fdac8dc
Vince Parsons
sdcard: Keep card selected across multi-block transfers.
readblocks() and writeblocks() released chip select after every block of
a CMD18/CMD25 multi-block transfer (readinto() and write() end with
cs(1) and an extra clocked byte), reselecting the card for the next
block. A Lexar 32GB microSDHC card loses bit alignment across that
release: every block after the first is read shifted by 4 bits, so the
data token 0xfe arrives as 0xe0 (ff e0 00 ... for ff fe 00 ...) and
readinto() times out. On a Pico 2 W, 200 of 200 two-block reads failed
at both the default 1.32MHz and 12MHz.
Keep the card selected from the command through to CMD12 or the stop
token, as CircuitPython's sdcardio and adafruit_sdcard drivers do.
readinto() and write() gain a release argument, True by default, so
single-block transfers are unchanged.
With this change, the same 200 two-block reads all succeed and match
single-block reads of the same blocks, at both clock rates, and
multi-block writes read back correctly. A card that worked before
still works.
Signed-off-by: Vince Parsons <micropython@vinceparsons.com>1 parent 4fa59bd commit fdac8dc
2 files changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
219 | 220 | | |
220 | | - | |
| 221 | + | |
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
240 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
| |||
274 | 276 | | |
275 | 277 | | |
276 | 278 | | |
277 | | - | |
278 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
279 | 283 | | |
280 | 284 | | |
281 | 285 | | |
| |||
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
300 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
301 | 307 | | |
302 | | - | |
| 308 | + | |
303 | 309 | | |
304 | 310 | | |
305 | 311 | | |
306 | | - | |
| 312 | + | |
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| |||
0 commit comments