Add data response token validation in SD/MMC write operations #6
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
drive_write_block()function was not validating the data response token that SD/MMC cards send after receiving data in SPI mode. Per SD specification section 7.3.3.1, this token indicates whether data was accepted or rejected due to CRC/write errors. Without validation, write failures go undetected, causing silent data corruption.Changes
Added constants for response token validation:
DATA_RESPONSE_MASK(0x1F): Extracts bits [4:0] from response byteDATA_RESPONSE_ACCEPTED(0x05): Expected value for successful writes (format:xxx00101)Modified
drive_write_block()to read and validate the response token immediately after CRC16 transmission, before waiting for card busy state:The token format is
xxx0sss1where bits [3:1] encode status:010= accepted,101= CRC error,110= write error.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https /usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.