boot file system and SKIPSD

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
smhodge
Posts: 86
Joined: Tue Jan 22, 2019 2:16 am
Location: Kirkland, WA, USA

boot file system and SKIPSD

Post by smhodge » Thu Sep 03, 2020 5:01 pm

My interpretation of the documentation is that the boot file system (/flash or /sd) is where it first finds <boot.py> and <main.py>, starting the search with /sd if it exists, and that you can force /sd to be skipped and thus use /flash by either removing the SD card or putting an empty SKIPSD file on /flash, but that comes with the caveat that /sd will not be mounted if the SD card is present, but can be later mounted with os.mount.

So couldn't the same thing be done by simply renaming the <boot.py> file on /sd to something else? Would that force /flash to be the current directory so that the code on /flash would be used instead of code on /sd, while at the same time having /sd mounted and thus avoid having to use os.mount?

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

Re: boot file system and SKIPSD

Post by dhylands » Thu Sep 03, 2020 7:13 pm

Looking at the source code: https://github.com/micropython/micropyt ... ain.c#L643

It either adds /sd and /sd/lib OR /flash and /flash/lib to sys.path. It will look for boot.py and main.py in the paths shown in sys.path.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: boot file system and SKIPSD

Post by pythoncoder » Fri Sep 04, 2020 6:03 am

smhodge wrote:
Thu Sep 03, 2020 5:01 pm
...
So couldn't the same thing be done by simply renaming the <boot.py> file on /sd to something else? Would that force /flash to be the current directory so that the code on /flash would be used instead of code on /sd, while at the same time having /sd mounted and thus avoid having to use os.mount?
I think SKIPSD is a security feature to prevent a hostile user fitting an SD card containing their own code.
Peter Hinch
Index to my micropython libraries.

Post Reply