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
SDIO port to STM32F4x
Re: SDIO port to STM32F4x
Hi Giovanni,
You changed retval names in sdc.c, but they are not in-line with descriptions
They should look like this:
instead of actual:
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.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: SDIO port to STM32F4x
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
@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
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...
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: SDIO port to STM32F4x
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
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
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...
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: SDIO port to STM32F4x
I am not disagreeing but then I prefer to create an explicit error type, it makes things entirely unambiguous.
Giovanni
Giovanni
Re: SDIO port to STM32F4x
part1zan_ wrote:Will SDIO work at STM32F3Discovery?
The STM32F303 does not provide an SDIO interface.
~ Tectu
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times