SDC init crash

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
manuelseeboeck
Posts: 3
Joined: Mon Feb 23, 2015 10:57 am

SDC init crash

Post by manuelseeboeck »

Hello,

I'm trying to connect a sd card via sdio on an STM32F4. During sdcConnect the osalThreadSleep function is called (in sdc_init(..)) and the program crashes unexpectedly (the _unhandled_exception handler is not called, neither the hard fault handler). See attached image.
Below is the snippet of my init function, it is called from within a static thread (stack size is 1024 byte).

Code: Select all

  palSetPadMode(GPIOC, GPIOC_PIN8,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D0
  palSetPadMode(GPIOC, GPIOC_PIN9,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D1
  palSetPadMode(GPIOC, GPIOC_PIN10, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D2
  palSetPadMode(GPIOC, GPIOC_PIN11, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D3
  palSetPadMode(GPIOC, GPIOC_PIN12, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //CLK
  palSetPadMode(GPIOD, GPIOD_PIN2,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //CMD

  palClearPad(GPIOE, GPIOE_PIN3);
  palSetPadMode(GPIOE, GPIOE_PIN3, PAL_MODE_OUTPUT_OPENDRAIN | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_LOWEST); //SD Power Enable

  sdcStart(&SDCD1, NULL);
  sdcConnect(&SDCD1);


Do you have any idea of why this error occours?

regards,
manuel
Attachments
sdc_crash.PNG
sdc_crash.PNG (11.81 KiB) Viewed 5345 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: SDC init crash

Post by Giovanni »

Hi,

Which version? if 3.0 then you must pass a configuration structure to sdcStart(), it is a recent change.

Giovanni
manuelseeboeck
Posts: 3
Joined: Mon Feb 23, 2015 10:57 am

Re: SDC init crash

Post by manuelseeboeck »

Hi,
I added the SDCConfig struct with 512 byte working area as described in the documentation, the programm still crashes at the same point though.

manuel
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDC init crash

Post by Giovanni »

Hi,

We are still doing changes there, I just committed some changes, please monitor the SDC thread in this same forum.

Giovanni
manuelseeboeck
Posts: 3
Joined: Mon Feb 23, 2015 10:57 am

Re: SDC init crash

Post by manuelseeboeck »

OK, thanks for the help.

manuel
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDC init crash

Post by barthess »

Strange error. Not enough information. But I can write some tips:
1) It may be caused by overflow in some different point not necessary in SDC thread.
2) Do not leave bus lines floating. Set pull up for CMD and data lines, pull down for CLK.
3) Insert pause after card power enabling.
4) It is very unlikely but do you have revision A chip? If yes than you need to set STM32_USE_REVISION_A_FIX flag in your mcuconf.h
Post Reply