Page 1 of 1

Incorrect OCR sent during SD card init

Posted: Wed Mar 08, 2017 8:29 pm
by rawsock
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)

Re: Incorrect OCR sent during SD card init

Posted: Wed Mar 08, 2017 8:50 pm
by Giovanni
Hi,

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

Giovanni

Re: Incorrect OCR sent during SD card init

Posted: Wed Mar 08, 2017 10:37 pm
by rawsock
I tested on 2 SanDisk cards and 1 noname. All got significant performance boost during write (I did not test read speed).

Re: Incorrect OCR sent during SD card init

Posted: Mon Mar 20, 2017 9:20 am
by alex31
I confirm the performance speedup (F4 and F7, samsung SHDC card)

Alexandre

Re: Incorrect OCR sent during SD card init

Posted: Tue Apr 04, 2017 12:34 pm
by Giovanni
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

Re: Incorrect OCR sent during SD card init

Posted: Fri Apr 07, 2017 10:16 am
by rawsock
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.

Re: Incorrect OCR sent during SD card init

Posted: Sun Apr 09, 2017 7:48 am
by Giovanni
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