Page 1 of 1

Boot from SD Card

Posted: Mon Aug 24, 2015 7:54 pm
by JimTal001
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

Re: Boot from SD Card

Posted: Mon Aug 24, 2015 8:24 pm
by blmorris
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.

Re: Boot from SD Card

Posted: Mon Aug 24, 2015 8:45 pm
by JimTal001
Thanks for the response.

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

Re: Boot from SD Card

Posted: Mon Aug 24, 2015 9:28 pm
by blmorris
No, the files on the SD card just get run instead of the internal Flash.

Re: Boot from SD Card

Posted: Mon Aug 24, 2015 9:41 pm
by JimTal001
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

Re: Boot from SD Card

Posted: Mon Aug 24, 2015 11:19 pm
by blmorris
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.

Re: Boot from SD Card

Posted: Tue Aug 25, 2015 1:16 am
by JimTal001
Thanks blmorris,

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

Re: Boot from SD Card

Posted: Tue Aug 25, 2015 1:58 am
by dhylands
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