Attaching main.py into the build firmware.

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
plugowski
Posts: 6
Joined: Tue Apr 10, 2018 5:35 am
Location: Bangkok, Thailand
Contact:

Attaching main.py into the build firmware.

Post by plugowski » Wed Apr 21, 2021 6:12 am

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

User avatar
Roberthh
Posts: 2644
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Attaching main.py into the build firmware.

Post by Roberthh » Wed Apr 21, 2021 8:15 am

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.

plugowski
Posts: 6
Joined: Tue Apr 10, 2018 5:35 am
Location: Bangkok, Thailand
Contact:

Re: Attaching main.py into the build firmware.

Post by plugowski » Wed Apr 21, 2021 1:00 pm

So is there any option to create main.py on fly using _boot.py? Like copy it somehow into filesystem?

User avatar
Roberthh
Posts: 2644
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Attaching main.py into the build firmware.

Post by Roberthh » Wed Apr 21, 2021 1:14 pm

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.

Post Reply