SD card state change from ident to stby

Bug #597641 reported by Rudrajit Sengupta
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Unassigned

Bug Description

My environment
host : Linux PC(2.6.29.4)
Target: ARM-CortexA8
I am not running any OS on the target.

Below is my command line:
../src/arm-softmmu/qemu-system-arm -M FPGA_NOOS -kernel elfImage -nographic -sd sd.img

Problem scenario
1. CMD13 issued immediately after identication phase reports SD card state as "ident" instead of "stby".
2. class 0(basic) commands are reported as "ILLEGAL_COMMAND" after the card is locked.

Observation
1. In function sd_do_command(), the status of *previous* command is reflected only after the call to sd_set_status(sd). The variable "last_status" should contain the updated value of sd->card_status in order to correctly indicate *last command's* card status.
2. A "not" condition is missing in the if statement in the function sd_do_command(), thereby falsely exiting the function for class0 commands issued after card is locked.

Below is the patch file that seems to be taking care of the above two problems.
*** sd-0.12.4.c 2010-06-23 13:56:05.000000000 +0530
--- sd-0.12.4.rudra.c 2010-06-23 14:08:10.000000000 +0530
***************
*** 1265,1278 ****

      sd->card_status &= ~CARD_STATUS_B;
      sd_set_status(sd);

      if (last_status & CARD_IS_LOCKED)
! if (((last_status & APP_CMD) &&
                                   req->cmd == 41) ||
                          (!(last_status & APP_CMD) &&
                           (sd_cmd_class[req->cmd] == 0 ||
                            sd_cmd_class[req->cmd] == 7 ||
! req->cmd == 16 || req->cmd == 55))) {
              sd->card_status |= ILLEGAL_COMMAND;
              fprintf(stderr, "SD: Card is locked\n");
              return 0;
--- 1265,1279 ----

      sd->card_status &= ~CARD_STATUS_B;
      sd_set_status(sd);
+ last_status = sd->card_status;

      if (last_status & CARD_IS_LOCKED)
! if (!(((last_status & APP_CMD) &&
                                   req->cmd == 41) ||
                          (!(last_status & APP_CMD) &&
                           (sd_cmd_class[req->cmd] == 0 ||
                            sd_cmd_class[req->cmd] == 7 ||
! req->cmd == 16 || req->cmd == 55)))) {
              sd->card_status |= ILLEGAL_COMMAND;
              fprintf(stderr, "SD: Card is locked\n");
              return 0;

Revision history for this message
Peter Maydell (pmaydell) wrote :

These two issues should now be fixed in qemu git master by commits 25881d3..3799ce4.

Changed in qemu:
status: New → Fix Committed
Peter Maydell (pmaydell)
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.