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

Sdcardio failures #7278

Merged
merged 2 commits into from
Nov 29, 2022
Merged

Sdcardio failures #7278

merged 2 commits into from
Nov 29, 2022

Conversation

jepler
Copy link
Member

@jepler jepler commented Nov 29, 2022

Before this, CircuitPython was unusable on the SAM E54 XPLAINED devkit. After this, I'm able to initialize the following cards successfully:

  • Lexar Platinum II 32GB full-sized SD HC card
  • unbranded 2GB microSD card
  • Kingston 2GB microSD HC card

This is using the built in full sized SD card slot on the devkit.

Before the second change, after any attempt to construct an sdioio.SDCard instance (failed or successful) the pins would remain "in use" and a new instance could not be constructed. Now, an SDCard instance can be deinitialized with deinit() or by reset of the interpreter, and a new instance can be created.

If no card is inserted, it takes a long time to fail to initialize; this is the same as before. sd_mmc_check(0) blocks for a long time, it's not the surrounding 'try 100 times' loop that is the problem, so adding a keyboard interrupt check there is not helpful.

Todo:

  • test on the Grand Central + SDIO breakout combination as originally reported

Closes #7727
Closes #6914

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awaiting your test on a Grand Central, but code looks OK.

The -Os vs -O2 could be the lack of a volatile somewhere. Otherwise I'm thinking it represents some other unitialized value bug.

@jepler
Copy link
Member Author

jepler commented Nov 29, 2022

Also tested with Grand Central M4, SDIO Breakout, and 2GB non-branded card, with the following code:

import board    
import sdioio    
import storage    
    
with sdioio.SDCard(
    clock=board.SDIO_CLOCK,    
    command=board.SDIO_COMMAND,    
    data=board.SDIO_DATA,    
    frequency=25_000_000) as s:
    print(s.count() * 512 / 1000 / 1000)

@jepler
Copy link
Member Author

jepler commented Nov 29, 2022

@dhalbert Switching samd51 to -O2 produces a similar problem on GCM4, USB CDC disconnects, CIRCUITPY not accessible, safe mode not working. I'll file a fresh issue about this, but for now I'd like to just switch SAME51 (which is all of 1 board) to match SAMD51, even if -O2 not working feels like a nasty surprise.

@jepler jepler merged commit 49ac825 into adafruit:main Nov 29, 2022
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

Successfully merging this pull request may close these issues.

SDIO not working for Adafruit Grand Central M4 Express with SDIO breakout board
2 participants