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: 75
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: 647
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?

prathode
Posts: 5
Joined: Tue Feb 01, 2022 1:16 pm

Re: Build firmware v1.14 with IDF 4.2 problems

Post by prathode » Wed Mar 02, 2022 5:47 am

Damien wrote:
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?
Hi @Damien this first time I am building MicroPython so need bit of help. I am following README.md available in ESP32 port in official Micropython.

Currently I am using cmake version 3.16.3 but I am facing error version.cmake file not found. I have also verified that version.cmake is available on given path.

I have also referred this post https://github.com/espressif/esp-idf/is ... -726356773 where it says that if we use lower version of git it may cause the below error so I have also updated my git to version 1:2.25.1-1ubuntu3.2 which is latest for my ubuntu system.

But still it throws an error. What could be possible solution.

I have pasted error below for reference.

Code: Select all

root@CI5W10P061524:/home/upy_v1.18_source/micropython/ports/esp32# make
idf.py -D MICROPY_BOARD=GENERIC -B build-GENERIC  build
WARNING: IDF_PATH environment variable is set to /root/home/upy_v1.18_source/esp-idf but /home/upy_v1.18_source/esp-idf/tools/idf.py path indicates IDF directory /home/upy_v1.18_source/esp-idf. Using the environment variable directory, but results may be unexpected...
/root/.espressif/python_env/idf4.2_py2.7_env/bin/python: can't open file '/root/home/upy_v1.18_source/esp-idf/tools/check_python_dependencies.py': [Errno 2] No such file or directory

fatal: not a git repository: '/root/home/upy_v1.18_source/esp-idf/.git'
WARNING: Git version unavailable, reading from source
Traceback (most recent call last):
  File "/home/upy_v1.18_source/esp-idf/tools/idf.py", line 788, in <module>
    main()
  File "/home/upy_v1.18_source/esp-idf/tools/idf.py", line 704, in main
    checks_output = check_environment()
  File "/home/upy_v1.18_source/esp-idf/tools/idf.py", line 99, in check_environment
    print_idf_version()
  File "/home/upy_v1.18_source/esp-idf/tools/idf.py", line 117, in print_idf_version
    version = idf_version()
  File "/home/upy_v1.18_source/esp-idf/tools/idf_py_actions/tools.py", line 62, in idf_version
    version = _idf_version_from_cmake()
  File "/home/upy_v1.18_source/esp-idf/tools/idf_py_actions/tools.py", line 36, in _idf_version_from_cmake
    with open(version_path) as f:
IOError: [Errno 2] No such file or directory: '/root/home/upy_v1.18_source/esp-idf/tools/cmake/version.cmake'
make: *** [Makefile:34: all] Error 1

Post Reply