SD Card Not Working - MPY: can't mount SD card

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

SD Card Not Working - MPY: can't mount SD card

Post by Dugite » Thu Jan 23, 2020 11:45 pm

I have been developing a data logger using MicroPython 1.12 and I am currently up to PCB revision 3. The first two revisions worked fine with the SD card and it mounted as normal when you plug the USB into a PC and I could see the SD card. The third revision of my PCB, the SD card is slightly further away and the SD card is not mounting.

In the following image the board labeled '1' on the left is the revision 3 PCB (not working) and the board labeled '3' on the right is the revision 2 PCB (working):
Capture-pcb.JPG
Capture-pcb.JPG (55.53 KiB) Viewed 486 times
MicroPython 1.12 is coming up with the message in the terminal:

MPY: can't mount SD card
RuntimeError: name too long
Capture.GIF
Capture.GIF (17.17 KiB) Viewed 546 times
I have checked continuity between the STM32 pins and the SD card socket comparing both boards and all seems OK. My concern is that the slight extra distance and perhaps auto route change is causing some timing issue. But would this really be a problem with this distance?

Any comments on this would be much appreciated :)
Last edited by Dugite on Sat Jan 25, 2020 12:41 am, edited 1 time in total.

User avatar
pythoncoder
Posts: 4479
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SD Card Not Working - MPY: can't mount SD card

Post by pythoncoder » Fri Jan 24, 2020 6:08 am

Continuity checks only tell you if a connection is missing. Might there be an extra one (e.g. a solder bridge)? With hardware faults there's no getting away from putting a 'scope on it...
Peter Hinch

chrismas9
Posts: 149
Joined: Wed Jun 25, 2014 10:07 am

Re: SD Card Not Working - MPY: can't mount SD card

Post by chrismas9 » Fri Jan 24, 2020 12:24 pm

It's possible you have a crosstalk problem between CLK and CMD. On the board that works these signals change to bottom or inner layer so I can't see their routing.

On the new board CLK and CMD are routed very close together for most of their run. On the pyboard there is a guard trace (GND) on each side of the CLk to reduce crosstalk. What can happen is on the clock eege when data is sampled the edge couples a spike onto the data line (CMD) causing it to be misread. I have seen this on SPI bus. There are a couple of ways to check this:

1. As Peter sugessted look at the signals, especially the CMD line. Are there any spikes coincident with clock edges?

2. Add a small capacitor between CLK and GND at the MCU end. Work up from say 10pF. Look at the clock with oscilloscope if you can. The purpose is to slow down the clock edge to reduce crosstalk, but not enough to destry the signal. This is not recommended solution, only for diagnostics, because slow clock edges can also cause problems.

3. Cut the CLK track near the MCU, or lift the MCU CLK pin from its pad. Insert a 22 to 33 ohm resistor in series to reduce slew rate. This is an acceptable production solution.

4. Cut the CLK line at both ends and replace it with a thin wire link (eg wire wrap wire). Elevate this wire so it can't couple to the CMD or DATA lines. You should probably twist it with a GND wire connected to GND at both ends.

User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Re: SD Card Not Working - MPY: can't mount SD card

Post by Dugite » Fri Jan 24, 2020 2:04 pm

Thank you for your comments and suggestions.

I finally just found the issue (this is a part-time effort currently) which ended up being two tracks touching from the auto-routing as shown by the red arrow below:
pcb-back (Small).JPG
pcb-back (Small).JPG (110.69 KiB) Viewed 504 times
Unfortunately, I did not pick that up before sending the design off to have 5 boards made but after cutting two tracks and jumpering them the SD card then started working.

So a good lesson here with auto-routers and making sure you check the tracks to make sure none are too close to each other.

Thanks for your input pythoncoder and chrismas9.

User avatar
pythoncoder
Posts: 4479
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SD Card Not Working - MPY: can't mount SD card

Post by pythoncoder » Sat Jan 25, 2020 10:02 am

Nasty. I'm surprised your CAD system doesn't have a design rules check which would have picked this up.
Peter Hinch

chrismas9
Posts: 149
Joined: Wed Jun 25, 2014 10:07 am

Re: SD Card Not Working - MPY: can't mount SD card

Post by chrismas9 » Sat Jan 25, 2020 1:01 pm

If you are doing another run of boards it would be worth hand routing a GND track on each side of CLK.

User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Re: SD Card Not Working - MPY: can't mount SD card

Post by Dugite » Fri Feb 07, 2020 1:28 pm

I am not sure what happened here with the routing, but I will see how the next board goes.

@ chrismas9
It is a 4 layer PCB with a power and GND plane so this should be fine?

Post Reply