Interesting issue with different sdcards

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Interesting issue with different sdcards

Post by dhylands » Tue May 06, 2014 11:31 pm

Just got my pyboard.

If I plug in the pyboard on its lonesone, then it seems to boot fine. I can get REPL and the USB Mass Storage device shows up.

However, if I plug in a 4GB sd card, then I get some weird behaviour.
1 - No USB Mass Storage device shows up
2 - After 30 seconds, my REPL prompt goes away and comes back.
3 - If I just leave it alone, then it will disconnect and reconnect every 30 seconds.

I happened to have 4 of the 4Gb cards. They're transcend class 10 cards, and all 4 behave the same way.

I tried a different sdcard (a 16Gb one). This one seems to work fine (although the USB volume only shows as a 3.1Gb volume when mounted through the pyboard (it shows as 16Gb when mounted on directly on my host).
A different brand of 16 Gb card also worked fine, and showed as a 2.8 Gb volume when mounted through the pyboard.
A 2Gb Patriot card seemed to work properly.
A TOPRAM 2Gb card caused the internal flash volume to show up. I'll need to run some tests to see if its being seen.

All of these sdcards are FAT formatted and work properly on my host.

I've attached a photo of the different cards. I'll eventually do some more investigation/debugging and figure out what's going on. I just thought I'd post my observations in case it helps anyone else out.
Attachments
sdcards-small.jpg
Different sdcards referenced in the post
sdcards-small.jpg (77.55 KiB) Viewed 10451 times

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Interesting issue with different sdcards

Post by kfricke » Wed May 07, 2014 8:35 pm

I do also have an Sandisk 1 GB SD card, which does not show up when inserted into the pyboard :?

Interestingly it does show up after pressing the RST button on the board ;)

SkG
Posts: 18
Joined: Mon Mar 10, 2014 2:57 pm

Re: Interesting issue with different sdcards

Post by SkG » Thu May 08, 2014 9:50 am

Its interesting this problem and the one that a Mac user has.

My PyBoard is shipped, I'll investigate both and see what happens, I have like 6 SD cards of different size.

FAT16 has a limit of 2GiB per partition, I don't know how its implemented the FAT driver in micropython I'll check it but I think that it was FAT32.

SkG
Posts: 18
Joined: Mon Mar 10, 2014 2:57 pm

Re: Interesting issue with different sdcards

Post by SkG » Tue May 13, 2014 6:02 pm

Well I tested two MicroSD cards, one of 4GB and another of 16GB.

When I connect the pyboard with them (both are FAT32) at first my system says that its size is 3GB but it gets updated immediately and the real size is shown in the preferences and in the console. But my desktop env (GNOME Shell) still names it as "3GB Volume" due it's what detected at first.

The full SD is usable without problems.

Image

pmst
Posts: 1
Joined: Sun May 18, 2014 7:08 pm

Re: Interesting issue with different sdcards

Post by pmst » Sun May 18, 2014 7:14 pm

Had similar issue until I reformatted the sd to FAT32 (it was FAT16 being a 2GB card)....
Found it works as follows (not sure if it's on the docs):
- connection on USB: internal mcu flash is available
- after 1st reset: sd is available

dilogic
Posts: 3
Joined: Mon Jun 09, 2014 10:51 am

Re: Interesting issue with different sdcards

Post by dilogic » Mon Jun 09, 2014 10:53 am

I had the same problem with another STM32F4-based board. Turned out that there was no pull-up resistor on SDIO_CMD line. On the prototype I've solved it by enabling internal pull-up on that CPU line and then added external resistor on next hardware revision.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Interesting issue with different sdcards

Post by pfalcon » Mon Jun 09, 2014 2:57 pm

dilogic, are you sure you had the same problem, maybe you had similar one? As you have experience with that matter, it would be nice if you could review PyBoard design - it's open source - and provide your recommendations. Thanks.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Interesting issue with different sdcards

Post by dhylands » Mon Jun 09, 2014 3:06 pm

I took a look at the schematic, and there is no pullup on the SDIO_CMD. So I'll add one and retest and see if it makes any difference.

dilogic
Posts: 3
Joined: Mon Jun 09, 2014 10:51 am

Re: Interesting issue with different sdcards

Post by dilogic » Mon Jun 09, 2014 3:18 pm

To pyfalcon:
it was not the same problem technically, as the board I've experienced it with was not pyboard, but the behaviour was exactly the same as well as the CPU, so my guess is that the solution can be the same (10K pull-up on SDIO_CMD). Also, the problem occured only with high-speed type cards.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Interesting issue with different sdcards

Post by dhylands » Mon Jun 09, 2014 5:18 pm

I added a 47k pullup on the SDIO_CMD line (aka PD2), but it didn't change the behaviour - cards that worked before still work, and the cards that failed before still fail.

I also verified that the sdcard_init routine enables the internal pullup as well:
https://github.com/micropython/micropyt ... card.c#L59

I attached a photo of my mod (and checked under the microscope that there are no shorts to adjacent pins, nor the via that is close to the bend).
Attachments
sdio-cmd-pullup.jpg
47K pullup added to SDIO_CMD line
sdio-cmd-pullup.jpg (63.64 KiB) Viewed 10217 times

Post Reply