Custom files in the self-compiled Micropython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
lutecki
Posts: 6
Joined: Wed Apr 14, 2021 8:56 pm

Custom files in the self-compiled Micropython

Post by lutecki » Wed Apr 14, 2021 9:12 pm

Hi,
I need to upload Micropython with program files to a 30 piece of ESP32. To speed things up I would compile my own MP version already with the program files and images and libraries. In which folder should I put the files to be included in the compiled bin file?

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

Re: Custom files in the self-compiled Micropython

Post by Roberthh » Thu Apr 15, 2021 9:30 am

You van embed python scripts into the firmware by placing them into the modules directory. But that does not add them to the file system. A workaround may be to encapsulate other content into a python script and extract that on boot. But that works for short files only.

User avatar
russ_h
Posts: 52
Joined: Thu Oct 03, 2019 2:26 am

Re: Custom files in the self-compiled Micropython

Post by russ_h » Thu Apr 15, 2021 4:29 pm

Here is a link showing how I modified the VFAT file system image to add files for a ESP32 based MicroPython device using Centos 7 Linux. I have not tried modifying the littlefs file system but I suspect the process would be similar.

https://gist.github.com/russhughes/1300 ... vfat-image

lutecki
Posts: 6
Joined: Wed Apr 14, 2021 8:56 pm

Re: Custom files in the self-compiled Micropython

Post by lutecki » Fri Apr 16, 2021 7:33 am

OK, so you thinking it's not very simple. So maybe does esptool allow to upload files to littlefs? Then I would write a script to burn bootrom and copy the files.

lutecki
Posts: 6
Joined: Wed Apr 14, 2021 8:56 pm

Re: Custom files in the self-compiled Micropython

Post by lutecki » Fri Apr 16, 2021 9:06 am

Hi guys and thanks for reply,
So if you thinking it's not simple, does esptool allow to upload files to littlefs? Then I would create a script to burn bootrom and copy the files in second step.

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

Re: Custom files in the self-compiled Micropython

Post by Roberthh » Fri Apr 16, 2021 9:18 am

Esptool just copies data to the flash memory and does not care about the type of the data.

Christian Walther
Posts: 137
Joined: Fri Aug 19, 2016 11:55 am

Re: Custom files in the self-compiled Micropython

Post by Christian Walther » Fri Apr 16, 2021 10:35 am

But you can use pyboard.py to copy files after you used esptool.py to install MicroPython. Works fine in a script if you put a sleep 5 or something between them to let MicroPython boot.

User avatar
russ_h
Posts: 52
Joined: Thu Oct 03, 2019 2:26 am

Re: Custom files in the self-compiled Micropython

Post by russ_h » Fri Apr 16, 2021 2:51 pm

Another option is to use mpfshell with a script to upload your files. I use this for uploading example programs to test new display driver code. See the upload.mpf file in https://github.com/russhughes/st7789_mp ... /T-DISPLAY for an example. It’s not very fast but it works.

To install mpfshell: pyrhon3 -m pip install mpfshell
To run script: mpfshell -s upload.mpf

Post Reply