Page 8 of 8

Re: SDIO port to STM32F4x

Posted: Wed Apr 25, 2012 8:42 pm
by efs113
Hi All,

I spent some time debugging the 1.1 detection bug I reported previously. Not sure exactly what is happening, but do have some information that someone more knowledgeable with the SD protocol may be able to make some sense of.

First, I tried a 2.0 card, it worked fine.

So, I went back to the 1.1 card and added some debug. Code referenced below is in the sdcConnect() function in os/hal/src/sdc.c, rev4032, branches/sdc_dev2. The card IS being detected as a 1.1 card (if on 230, SDC_CM8_PATTERN, returns failure and sdcp->cardmode is set to SDC_MODE_CARDTYPE_SDV11 on line 248). The problem occurs at the next sdc_lld_send_cmd_short_crc(), line 271, when SDC_CMD_APP_CMD is sent. sdc_lld_send_cmd_short_crc() succeeds, but the resp code is flagged as an error by the SDC_R1_ERROR(resp[0]) part of the if condition. resp[0] contains 0x00400120. resp[0], when masked with SDC_R1_ERROR_MASK, becomes 0x00400000. This causes SDC_R1_ERROR(resp[0]) to return true resulting in the 'goto failed' on line 273.

I dug through the SD card documentation (not very thoroughly though) and couldn't find what that bit might represent. The documentation I was looking at stated SDC_CMD_APP_CMD response should only be 8 bits long. Anyone have any idea what the bit represents? Where did SDC_R1_ERROR_MASK come from and what do its bits represent?

So, I decided to ignore the error. I commented out the 'goto failed' on line 273 after the failing command. Reran the haltest and it PASSED successfully several times.

Could this possibly be a false error?

Eric

Re: SDIO port to STM32F4x

Posted: Tue May 08, 2012 8:52 am
by Jacon
Hi Giovanni,

You changed retval names in sdc.c, but they are not in-line with descriptions ;)

They should look like this:

Code: Select all

 * @retval CH_FAILED    operation failed..
 * @retval CH_SUCCESS   operation succeeded.

instead of actual:

Code: Select all

 * @retval CH_FAILED    operation succeeded.
 * @retval CH_SUCCESS   operation failed.

Re: SDIO port to STM32F4x

Posted: Tue May 08, 2012 8:56 am
by Giovanni
Thanks, I will fix those.

@Eric, I hoped barthess would know more about that, I will study a bit that problem when I will rework the SDC driver.

BTW, I am working to add a generic "block" interface to both the SDC and MMC_SPI drivers, much like the streams for serial devices, this way any block device can be accessed in the same way.

Giovanni

Re: SDIO port to STM32F4x

Posted: Thu May 10, 2012 10:22 am
by Jacon
Giovanni wrote:Thanks, I will fix those.
Giovanni

Still not fixed... ;)

Similar problem in newly added files / file sections:
- io-block.h - you used old retval names, instead of new ones;
- mmc-spi.c - same problem;
- sdc.c - same problem - mixture of both systems in one file now;

It's good time to replace them globally in all files, I think...

Re: SDIO port to STM32F4x

Posted: Thu May 10, 2012 10:52 am
by Giovanni
Frankly I am scared to change that in all files, probably it is better to leave TRUE/FALSE in the code and just document CH_FAILED/CH_SUCCESS as aliases. If we have to go through the pain probably it would be better to drop the bool_t and define a proper error type (maybe cherr_t) as an enumeration.

BTW, I am still working on both SDC and MMC_SPI, expect a new commit in the evening. I am trying to make the two drivers share code and definitions.

Giovanni

Re: SDIO port to STM32F4x

Posted: Thu May 10, 2012 11:14 am
by Jacon
Giovanni wrote:... probably it is better to leave TRUE/FALSE in the code and just document CH_FAILED/CH_SUCCESS as aliases. ...

In my opinion - no. It's one of the hardest confusion sources in whole code,
especially for newcomers.

But - you're the Boss here...

Re: SDIO port to STM32F4x

Posted: Thu May 10, 2012 12:27 pm
by Giovanni
I am not disagreeing but then I prefer to create an explicit error type, it makes things entirely unambiguous.

Giovanni

Re: SDIO port to STM32F4x

Posted: Sun Nov 03, 2013 4:55 pm
by part1zan_
Will SDIO work at STM32F3Discovery?

Re: SDIO port to STM32F4x

Posted: Sun Nov 03, 2013 6:07 pm
by Tectu
part1zan_ wrote:Will SDIO work at STM32F3Discovery?

The STM32F303 does not provide an SDIO interface.


~ Tectu

Re: SDIO port to STM32F4x

Posted: Sun Nov 03, 2013 6:17 pm
by Giovanni
No, the STM32F3 does not have the SDIO peripheral.

giovanni