Compiling Micropython

Forcing the correct module versions

When trying to compile the ESP32 port of MicroPython on an Ubuntu-20.04 system I see the following error:

compileError.png

As the message states we are running a version of pyparsing which is too recent for the ESP_IDF development environment and we must create a virtual environment for Python3 with the correct version the this module.

This is how I did it:

First I created a directory ~/pythonEnvironments in my home directory.
Then I create a virtual environment mp_env for MicroPython compilation:

python3 -m venv mp_env

Once the environment is created you can activate it:

source mp_env/bin/activate

Once you are in your new environment you can use pip to load the modules you need with the correct version numbers:

pip3 install pyparsing=2.3.1
pip3 install pyserial

Once this is accomplished compilation of MicroPython works as expected:

virtualEnv.png

As soon as you are done you can deactivate the environment and return to the standard Python environment with the deactivate command.

Freezing modules into the MicroPython binary

We want to give students easy access to drivers for the sensors we use during the course. If we compile and freeze these modules into the MicroPython binary, then these module are available for import without the necessity to upload them to the ESP32 before use. in addition this method frees valuable RAM space, a resource that is very scarce on the machine.

Freezing of MicroPython modules into the binary is pretty easy: We must simply copy the Python code into the ports/esp32/modules directory of the MicroPython source before compilation. Here is the list of additional modules that are currently included:

modules.png

-- Uli Raich - 2020-04-29

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng compileError.png r1 manage 59.7 K 2020-04-29 - 18:02 UliRaich  
PNGpng modules.png r1 manage 34.3 K 2020-04-29 - 18:58 UliRaich  
PNGpng virtualEnv.png r1 manage 161.3 K 2020-04-29 - 18:18 UliRaich  
Edit | Attach | Watch | Print version | History: r9 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-04-29 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback