Page 1 of 1

Attaching main.py into the build firmware.

Posted: Wed Apr 21, 2021 6:12 am
by plugowski
Hi,

I didn't develop for a while in micropython, last version I used was v1.10 or 1.11. So there was (as I remember) folder scripts, where I was able to put my main.py script file and when I build firmware and flash it it was already on board and worked.

Now in ports/esp32 this folder dissapeared and I can't find any information how to put main.py into firmware in automated way.

Can anyone help me with that?

Best Regards,
Paul

Re: Attaching main.py into the build firmware.

Posted: Wed Apr 21, 2021 8:15 am
by Roberthh
You can still put your code into the esp32/modules directory. I do not recall the state at the moment, but AFAIK main.py will not be called from frozen bytecode. So that has to be in the flash file system. But main.py can call your modules.
In modules there is also _boot.py, which is executed before boot.py and main.py. So that can be used for early init steps.

Re: Attaching main.py into the build firmware.

Posted: Wed Apr 21, 2021 1:00 pm
by plugowski
So is there any option to create main.py on fly using _boot.py? Like copy it somehow into filesystem?

Re: Attaching main.py into the build firmware.

Posted: Wed Apr 21, 2021 1:14 pm
by Roberthh
It should be possible, since one of the actions in _boot.py is creating the file system in flash with boot.py if required. The template for that boot.py is in the file inisetup.py, also located in modules.