Trouble with SD Card

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Trouble with SD Card

Post by Roberthh » Tue Jun 21, 2016 12:03 pm

If you plug in the SD card while PYBoard is running, it will not be recognized. You have to reboot PyBoard, e.g. with Ctrl-D. or pushing the reset button.

ahmet_cihan
Posts: 7
Joined: Mon Jun 20, 2016 9:23 am

Re: Trouble with SD Card

Post by ahmet_cihan » Tue Jun 21, 2016 1:51 pm

But if I reset the board, system will boot from SD Card. So, I need to put my code into SD Card. I don't want this. In my project, user will be able to insert or remove SD Card while board is running. The user/operator might delete the code file. Is there any way to protect boot.py and main.py files?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Trouble with SD Card

Post by deshipu » Tue Jun 21, 2016 2:04 pm

You could have a second SD card connected with SPI.

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

Re: Trouble with SD Card

Post by dhylands » Tue Jun 21, 2016 5:17 pm

What you're describing is expected behaviour.

MicroPython only checks if the sdcard is present during bootup, so at powerup time, or soft-reboot (perhaps using Control-D).

I tried your steps and I get the exact same behaviour. If I power on the board and then insert the sdcard then it won't be detected. If I press Control-D then it will be detected.

Similarly, once it's been detected, if you remove it and repeat the os.listdir('/') it will still be reported.

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

Re: Trouble with SD Card

Post by dhylands » Tue Jun 21, 2016 5:20 pm

ahmet_cihan wrote:But if I reset the board, system will boot from SD Card. So, I need to put my code into SD Card. I don't want this. In my project, user will be able to insert or remove SD Card while board is running. The user/operator might delete the code file. Is there any way to protect boot.py and main.py files?
You can have a boot.py on the sdcard which just executes the boot.py from /flash. See: http://forum.micropython.org/viewtopic.php?f=2&t=865

ahmet_cihan
Posts: 7
Joined: Mon Jun 20, 2016 9:23 am

Re: Trouble with SD Card

Post by ahmet_cihan » Wed Jun 22, 2016 2:33 pm

Thank you Dave. That will solve my problem.

hybotics
Posts: 33
Joined: Tue Apr 03, 2018 2:58 am
Contact:

Re: Trouble with SD Card

Post by hybotics » Sat Mar 09, 2019 6:32 am

Hi,

I am trying to get my pyboard 1.1 to boot from a Sandisk 16Gb sd card. It is single partition. formatted fat32 according to gparted. Micropython v1.10.

The pyboard does not recognize this to boot from. There is a boot.py on the sd card.

Should this work?

8-Dale

Post Reply