Incorrect OCR sent during SD card init Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
rawsock
Posts: 5
Joined: Fri Feb 17, 2017 11:26 am
Been thanked: 1 time

Incorrect OCR sent during SD card init  Topic is solved

Postby rawsock » Wed Mar 08, 2017 8:29 pm

In hal_sdc.c, sdc_init, there is an incorrect OCR word sent in ACMD41:

ocr = 0xC0100000U;

while the correct value according to SD card specification is:

ocr = 0x50FF8000U;

That is, busy=0, hc=1, full performance, full voltage range. There are two major results of this change:

- sending empty voltage range is invalid for initialization, as it only queries for a supported voltage range without initializing the card (according to spec, but seems to work on most cards anyway)
- there is 2-4x performance speedup because full performance bit is set (currently it is 0 which means power save)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Incorrect OCR sent during SD card init

Postby Giovanni » Wed Mar 08, 2017 8:50 pm

Hi,

Interesting, have you tested this on multiple cards? I am not the author of that part so I am not very informed.

Giovanni

rawsock
Posts: 5
Joined: Fri Feb 17, 2017 11:26 am
Been thanked: 1 time

Re: Incorrect OCR sent during SD card init

Postby rawsock » Wed Mar 08, 2017 10:37 pm

I tested on 2 SanDisk cards and 1 noname. All got significant performance boost during write (I did not test read speed).

User avatar
alex31
Posts: 379
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 62 times
Contact:

Re: Incorrect OCR sent during SD card init

Postby alex31 » Mon Mar 20, 2017 9:20 am

I confirm the performance speedup (F4 and F7, samsung SHDC card)

Alexandre

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Incorrect OCR sent during SD card init

Postby Giovanni » Tue Apr 04, 2017 12:34 pm

Question, the complete code is:

Code: Select all

  if ((sdcp->cardmode &  SDC_MODE_CARDTYPE_MASK) == SDC_MODE_CARDTYPE_SDV20) {
    ocr = 0xC0100000U;
  }
  else {
    ocr = 0x80100000U;
  }


Is the constant for non-v20 cards correct? my idea is to make both constants configurable, does it make sense?

Giovanni

rawsock
Posts: 5
Joined: Fri Feb 17, 2017 11:26 am
Been thanked: 1 time

Re: Incorrect OCR sent during SD card init

Postby rawsock » Fri Apr 07, 2017 10:16 am

OCR for non-v20 cards needs to be changed as well. Probably only HC bit needs to be off, when compared to v20 OCR, but I did not test it.
The only configurable options that would make sense are power save vs full performance and voltage range.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Incorrect OCR sent during SD card init

Postby Giovanni » Sun Apr 09, 2017 7:48 am

Fixed as bug #826.

I added two configuration options that allow to override the default initialization values. The default for v20 cards is the suggested one.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 4 guests