Page 1 of 1
calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 9:10 am
by jcsduncan
Forum noob here! Hello everyone
Is it possible to call boot.py from the internal flash with an SD card inserted?
Thanks in advance.
Chris
Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 2:14 pm
by blmorris
Two options (I just tested both of them, so pretty sure that they work…)
if you just want to import it - for example, if you want boot.py to run as normal from flash even with an SD card inserted.
will let you run this file (or any other file) an arbitrary number of times if you want, compared to 'import' which will only run the code once.
-Bryan
Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 3:02 pm
by jcsduncan
Thanks for the reply Bryan

Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 3:05 pm
by jcsduncan
I may have worded the question wrong...
I wish for the device to execute boot.py from internal flash rather than the sd card - not a manual execution.
Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 7:09 pm
by dhylands
Basically, what Bryan said. To have it happen automatically, then you'd create a boot.py on the sdcard which had the following in it:
Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 9:57 pm
by blmorris
I think that putting 'import boot' at the beginning of 'main.py' on your SD card will also work - /flash is on the import search path.
Re: calling boot.py from int flash with SD inserted.
Posted: Thu Feb 26, 2015 11:01 pm
by dhylands
blmorris wrote:I think that putting 'import boot' at the beginning of 'main.py' on your SD card will also work - /flash is on the import search path.
I tried that but it didn't seem to do anything. I had /flash/boot.py with:
Code: Select all
import pyb
def boot_func():
print("Executing internal /flash/boot.py")
and with /sd/main.py just containing: [code}import boot[/code] I got:
Code: Select all
Micro Python v1.3.10-103-g12d6d77 on 2015-02-26; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> boot_func()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'boot_func' is not defined
>>> import boot
>>> boot_func()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'boot_func' is not defined
>>>