Page 1 of 1

boot file system and SKIPSD

Posted: Thu Sep 03, 2020 5:01 pm
by smhodge
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?

Re: boot file system and SKIPSD

Posted: Thu Sep 03, 2020 7:13 pm
by dhylands
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.

Re: boot file system and SKIPSD

Posted: Fri Sep 04, 2020 6:03 am
by pythoncoder
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.