micro SD slots with no card detect signal

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

micro SD slots with no card detect signal

Postby mabl » Sat Jun 23, 2012 5:16 pm

Hi,

I'm currently looking into correctly implementing card detection for the Olimex STM32P107. This card slot has no dedicated card detect signal and uses the CS signal which is pulled low via a 1M resistor on the board and "overwritten" by the pull-up of the card.

Now, I do not see an obvious way on how to implement the card detect call, since it is called periodically by the MMC driver, independent of its current state. So I cannot reconfigure the SPI NSS/CS output as an input during read/write transactions to read the pull-up. Has anybody solved this problem already?

Best,

Matthias

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: micro SD slots with no card detect signal

Postby Tectu » Sat Jun 23, 2012 5:20 pm

I am not sure if this is even related, but I want to come up with this here:

I don't have the Olimex P107 board, but another board with an SD card slot. The example works fine when porting the board files. I have just one problem: When inserting the SD card, the function called by the event does get called (LED debugging ;-)), but the card doesen't get mounted 80% of the time (fs_ready is false). I have to reset the board then and take another try. Sometimes I have to do that five times.
When I take the card out and put it back in again, InsertHandler dosen't get called again.
But as I said, when the card gets mounted successfully, everything works great.

Ideas?


~ Tectu

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: micro SD slots with no card detect signal

Postby Giovanni » Sat Jun 23, 2012 5:23 pm

This is the same on newer Olimex boards. One possible solution is to make the MMC_SPI driver work like the SDC one and do not poll that input all the time. Making those two drivers behave in a more similar way would be a good idea anyway.

I'll give it a try tomorrow.

Giovanni

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: micro SD slots with no card detect signal

Postby mabl » Sat Jun 23, 2012 5:33 pm

Hi Giovanni,

that would be great :-) Thank you for looking into it, it's greatly appreciated.

@Tectu: That's call Thread hijacking! :twisted: Anyway, get yourself a working debugger and don't complain until then :P RTOS development without a Debugger is just awful.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: micro SD slots with no card detect signal

Postby Tectu » Sat Jun 23, 2012 6:07 pm

mabl wrote:@Tectu: That's call Thread hijacking! :twisted: Anyway, get yourself a working debugger and don't complain until then :P RTOS development without a Debugger is just awful.

I actually do have a debugger, I mostly just don't know how to use it the best way.

Also, I did just ask if someone has a similar problem, nothing else ;-)


~ Tectu

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: micro SD slots with no card detect signal

Postby Giovanni » Sun Jun 24, 2012 1:40 pm

This will take some more time because the driver state machine changes entirely. You could simply make the detection function return TRUE and handle insertions outside the driver as a temporary workaround.

Giovanni

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: micro SD slots with no card detect signal

Postby mabl » Sun Jun 24, 2012 1:46 pm

Giovanni wrote:This will take some more time because the driver state machine changes entirely. You could simply make the detection function return TRUE and handle insertions outside the driver as a temporary workaround.

Giovanni


Hi Giovanni, that's what I'm currently doing. Also my SD cards are not removed during operation. So take your time changing the state machines. I was just looking for doing it the nice way since this is getting more and more important with the rise of Olimex boards.

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: micro SD slots with no card detect signal

Postby mabl » Sat Jun 30, 2012 1:06 pm

Hi Giovanni,

I've seen you made quite some changes - is this already considered "stable"?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: micro SD slots with no card detect signal

Postby Giovanni » Sat Jun 30, 2012 1:12 pm

Hi, the driver changes are over, I am testing it right now in the STM32-E407 demo project (will have to adjust all other projects later), card detection works even if the D3 pin is shared with SDIO.

On the SPI interface there is a problem, the card detection is shared with CS which is a push-pull output, that prevents the detection of the card. There are two possible solutions to this:

1) Switch the CS in input mode, delay, read the value, switch to output mode. The problem is that the delay using R=1M and C=10pF is like 30uS, not possible in ISR context.
2) Make the CS an open drain output and rely on the 10K pull-up internal to the card. This could work but I haven't tested it yet.

Giovanni

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: micro SD slots with no card detect signal

Postby mabl » Sat Jun 30, 2012 1:16 pm

Sounds great. I unfortunately do not have my boards with me over the weekend. But I'll sure test it within the next week. Thank you so much for taking all that time to make ChibiOS even greater!


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 23 guests