Page 1 of 1
Boot from /flash and mount /sd
Posted: Wed Aug 19, 2015 5:49 pm
by LRonHorse
Hi
Does anyone know how to boot from flash but still have the sd mounted and accessible - or is possible?
I've just gotten started with the pyboard and getting to grips with it (albeit slowly) but can't find a way of doing this.
I'd like to run code from flash but use sd for writing data to.
Cheers
LRon
Re: Boot from /flash and mount /sd
Posted: Wed Aug 19, 2015 7:49 pm
by dhylands
When an sd card is inserted, it will only run /sd/boot.py and it will ignore /flash/boot.py
If you make the sdcard contain something like the following:
then you can get the /flash/boot.py executed.
Otherwise, you'd need to comment out the f_chdrive("/sd"); line:
https://github.com/micropython/micropyt ... ain.c#L506
and then it should always run /flash/boot.py
Re: Boot from /flash and mount /sd
Posted: Thu Aug 20, 2015 12:45 pm
by LRonHorse
Thanks Dave I shall give that a try today and see where it gets me

Re: Boot from /flash and mount /sd
Posted: Fri Aug 21, 2015 2:19 pm
by LRonHorse
Hi Dave
I tried the execfile('/flash/boot.py') approach from the sd card and it didn't work for me.
However, I did try the following:
import pyb
pyb.main(('/flash/main.py')
which did work - dunno why I didn't try that first!!
It do a couple of odd things though, such as overwriting the boot.py file on the flash fs. No idea why so it could be something stupid I managed to do.
Writing to /sd also seemed to work quite happily from /flash although again with a couple of odd occurrences.
Do you, or anyone else on the forum, know if there is a way to immediately update a file write as, after the initial write I seem to have to power down the board before it'll write - and even then it's not overly reliable.
I've tried calling os.sync() but this fails also.
Anyway, thanks for the info - much appreciated

Re: Boot from /flash and mount /sd
Posted: Fri Aug 21, 2015 4:32 pm
by dhylands
I've found that using the USB Mass Storage to be unreliable at best. The underlying protocols were designed with exclusive access in mind. Unfortunately, the way the pyboard uses it it is very easy for the host to totally overwrite any changes made by the pyboard.
So I wound up writing a program called rshell
https://github.com/dhylands/upy-shell/t ... ter/rshell which allows you to copy files into and out of the pyboard using only usb-serial. Then you can disable USB Mass storage and all accesses to the file system will come from the pyboard and you don't get files mysteriously altered by the host (because it thought it had exclusive access).
Re: Boot from /flash and mount /sd
Posted: Fri Aug 21, 2015 5:08 pm
by LRonHorse
Thanks for that - I shall checkout RShell and see what transpires
Many thanks
LRon