sd_drive: refuse a card that never answered instead of serving no blocks - #51
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last section of #4:
examples/sd_drive.pyreadcard.ioctl(4, 0)straight into its block count. An empty slot or a card that times out answers -1 rather than raising, so the example printed a negative size, attached a drive of no blocks, and sat in its loop saying nothing. That's how #4 was first mistaken for a broken example.card_geometry()now refuses a non-positive or non-integer block count or size with aRuntimeErrorthat says to check the slot and reset the board, before anything is attached.tests/test_sd_drive_example.pyruns the example'smain()against a fake card and device. Against the old example it fails three subtests and errors on the fourth (-1/-1, 0 blocks, -1 block size,None). With the fix all pass, and the control, a healthy 62,685,184 x 512 card, still attaches both ways. Full suite: 186 tests OK (22 skipped). The example also compiles on MicroPython 1.29.Not run on a board. #4 stays open for the part that needs a card in the P4's slot.
Refs #4