This is the mail archive of the ecos-bugs@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001764] Enhancement of MMC/SD over SPI driver


Please do not reply to this email, use the link below.

http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001764

--- Comment #13 from Mike Jones <mjones@linear.com> ---
I had new troubles with an SD Card so I spent some debug time.

My hardware is a standard K60 Tower with 2GB SD Card from SanDisk. The SPI is
rewired so the lines are connected properly.

The card cannot be recognized, on hardware that has worked before, with a card
that has worked before using this patch. The differences now are up to date
code base with FX patches, I2C, etc. Everything seems to work but this.

So I put my Beagle on the bus so I can see what is going on. So the details are
as follows.

- First, the clocking to clear the bus occurs.
- Second, there is an init command 40 00 00 00 95 which responds with an 01
- Third, there is a command to do a voltage check:
    48 00 00 01 AA 87

This means CMD8, voltage 01 (2.7V - 3.3V), test pattern AA

The card returns:

    01 00 00 01 AA FF

This means it echo's back the proper values. This is an R7 response.

In the spec https://www.sdcard.org/downloads/pls/simplified_specs/part1_410.pdf

On page 82 of the spec it describes this R7 response, and the 01 should be at
bit 16, pattern at bits 8:15 followed by crc and end bit.

Based on table 4-39 this seems malformed. I don't see the CMD8 at bits 40:45.
What is there is a 01. CRC also seems wrong unless FF is the real calculated
value. I have not tried to compute it.

The 01 and AA seem to be in the correct location.

Now in the code in mmc_spi.c:

  cyg_spi_transaction_transfer(dev, cyg_mmc_spi_polled,
      R7_RESPONSE_LENGTH, mmc_spi_ff_data, response, 0);
  DEBUG2("%s(): R7: %02x %02x %02x %02x %02x.\n", __FUNCTION__,
      response[0], response[1], response[2], response[3], response[4]);
  if (0 == (MMC_SPI_VHS & response[2])) {
    DEBUG1("%s(): card doesn't accept voltage %02x\n", __FUNCTION__,
MMC_SPI_VHS);
    mmc_spi_end_command(disk);
    return -ENOTSUP;
  }

It turns out the 01 is in response[3] and AA is in response[4]. If the transfer
with R7_RESPONSE_LENGTH does not include CRC, this positioning makes sense.
However, response[0] is 0. So it does not match the Beagle.

The code then returns an error because it is verifying the voltage with
response[2] rather than response[3].

So I then thought, well, let's change to response[3] and see if it works.

Now the code proceeds and sends command:

    77 00 00 00 00 00

This is 0x37 or CMD55, which is used because the code thinks this is a version
2 card. I have a SD card, so I think it is version 1, but I am new at this. The
code says it is V2 because it understands CMD8. So I guess it is V2.

Anyway, the code thinks the CMD55 App Command is ok and proceeds and sends
    69 40 00 00 00 FF

This is a 0x29 or CMD41, which is an initialization command. 40 means SDHC or
SDXC supported. However, this is an SD card. So perhaps the CMD8 should have
failed so that this would be a V1 card. Except, the CMD8 check for V1 occurs
before the voltage check and the code believes it worked.

  if (MMC_REPLY_ILLEGAL_COMMAND & reply) { // V1 cards do not understand CMD8
    disk->sd_version = 1;
    disk->sd_capacity = STANDARD_CAPACITY;
    mmc_spi_end_command(disk);
    return ENOERR;
  }

This code does not detect an illegal command. And the Beagle produced a reply.

Back to things, the code proceeds to:

    if ( 1 == disk->sd_csd_version) {
      // There is information available about the file format, e.g.
      // partitioned vs. simple FAT. With the current version of the
      // generic disk code this needs to be known statically, via
      // the mbr field of the disk channel structure. If the card
      // is inappropriately formatted, reject the mount request.
      if ((0 != MMC_CSD_REGISTER_FILE_FORMAT_GROUP(&csd)) ||
          (0 != MMC_CSD_REGISTER_FILE_FORMAT(&csd))) {
          return -ENOTDIR;
      }
    } // Accord

and we fail the mount request.

So I reformat the drive...

And the result is the same.

Now that I have a setup, perhaps I can take a look my working microSD stuff
which is on a custom board and look at a card that works and the failing
Samsung card, etc. I also have an SDHC card I can check on this Tower hardware.
All for now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]