Possible to flash board with a preloaded main.py?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

Possible to flash board with a preloaded main.py?

Post by plunk » Thu Dec 07, 2017 10:50 pm

Hello,

I will need to flash a large number of boards with micropython, so I am trying to streamline the process as much as I can. Is it possible to have an initial main.py baked into the firmware that can then be changed later through the typical fashion (edit the source through the REPL or mounted filesystem)?

pagano.paganino
Posts: 89
Joined: Fri Sep 11, 2015 10:47 pm
Location: Italy

Re: Possible to flash board with a preloaded main.py?

Post by pagano.paganino » Thu Dec 07, 2017 11:23 pm

Suppose stm32 port you can edit https://github.com/micropython/micropyt ... ain.c#L144 and change it with your custom main.py

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

Re: Possible to flash board with a preloaded main.py?

Post by Roberthh » Fri Dec 08, 2017 6:51 am

The other option is to extend the file https://github.com/micropython/micropyt ... nisetup.py, which already creates a boot.py in an empty file system.

chrismas9
Posts: 152
Joined: Wed Jun 25, 2014 10:07 am

Re: Possible to flash board with a preloaded main.py?

Post by chrismas9 » Fri Dec 08, 2017 10:13 am

You might be able to suck out a flash image from a master using JTAG or SWD and program the rest from it.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Possible to flash board with a preloaded main.py?

Post by SpotlightKid » Fri Dec 08, 2017 10:22 am

I had a PR, which added the capability to overwrite the files, which are generated at file-system creation time, but it got nowhere and is now outdated: https://github.com/micropython/micropython/pull/1891

See also https://github.com/micropython/micropython/issues/1838

plunk
Posts: 11
Joined: Thu Oct 05, 2017 1:54 pm

Re: Possible to flash board with a preloaded main.py?

Post by plunk » Fri Dec 08, 2017 10:05 pm

Thank you all very much for the quick replies!

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

Re: Possible to flash board with a preloaded main.py?

Post by pythoncoder » Sat Dec 09, 2017 7:54 am

On the ESP8266 I use a modified _boot.py https://github.com/peterhinch/micropyth ... r/_boot.py.
Peter Hinch
Index to my micropython libraries.

Post Reply