SDIO failing at block length message of sdcConnect

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jmarple
Posts: 2
Joined: Sat Mar 26, 2016 6:44 pm

SDIO failing at block length message of sdcConnect

Post by jmarple »

Hello all,

I've hit a wall trying to get SDIO to work on a stm32f4 discovery board. When I run sdcConnect, the program gets to this line before failing everytime in sdc.c:

Code: Select all

  /* Block length fixed at 512 bytes.*/
  if (sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_SET_BLOCKLEN,
                                 MMCSD_BLOCK_SIZE, resp) ||
      MMCSD_R1_ERROR(resp[0])) {
    goto failed;
  }


My main.c looks like this:

Code: Select all

int main(void) {

  halInit();
  chSysInit();

  uartStart(&UARTD2, &uartcfg);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  sdcStart(&SDCD1, &sdccfg);

  printMsg("Connecting...\n", 14);

  if (sdcConnect(&SDCD1)) 
    printMsg("Failed!!!\n", 10); 
  else 
    printMsg("Good!\n", 6);
 

  while (true) {
    chThdSleepMilliseconds(1000);
  }
}


The card is a 16gb PNY sd card formatted as fat32. I'm pretty sure I have the board.h set up correctly. I'm using 10cm wires from the discovery board to the card and pull-up resistors on the 4 data lines and cmd line. Any insight to why this particular section of sdcConnect is failing? I attached the code if that helps. Thanks in advance.
Attachments
SDIO.tar.gz
Code.
(3.27 MiB) Downloaded 205 times
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO failing at block length message of sdcConnect

Post by Giovanni »

Hi,

Does it fail with any card or just that particular card? if it fails for any card then it is likely a setup problem, wires, I/O, etc

Giovanni
jmarple
Posts: 2
Joined: Sat Mar 26, 2016 6:44 pm

Re: SDIO failing at block length message of sdcConnect

Post by jmarple »

I got my hands on a different SD card (SanDisk 16gb class 4) and to my surprise it worked. I tired shortening the wires so that they are only ~2-3cm long now but the old card still doesn't work and gets stuck in that same section of code. A bit disheartening but atleast I can start testing code for now.

Do you have any ideas for why one SD card would work over another?

Thanks for your help.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO failing at block length message of sdcConnect

Post by Giovanni »

Hi,

No idea, I would need one of those cards to find out. A test that I would do is to try to use one board with a built-in connector in order to rule out HW problems.

There could also be a driver bug triggered by that particular card anwer.

Giovanni
Post Reply