2010-05-18 22:45:53     driver of SD/SDHC on BF561

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-05-18 22:45:53     driver of SD/SDHC on BF561

chaotian jing (AFGHANISTAN)

Message: 89518   

 

Hi,

 

On my BF561 board, the 4G SDHC is working well, but the 1G SD card cannot work.

 

I was troubled that the 512M mini SD card and 2G mini SD card can work well,but only 1G mini SD card.

 

The kernel version is 2.6.22.19

 

the driver code about it is in /linux-2.6.x/drivers/mmc$

 

Now attch some problem I missed while mount and format the SD card.

 

root:~> mount /dev/mmc /mnt/

mmc_spi spi1.6: INVALID RESPONSE, fe; CMD17

mmcblk0: error 4 sending read/write command(CMD17)

end_request: I/O error, dev mmcblk0, sector 0

FAT: unable to read boot sector

mmcblk0: error 2 sending read/write command(CMD17)

end_request: I/O error, dev mmcblk0, sector 0

FAT: unable to read boot sector

yaffs: dev is 37748736 name is "mmcblk0"

yaffs: Attempting MTD mount on 36.0, "mmcblk0"

yaffs: dev is 37748736 name is "mmcblk0"

yaffs: Attempting MTD mount on 36.0, "mmcblk0"

mount: mounting /dev/mmc on /mnt/ failed

 

 

root:~> mkfs.vfat  /dev/mmc

mkfs.vfat 2.11 (12 Mar 2005)

mmcblk0: error 2 sending read/write command(CMD18)

end_request: I/O error, dev mmcblk0, sector 0

mkfs.vfat: failed whilst writing reserved sector

 

Has anybody miss this problem before?

 

 

 

the initialize code in /linux-2.6.x/drivers/mmc/mmc_spi.c

 

 

 

/* reset ... with cmd->opcode == MMC_GO_IDLE_STATE */

    static int

mmc_spi_initialize(struct mmc_spi_host *host, struct mmc_request *mrq)

{

    struct mmc_command    *cmd = mrq->cmd;

    int            could_invert_cs = 0;

    int            status;

    host->cid_sequence = 0;

    int i;

    /* REVISIT put a powercycle reset here?  */

    mmc_spi_dummy_clocks(13);

    could_invert_cs = 1;

 

    /* try to be very sure any previous command has completed;

     * wait till not-busy, skip debris from any old commands,

     */

    (void) mmc_spi_scanbyte(host, mmc_spi_busy, WRITE_TIMEOUT);

    (void) mmc_spi_readbytes(host, host->command.buf,

        sizeof host->command.buf);

 

    /*

     * Do a burst with chipselect deactivated.  We need to do this

     * to meet the requirement of 74 clock cycles with chipselect

     * high before CMD0.  (Section 6.4.1, in "Simplified Physical

     * Layer Specification 2.0".)  Some cards are particularly

     * needy of this (e.g. Viking "SD256") while most others don't

     * seem to care.  Note that it's not enough to deactivate

     * chipselect without toggling the clock.  Beware of the hack:

     * we "know" that mmc_spi_readbytes uses the host->status

     * spi_transfer.

     */

 

    host->command.command.dummy = 0xff;    // XXX:

 

    /* issue software reset */

    cmd->arg = 0;

    status = mmc_spi_command_send(host, mrq, CRC_GO_IDLE_STATE, cmd);

    if (status < 0) {

    printk("@@@@ status:%ld\n", status);

    //while (status < 0) {//jing change 05.13

    /* maybe:

     *  - there's no card present

     *  - the card isn't seated correctly (bad contacts)

     *  - it didn't leave MMC/SD mode

     *  - there's other confusion in the card state

     *

     * power cycling the card ought to help a lot.

     * At any rate, let's try again.

     */

    //printk("########## Cannot initialize!\n");//jing add 05.13

    mdelay(100);//jing add 05.18

    status = mmc_spi_command_send(host,

        mrq, CRC_GO_IDLE_STATE, cmd);

    if (status < 0)

        dev_err(&host->spi->dev,

            " \n%s",

            !could_invert_cs

            ? ("\tor the active chip-select"

            " level can't be inverted\n") : "");

    //printk("########## Cannot initialize!\n");//jing add 05.13

    }

    //printk("&&&&&&&&&&&& status:%d\n", status);

    return status;

}

 

 

 

