当前位置:网站首页>Espressif plays with the compilation environment

Espressif plays with the compilation environment

2022-07-26 08:53:00 Embedded engineering lion

Espressif Of ESP-IDF Recently released release/v5.0, I've been release/v4.3 On the development , Unconsciously, it has fallen behind 2 A version ( There's another one in the middle release/4.4 edition ). Then put your own ESP-IDF Updated to release/v5.0 edition , Originally thought that the implementation ./install.sh The script is executed after . ./export.sh You can complete the setup of the compilation environment , Facts have proved that nothing can be plain sailing .

The operating system I use is uBuntu, The system information is as follows :

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic

Below is a list of some that are being installed ESP-IDF Of release/v5.0 Problems encountered in the compilation environment of and solutions .

  1. python Version is too low

    stay ESP-IDF Of release/v4.3 On Development , I'm using python The version is 3.6.9. take ESP-IDF Upgrade to release/v5.0 After the ./install.sh Prompt python Version is too low , By looking at ./install.sh The script knows ,python Version check script ${IDF_PATH}/tools/python_version_checker.py, Continue to analyze the script, and now release/v5.0 Supported by pyhon The minimum version is 3.7 above .

    The solution is simple , upgrade python Version can , Can use update-alternatives Implement multiple python Version Management . This is what I installed python Of 3.8.12 edition .

    #!/usr/bin/env bash
    
    set -e
    set -u
    
    basedir=$(dirname "$0")
    IDF_PATH=$(cd "${basedir}"; pwd -P)
    export IDF_PATH
    
    echo "Detecting the Python interpreter"
    . "${IDF_PATH}/tools/detect_python.sh"
    
    echo "Checking Python compatibility"
    "${ESP_PYTHON}" "${IDF_PATH}/tools/python_version_checker.py"
    
    TARGETS=`"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "[email protected]"`
    
    echo "Installing ESP-IDF tools"
    "${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install --targets=${
          TARGETS}
    
    FEATURES=`"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract features "[email protected]"`
    
    echo "Installing Python environment and packages"
    "${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install-python-env --features=${
          FEATURES}
    
    echo "All done! You can now run:"
    echo ""
    echo " . ${basedir}/export.sh"
    echo ""
    
    import sys 
    
    try:
        # Python 2 is not supported anymore but still the old way of typing is used here in order to give a nice Python
        # version failure and not a typing exception.
        from typing import Iterable
    except ImportError:
        pass
    
    OLDEST_PYTHON_SUPPORTED = (3, 7)  # keep it as tuple for comparison with sys.version_info
    
    
    def _ver_to_str(it):  # type: (Iterable) -> str
        return '.'.join(str(x) for x in it) 
    
    
    def is_supported():  # type: () -> bool
        return sys.version_info[:2] >= OLDEST_PYTHON_SUPPORTED[:2]
    
    
    def check():  # type: () -> None
        if not is_supported():
            raise RuntimeError(
                'ESP-IDF supports Python {} or newer but you are using Python {}. Please upgrade your '
                'installation as described in the documentation.'.format(
                    _ver_to_str(OLDEST_PYTHON_SUPPORTED), _ver_to_str(sys.version_info[:3])
                )
            )
    
    
    if __name__ == '__main__':
        check()
    
  2. /home/esp/.espressif/python_env/idf5.0_py3.8_env/bin/python: No module named pip

    This problem is very strange , At first I thought I python Of 3.8.12 Version is not installed pip, So you can install it directly through the following commands pip:

    sudo apt install python3-pip
    

    After the installation is completed, execute directly pip --version Let's make sure pip Is the installation successful , The results are shown below :

    pip 22.2 from /home/esp/.local/lib/python3.8/site-packages/pip (python 3.8)
    

    There is the information shown above , On behalf of pip Installation is successful , Then continue to execute ./install.sh Script , It turns out that /home/esp/.espressif/python_env/idf5.0_py3.8_env/bin/python: No module named pip Error of , Mingming pip It has been installed successfully , How can this error be reported here .

    Get into ESP-IDF Of python Environmental Directory ~/.espressif/python_env/idf5.0_py3.8_env/lib/python3.8, Found under this directory site-packages There is no pip The catalog of , guess ./install.sh What you really want to use in the script is Espressif Self defined python Catalog , Not in ubuntu Specified on python Catalog .

    After the above analysis , There is only one solution , stay Espressif Self defined python Catalog ~/.espressif/python_env/idf5.0_py3.8_env/lib/python3.8 Under the site-packages Middle mount pip that will do . Execute the following two commands :

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    
    /home/esp/.espressif/python_env/idf5.0_py3.8_env/bin/python3 get-pip.py
    

    Query after execution site-packages Catalog , It is found that there is already pip Catalog . And then execute it again ./install.sh The script can be .

原网站

版权声明
本文为[Embedded engineering lion]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207260840291517.html