Boot from 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.
Post Reply
JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Boot from SD Card

Post by JimTal001 » Mon Aug 24, 2015 7:54 pm

I want to run my python code off the SD card (like raspberry pi). Is there documentation which describes how to setup the pyboard to do this?

Thanks

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Boot from SD Card

Post by blmorris » Mon Aug 24, 2015 8:24 pm

Just put your 'boot.py' and 'main.py' files on your SD card; when the card is present in the pyboard it will run the code there instead of from the internal flash.

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: Boot from SD Card

Post by JimTal001 » Mon Aug 24, 2015 8:45 pm

Thanks for the response.

Do I need to remove the boot.py and main.py from flash?

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Boot from SD Card

Post by blmorris » Mon Aug 24, 2015 9:28 pm

No, the files on the SD card just get run instead of the internal Flash.

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: Boot from SD Card

Post by JimTal001 » Mon Aug 24, 2015 9:41 pm

Based on what I have understand (from post/response) it is not possible to output debug information (like print statements) to the terminal (REPL) if running a program on the SD card. Can anyone verify this.

Thanks

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Boot from SD Card

Post by blmorris » Mon Aug 24, 2015 11:19 pm

The REPL works the same whether you boot from internal flash or SD card.
You can use 'boot.py' to set whether the REPL uses USB or one of the hardware serial ports (uarts). You can also set whether USB Mass Storage is turned on or off. If the SD card is present then that boot.py and main.py will be run.

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: Boot from SD Card

Post by JimTal001 » Tue Aug 25, 2015 1:16 am

Thanks blmorris,

Can you point me to the documentation which elaborates on setting the USB mode?

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

Re: Boot from SD Card

Post by dhylands » Tue Aug 25, 2015 1:58 am

It looks like there isn't any documentation.

The function in question is called pyb.usb_mode. There is a brief amount of documentaiton in the default boot.py file:
https://github.com/micropython/micropyt ... #L131-L132

There is a bit more information in the actual source file:
https://github.com/micropython/micropyt ... #L182-L189

If you use pyb.usb_mode('VCP') or pyb.usb_mode('CDC') then you'll get usb-serial only with no Mass Storage. If you use pyb.usb_mode(None) then it should disable all USB functionality.

You can get the REPL on a HW UART by using the pyb.repl_uart function:
http://docs.micropython.org/en/latest/l ... .repl_uart

Post Reply