Page 1 of 1

Adding python files and folders to build

Posted: Fri Jul 01, 2022 4:04 pm
by bborncr
I see that the "boot.py" file that is preinstalled in firmware builds is created in "modules/inisetup.py".
It there an easier way to add preinstalled folders and example files to the build?

Re: Adding python files and folders to build

Posted: Mon Jul 04, 2022 1:42 am
by jimmo
bborncr wrote:
Fri Jul 01, 2022 4:04 pm
It there an easier way to add preinstalled folders and example files to the build?
There are two ways to do this -- either you can "freeze" Python code into the firmware, or you can pre-load them onto the filesystem. Freezing is far superior because it means that the module executes from ROM and doesn't use any RAM to load the bytecode.

If you're customising the build (e.g. by adding frozen modules), the way to do this is to write a custom board definition (e.g. ports/PORT/boards/BOARD. Start with a copy of the existing one, and you can modify manifest.py to add your own files. Note that your own board definition directory doesn't have to live in the micropython repo.

See example board definitions here: https://github.com/micropython/micropyt ... ple-boards
See docs on manifest.py here: https://docs.micropython.org/en/latest/ ... ifest.html