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

SG2044Pkg/SdCard: Fix write fails and read timeout #153

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

g11023225
Copy link

Fix the bug causing write operation failures and occasional read operation timeouts.
The modifications in the current commit are based on the following reasons:

  1. All writable fields in NORMAL_INT_STAT_R(0x30) are W1C. Clearing a specific interrupt must not affect other fields.
  2. Set CMD_TYPE to 0x3 when issuing Abort CMD (CMD12).
  3. Poll PSTATE_REG.CMD_INHIBIT_DAT before sending ADTC commands to ensure it is 0 (0 for ready).
  4. ACMD22 is an ADTC command with 4-byte data transfer. Configure blocksize and blockcount registers before sending it.
  5. Update the command-sending code to support ACMD22.
  6. Poll BUF_RD_ENABLE and BUF_WR_ENABLE in PSTATE_REG(0x24) to determine when data registers are accessible.
  7. Set read and write timeouts to 100ms and 250ms, respectively.
  8. Add Readme.md to guide SD card read/write stress testing.

Signed-off-by: zhouwei.zhang [email protected]

Fix the bug causing write operation failures and occasional read operation timeouts.
The modifications in the current commit are based on the following reasons:
  1. All writable fields in NORMAL_INT_STAT_R(0x30) are W1C. Clearing a specific interrupt must not affect other fields.
  2. Set CMD_TYPE to 0x3 when issuing Abort CMD (CMD12).
  3. Poll PSTATE_REG.CMD_INHIBIT_DAT before sending ADTC commands to ensure it is 0 (0 for ready).
  4. ACMD22 is an ADTC command with 4-byte data transfer. Configure blocksize and blockcount registers before sending it.
  5. Update the command-sending code to support ACMD22.
  6. Poll BUF_RD_ENABLE and BUF_WR_ENABLE in PSTATE_REG(0x24) to determine when data registers are accessible.
  7. Set read and write timeouts to 100ms and 250ms, respectively.
  8. Add Readme.md to guide SD card read/write stress testing.

Signed-off-by: zhouwei.zhang <[email protected]>
@jingyu-li98 jingyu-li98 merged commit ad6708e into sophgo:devel-sg2044 Feb 28, 2025
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.

2 participants