SD-Card Insert/Remove Handlers

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: SD-Card Insert/Remove Handlers

Post by Tabulous »

Giovanni wrote:Try inserting a 100mS delay before sdcConnect(), it is possible that card needs more time for power up.

Giovanni


Adding a delay will not help, as the card always works the first time you insert it, but if you then remove it and re-insert it, it does not work. BUT! if you once again remove it and re-insert it, it works again........

So to conclude every 1st, 3rd, 5th 7th etc insert it works, every 2nd, 4th 6th 8th insert it fails. This sequence is very repeatable i.e. 100%
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD-Card Insert/Remove Handlers

Post by Giovanni »

Try to remove in sdc_lld_connect() the failing test and see if the card works afterwards.

Giovanni
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

Re: SD-Card Insert/Remove Handlers

Post by mukululul »

Hi,
I am seeing a simular problem on the Olimex STM32-E407 with the chibios demo.
First I tried a 256MB Scandisk MicroSD (about 5 Years old) and it never works (works ok in the PC). It always fails in
bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp)
in line 534 sdc_lld.c
if ((sta & (SDIO_STA_CTIMEOUT | SDIO_STA_CCRCFAIL)) != 0) {
sdc_lld_collect_errors(sdcp, sta);
return CH_FAILED;


sdcp->errors=0xA

I have another Scandisc SDHC Card with 4GB pretty new which works sometimes. Once it is detected I need to call 3 times "tree" in the shell until I get the directory tree displayed.

Any ideas where the problem is?
To me this sounds like a timing problem, some timeouts might be to thight.

Any help is apprechiated.

Regards
Michael
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD-Card Insert/Remove Handlers

Post by Giovanni »

I continue to get those reports of problems but I am unable to reproduce them.

Could you give a try to the SD test application present in ChibiOS 3.0? it is under ./testhal/STM32F4xx/SDC

Giovanni
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

Re: SD-Card Insert/Remove Handlers

Post by mukululul »

Hi Giovanni,
thank you for the fast reply. Where can I get 3.0?
Thx.
Michael
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD-Card Insert/Remove Handlers

Post by Giovanni »

Hi,

You need to do a subversion checkout, details are here: http://sourceforge.net/p/chibios/svn/HE ... nel_3_dev/

That test application contains a good test/benchmark for SD cards.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: SD-Card Insert/Remove Handlers

Post by alex31 »

I have another Scandisc SDHC Card with 4GB pretty new which works sometimes. Once it is detected I need to call 3 times "tree" in the shell until I get the directory tree displayed.

Any ideas where the problem is?
To me this sounds like a timing problem, some timeouts might be to thight.


I have resolved problems with some cards working and others not working
by raising SDC_READ_TIMEOUT_MS from 5 to 15 in mcuconf.h.


Alexandre
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

Re: SD-Card Insert/Remove Handlers

Post by mukululul »

Hi Giovanni,
I tried the SD Test and the 256MB SD card does not work there either. This Card is a V1.1 SD and I am not sure if the code this really fully supports it right now.
I ordered a V2.0 SD since from my point of view it does not make sense to support this old stuff and I will continue with this. The other card I had yesterday to try I borrowed from my daughter and I cant use it for further tests because I am scared that data is deleted with the tests.

I'll be back ;-)

Regards
Michael
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD-Card Insert/Remove Handlers

Post by Giovanni »

Thanks, let me know, I will find some more cards and give it a try again in the weekend.

Giovanni
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

Re: SD-Card Insert/Remove Handlers

Post by mukululul »

Hi Giovanni,
today I tried a cheap card I bought in the supermarket. The test dies in err = f_stat("0:chtest.txt", &filinfo);
with a hardfault. I could not find out yet why, once I leave the func get_fileinfo() in ff.c Line 1908 I am in the hardfault handler.
I modified the main a little bit so I can use USB as a serial connection. Not sure if this can cause the problem.
I also had to remove the costum makefile but I could not see a reason why not.

Is the test running on your setup completely?

Thx
Michael
Post Reply