Build firmware v1.14 with IDF 4.2 problems

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Walkline
Posts: 14
Joined: Wed Feb 19, 2020 4:44 pm

Build firmware v1.14 with IDF 4.2 problems

Post by Walkline » Sat Mar 20, 2021 11:16 am

This is my first time to compile ESP32 port with IDF4, I want to write down a Shell script used for one key deploy MicroPython development environment.

Here is the key segments of my script

Code: Select all

#!/bin/bash
tmp_root_dir=$PWD

# update and install git
sudo apt-get update
sudo apt-get install -y git

# clone IDF and submodules, checkout branch to v4.2
git clone -b v4.2 --recursive https://github.com/espressif/esp-idf.git

# export IDF path
echo "export IDF_PATH=$tmp_root_dir/esp-idf" >> ~/.profile
source ~/.profile

# install development software
sudo apt-get install -y wget flex bison gperf gcc tar make cmake ninja-build ccache
sudo apt-get install -y libffi-dev libssl-dev dfu-util libusb-1.0-0 python-pyparsing python-pyelftools
sudo apt-get install -y python3 python3-pip python3-setuptools libpython3-dev libpython-dev libncurses-dev
sudo apt-get install -y python python-pip python-setuptools python-serial python-cryptography python-future

# switch Python 3.6 to default
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7   1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6   2

# Install toolchains by using IDF install tools 
$IDF_PATH/install.sh

# clone MicroPython and submodules
cd $tmp_root_dir
git clone --recursive https://github.com/micropython/micropython.git

# compile firmware
echo "export Python3_DIR=~/.espressif/python_env/idf4.2_py3.6_env" >> ~/.profile
source ~/.profile
source $IDF_PATH/export.sh

cd $tmp_root_dir/micropython
make -C mpy-cross
cd ports/esp32 && make submodules && make
When this script running into 'compile firmware' part, it's thrown a CMake Error

Code: Select all

CMake Error at /home/walkline/esp32_idf4/micropython/py/mkrules.cmake:32 (find_package):
  By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Python3", but
  CMake did not find one.

  Could not find a package configuration file provided by "Python3" with any
  of the following names:

    Python3Config.cmake
    python3-config.cmake

  Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set
  "Python3_DIR" to a directory containing one of the above files.  If
  "Python3" provides a separate development package or SDK, be sure it has
  been installed.
In the file '/micropython/py/mkrules.cmake:32'

Code: Select all

find_package(Python3 REQUIRED COMPONENTS Interpreter)
Here is the first problem, I can solved this problem by replacing 'Python3' to 'PythonInterp', but I don't know that's why?

After fixed first problem, here is my second problem

Code: Select all

esptool.py v3.0
Generated /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/bootloader/bootloader.bin
[1021/1241] Generating ../../genhdr/mpversion.h
FAILED: genhdr/mpversion.h
cd /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/esp-idf/main && /usr/bin/cmake -E make_directory /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/genhdr && /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/genhdr/mpversion.h
/bin/sh: 1: /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py: Permission denied
[1022/1241] Building C object esp-idf/wifi_provisioning/CMakeFiles/__idf_wifi_provisioning.dir/src/scheme_ble.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 2

Code: Select all

/bin/sh: 1: /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py: Permission denied
Is '/micropython/py/makeversionhdr.py' missing '#!/usr/bin/env python' at first line?

So....I append the 'missing line' for every .py file in '/micropython/py/', and here is my last problem, without solution....

Code: Select all

[2/224] Generating ../../genhdr/mpversion.h
FAILED: genhdr/mpversion.h
cd /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/esp-idf/main && /usr/bin/cmake -E make_directory /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/genhdr && /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py /home/walkline/esp32_idf4/micropython/ports/esp32/build-GENERIC/genhdr/mpversion.h
/bin/sh: 1: /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py: Permission denied
[3/224] Performing build step for 'bootloader'
ninja: no work to do.
[4/222] Linking CXX static library esp-idf/wifi_provisioning/libwifi_provisioning.a
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 2

Code: Select all

/bin/sh: 1: /home/walkline/esp32_idf4/micropython/py/makeversionhdr.py: Permission denied
Is there any way to solve all my problems? And the important thing is, do not manually modify file contents is the best way....

PM-TPI
Posts: 32
Joined: Fri Jun 28, 2019 3:09 pm

Re: Build firmware v1.14 with IDF 4.2 problems

Post by PM-TPI » Mon Mar 29, 2021 7:19 pm

Having same issue...
Any solutions out there ???

Code: Select all

[101/101] Generating binary image from built executable
esptool.py v3.0
Generated /mnt/c/AccuTherm/micropython/ports/esp32/build-GENERIC_SPIRAM/bootloader/bootloader.bin
[1019/1241] Generating ../../genhdr/mpversion.h
FAILED: genhdr/mpversion.h
cd /mnt/c/AccuTherm/micropython/ports/esp32/build-GENERIC_SPIRAM/esp-idf/main && /usr/bin/cmake -E make_directory /mnt/c/AccuTherm/micropython/ports/esp32/build-GENERIC_SPIRAM/genhdr && /mnt/c/AccuTherm/micropython/py/makeversionhdr.py /mnt/c/AccuTherm/micropython/ports/esp32/build-GENERIC_SPIRAM/genhdr/mpversion.h
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 5: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py:
Generate header file with macros defining MicroPython version info.

This script works with Python 2.6, 2.7, 3.3 and 3.4.
: not found
from: can't read /var/mail/__future__
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 9: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py: import: not found
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 10: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py: import: not found
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 11: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py: import: not found
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 12: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py: import: not found
/mnt/c/AccuTherm/micropython/py/makeversionhdr.py: 15: /mnt/c/AccuTherm/micropython/py/makeversionhdr.py: Syntax error: "(" unexpected
[1022/1241] Building C object esp-idf/wifi_provisioning/CMakeFiles/__idf_wifi_provisioning.dir/src/scheme_ble.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory '/mnt/c/AccuTherm/micropython/ports/esp32'
rich@RG-x360:/mnt/c/AccuTherm$

Damien
Site Admin
Posts: 642
Joined: Mon Dec 09, 2013 5:02 pm

Re: Build firmware v1.14 with IDF 4.2 problems

Post by Damien » Thu Apr 22, 2021 12:00 am

I think you need to install cmake version 3.12 or greater. Which version of cmake do you currently have?

Post Reply