I think the initialize function may not prefect. because the "can't initialize the card - no card?" is printed only

 

in the case that the card is 1G mini SD .

 

              has someone has some clue about it?

QuoteReplyEditDelete

 

 

2010-05-18 22:47:29     Re: driver of SD/SDHC on BF561

chaotian jing (AFGHANISTAN)

Message: 89519   

 

Now the mmc_spi.c is attched.

 

mmc_spi-old.c

QuoteReplyEditDelete

 

 

2010-05-19 00:32:44     Re: driver of SD/SDHC on BF561

Mike Frysinger (UNITED STATES)

Message: 89520   

 

2.6.22.x is old.  upgrade to the latest release which has many mmc/spi fixes.

QuoteReplyEditDelete

 

 

2010-05-19 01:46:03     Re: driver of SD/SDHC on BF561

chaotian jing (AFGHANISTAN)

Message: 89524   

 

2.6.22.x is old.  upgrade to the latest release which has many mmc/spi fixes.

 

---

 

Ignore the release version,Is the 1G mini SD card is special??

QuoteReplyEditDelete

 

 

2010-05-19 03:40:29     Re: driver of SD/SDHC on BF561

Wolfgang Muees (GERMANY)

Message: 89534   

 

No, a 1GB miniSD card is nothing special.

 

But: this *particular* 1GB miniSD card is special. *Many* SD cards have design flaws in the SD card controller working in SPI mode.

 

A few months ago, the mmc_spi driver got a big rework, so that this driver can handle the most common design flaws of SD cards in SPI mode.

 

So you *schould* upgrade your kernel. The new code is much more better, and the old code will _not_ work with about 50% of all manufactured SD cards.

 

regards

 

Wolfgang

TranslateQuoteReplyEditDelete

 

 

2010-05-19 21:36:22     Re: driver of SD/SDHC on BF561

chaotian jing (AFGHANISTAN)

Message: 89564   

 

No, a 1GB miniSD card is nothing special.

 

But: this *particular* 1GB miniSD card is special. *Many* SD cards have design flaws in the SD card controller working in SPI mode.

 

A few months ago, the mmc_spi driver got a big rework, so that this driver can handle the most common design flaws of SD cards in SPI mode.

 

So you *schould* upgrade your kernel. The new code is much more better, and the old code will _not_ work with about 50% of all manufactured SD cards.

 

regards

 

Wolfgang

 

---

 

I don't understand that the 1G mimi SD card can work well with another driver(but 4G SDHC cannot work with it). all the replyer advise me update the release,but in my company,other drivers all run on 2.6.22. So, I must work out it on this kernel version.

 

May be the problem is Sequence in time, But I cannot find it(because all other sd card work well).

QuoteReplyEditDelete

 

 

2010-05-20 10:12:24     Re: driver of SD/SDHC on BF561

Robin Getz (UNITED STATES)

Message: 89594   

 

Chaotian:

 

You asked for help - we told you what to do (upgrade) - you refused - that's all we can do.

 

You may want to upgrade just to see if that makes the problem go away - if it doesn't - then knowing that helps, and we can look into things. If it does - you can backport the changes to your old release.

 

-Robin

QuoteReplyEditDelete

 

 

2010-05-21 05:16:20     Re: driver of SD/SDHC on BF561

Wolfgang Muees (GERMANY)

Message: 89633   

 

but in my company,other drivers all run on 2.6.22.

 

We are using about 20 self-written kernel drivers in our products.

 

The porting of these drivers to a new kernel release is not difficult. If you want to continue to benefit from the open source community, you have to pay the price: port your driver to new kernel releases to cope with the ongoing development.

 

If you don't understand this and become lazy, you will suffer.

 

regards

 

Wolfgang

Attachments

    Outcomes