Custom made - Sometimes, it is nice to be able to build custom made things. Thanks to Damien George and all the clever people at micropython.org for making it easy. So that, to custom build a micropython is not that difficult.
Why do you want to build customize firmware anyway? Well, you might want to include some functionalities of your own and removed some functionalities from the standard distribution.
The choices are there for you to make.
I have a few changes that I want to make in micropython.
These are accomplished by modifying and adding files.
I also want to remove some modules specifically, help, upip, and webrepl from esp32, esp23-cam and esp8266 firmware, to reduce their built size.
Modification to Makefile, mpconfigport.h, mpthreadport.c, and boards/sdkconfig.base are needed for some specific ports.
I have made simple scripts, to clone micropython and esp-idf, patch the
necessary files for custom build and run make for ports listed under:
The scripts mpb.py will create a working directory for today in YYYYMMDD format. Git clone micropython under this directory. Copy and all ports for custom build and patch files using copy 'cp -rfv' files from Custommade_Template directory.
I know that I am abusing the GIT server as an FTP server by cloning the whole micropython master branch each time. Those who know git will probably say, "why not use git pull?" The whole micropython source is about 75 megabytes, which is not that large. It is simpler this way.
After running the mpb.py and if everything went ok, then you can run mpc.py. This script will copy all compiled firmware and micropython binary files to a staging area.
The script mpb.py will ask you to run esp.py script if a valid version of esp-if is not available. The esp.py will download and update the correct
esp-idf together with the camera component.
There are a few things you need to change in these files. The value of mpc_dir is the directory path where you want to copy your compiled binaries. You also need to change PATH values at a different stage of the build script. For esp32 you need xtensa-esp32-elf tools and for esp8266 you need xtensa-lx106-elf.
I have packed all the necessary files in a zip file, custommade.zip. You can download it from GitHub. Unzipping this zip file, a top directory MP will be created. You can then cd MP and run mpb.py. If needed, you may have to run esp.py to fix esp-if dependency. After you have a valid esp-idf installed, you can run mpb.py again so that you can make your custom build MicroPython.
Mind you, I did all this just for fun. I have not studied the micropython build structure and mechanism in detail. Future distributions may not build using this setup. I can not guarantee the usefulness and correctness of the compiled binaries, either.
I have flashed and run some simple test scripts on a few esp8266, esp32 and esp32-cam boards. They work. I have not done any rigorous testing, just that they boot up ok, import modules, and run simple test scripts.
You'd be better off downloading the official firmware from micropython.org if a standard firmware is what you need.
Why do you want to build customize firmware anyway? Well, you might want to include some functionalities of your own and removed some functionalities from the standard distribution.
The choices are there for you to make.
I have a few changes that I want to make in micropython.
- version header -kaki5 (pronounce kaki-lima)
- an additional thread cleanup function for esp32
- add frozen modules CryptoXo and uasyncio
- remove help, upip, and webrepl
- camera C module for esp32 camera board
These are accomplished by modifying and adding files.
- py/makeversionhdr.py
- py/modthread.c
- extra/CryptoXo.py, extra/uasyncio.py, and manifest.py
- mpconfigport.h
- main.c and modcamera.c
I also want to remove some modules specifically, help, upip, and webrepl from esp32, esp23-cam and esp8266 firmware, to reduce their built size.
Modification to Makefile, mpconfigport.h, mpthreadport.c, and boards/sdkconfig.base are needed for some specific ports.
I have made simple scripts, to clone micropython and esp-idf, patch the
necessary files for custom build and run make for ports listed under:
- esp32-cam
- esp32
- esp8266
- esp8266_512K
- unix
- windows
The scripts mpb.py will create a working directory for today in YYYYMMDD format. Git clone micropython under this directory. Copy and all ports for custom build and patch files using copy 'cp -rfv' files from Custommade_Template directory.
I know that I am abusing the GIT server as an FTP server by cloning the whole micropython master branch each time. Those who know git will probably say, "why not use git pull?" The whole micropython source is about 75 megabytes, which is not that large. It is simpler this way.
After running the mpb.py and if everything went ok, then you can run mpc.py. This script will copy all compiled firmware and micropython binary files to a staging area.
The script mpb.py will ask you to run esp.py script if a valid version of esp-if is not available. The esp.py will download and update the correct
esp-idf together with the camera component.
There are a few things you need to change in these files. The value of mpc_dir is the directory path where you want to copy your compiled binaries. You also need to change PATH values at a different stage of the build script. For esp32 you need xtensa-esp32-elf tools and for esp8266 you need xtensa-lx106-elf.
I have packed all the necessary files in a zip file, custommade.zip. You can download it from GitHub. Unzipping this zip file, a top directory MP will be created. You can then cd MP and run mpb.py. If needed, you may have to run esp.py to fix esp-if dependency. After you have a valid esp-idf installed, you can run mpb.py again so that you can make your custom build MicroPython.
Mind you, I did all this just for fun. I have not studied the micropython build structure and mechanism in detail. Future distributions may not build using this setup. I can not guarantee the usefulness and correctness of the compiled binaries, either.
I have flashed and run some simple test scripts on a few esp8266, esp32 and esp32-cam boards. They work. I have not done any rigorous testing, just that they boot up ok, import modules, and run simple test scripts.
You'd be better off downloading the official firmware from micropython.org if a standard firmware is what you need.
Thank you for this information. I just installed one of your newest Micropython firmware builds from github om my AI-Thinker ESP32-CAM and it works fine. Does this method as described above still apply for building Micropython for ESP32-CAM? I would like to try it by myself.
ReplyDelete