ubuntu system development environment to build ESP32

Foreword

ESP32 of things can be said that a relatively lean and market the chip. BLE and integrated 802.11b Wi-Fi. Low power consumption, processing speed is quite strong. Currently it is also just start ESP32. But when installed in the environment, step on a lot of the pit.
Of course ESP32 support the development of a lot of ways. For example, in arduino development, msys32 under windows add esp-idf development environment (because msys32 is a linux virtual environment, so this way the compiler will be slow), you can also use Eclipse IDE + CMake + esp-idf development, but also there may use GNU Make + esp-idf develop a linux system.
I am using a development environment linux system. Here is not pulled, it can start to fill the pit road.
Installation environment of the main reference <Lexin's official website> .
(Note: Because during the installation environment need to download more libraries and tools, so to ensure smooth network)

First, install ready

  • Here is the use of linux releaseubuntu 16.04 LTS
  • There are basic needs of the environment python2and gittools (without these tools can be installed Baidu)
  • mkdir -p ~/esp32/source ~/esp32/crossTool ~/esp32/demos Use this command to create all of these directories

1, update ubuntu source

  1. To back normal installation tools, the best source to update it. It is best to switch the source for domestic sources. ubuntu system is the following command to update the source, other Linux distributions can Baidu update:
  • sudo apt-get install update
  1. Because the process of installing esp32 environment need to install python libraries, so here it is best to pip tool update to the latest version. The latest version is 19.3.1, use the following command to update, if not the latest version generally able to update properly.
  • sudo python -m pip install --default-timeout=100 --upgrade pip

2, error handling:

After pip tool update to the latest version, use the pip install 安装包possible following error:

  # 错误的原因是新版本的库找不到 main 模块了
  Traceback (most recent call last): 
  File "/usr/bin/pip", line 9, in <module>
  from pip import main
ImportError: cannot import name 'main'

The solution is to modify the /usr/bin/pipsource code
with the sudo vi /usr/bin/pipcommand to open the source code
and modify the following way, after you modify the error will not be a

################修改前程序####################

import sys
from pip import main  
if __name__ == '__main__':  
    sys.exit(main())

################修改前程序####################



################修改后程序####################

import sys
from pip import __main__  # 这行修改
if __name__ == '__main__':
    sys.exit(__main__._main()) #这行修改

################修改后程序####################

3, installation dependencies

In <Lexin's official website> in the mentioned ununtusystem (or other system can view the release Quguan network) need to install the following dependencies. Execute the following command to, or go to the official website to view.

sudo apt-get install gcc git wget make flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing python-pyelftools

Second, cross-tool

1, the cross download tool (xtensa-esp32-elf)

<Lexin's official website> This page has cross tool download link, if following this link to the download can not be copied Quguan network, and then replace the link below (note that your system is 32 or 64-bit systems). Then execute the following command to download. (Try to download the latest official stable of tools and libraries)

  1. cd ~/esp32/crossTool/
  2. wget -c https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz
  3. tar zxvf xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz Specific package name to download prevail

2, set the crossover tool environment variables

Perform the following steps to set environment variables
1, using the sudo vi ~/.profilecommand to open this file
2, in .profilethe last line add export PATH="$HOME/esp32/crossTool/xtensa-esp32-elf/bin:$PATH"
3, execute rebootthe command to restart the system after the restart cross-tools environment variable onset of
4, echo $PATHlook at the success has not set

Third, the source library download

1, download the source code repository (esp-idf)

  • <Lexin's official website> have link library esp-idf, if not visit the link below, you can go to the official website to view, or on their own to githubsearch esp-idflibrary and then download.
  • Note: The gitdownload time must be added --recursiveoption, because after downloading the library also download more dependent seeds. If the download does not depend on the seed, then I will report back when compiling all sorts of strange errors such as: Can not find micro-eccthe directory and the like. If you do not add --recursivethe option, you need to perform after downloading cd ~/esp32/source/and git submodule update --initcommand.
  • Execute the following command to download esp-idfthe source code library
    1. cd ~/esp32/source/
    2. git clone --recursive https://github.com/espressif/esp-idf.git

2, set the environment variable

Perform the following steps to set esp-idfthe circulation environment becomes
1, a sudo vi ~/.profilecommand to open the file
2, in the .profilelast row was added export IDF_PATH="$HOME/esp32/source/esp-idf"
3, a rebootcommand to reset the system reboot tool environment variable cross onset of
4, echo $IDF_PATHto see if there is an provided successful

Fourth, the installation Python packages

In this process, almost desperate, could lead to a network is not good then download the package download time-out is always a failure. After it has been tried dozens of times, and eventually to fill the pit. Here to tell us about ways to fill the pit.

1, the official installation method

The official was executed the following command to install. In this process, individuals can only be at one or two in front of the package, and then they reported a timeout failure. Try dozens of times over, and finally I gave up. If you can at all do not have to perform the following installation is complete solution to the

  • python -m pip install --user -r $IDF_PATH/requirements.txt

2, a solution

On the basis of the official to increase the timeout limit. Command is as follows:

  • python -m pip install --default-timeout=100 --user -r $IDF_PATH/requirements.txt
  • Although the increase in the timeout limit, but still reported a timeout exception. And in this way the installation has a drawback, is reported after a timeout exception, after all again the next attempt to re-download. Of course, if successful, you can download finished. After they went through dozens of times, I really desperate. Then decisively abandoned this approach.

3, two solutions

The second method is to look at $IDF_PATH/requirements.txtwhat the role of file yes. Contents of the file are as follows

# This is a list of python packages needed for ESP-IDF. This file is used with pip.
# Please see the Get Started section of the ESP-IDF Programming Guide for further information.
#
#查看 setuptools 软件包的版本是否大于或者等于 21
setuptools>=21
# The setuptools package is required to install source distributions and on some systems is not installed by default.
# Please keep it as the first item of this list. Version 21 is required to handle PEP 508 environment markers.
#

click>=5.0  #比较 click 软件包的版本是否大于或者等于 5.0
pyserial>=3.0  #比较 pyserial 软件包的版本是否大于或者等于 3.0
future>=0.15.2 #比较 future 软件包的版本是否大于或者等于 0.15.2
cryptography>=2.1.4 #比较 cryptography 软件包的版本是否大于或者等于 2.1.4
pyparsing>=2.0.3,<2.4.0 #比较 pyparsing软件包的版本是否大于或者等于 2.0.3 并且 小于 2.4.0
pyelftools>=0.22 #比较 pyelftools 软件包的版本是否大于或者等于 0.22
# windows-curses are required in Windows command line but cannot be installed in MSYS2. A requirement like
# "windows-curses; sys_platform == 'win32'" would want to install the package on both of them. There is no environment
# marker for detecting MSYS2. So instead, a dummy custom package is used with "windows-curses" dependency for Windows
# command line.
file://${IDF_PATH}/tools/kconfig_new/esp-windows-curses; sys_platform == 'win32'

After learned about the contents of this file is to use commands one by one update, though some packages still download times out, but at least part of the normal installation. The installation command is as follows:

  1. sudo pip install --default-timeout=100 --upgrade setuptools
  2. sudo pip install --default-timeout=100 --upgrade click
  3. sudo pip install --default-timeout=100 --upgrade pyserial
  4. sudo pip install --default-timeout=100 --upgrade future
  5. sudo pip install --default-timeout=100 --upgrade cryptography
  6. sudo pip install --default-timeout=100 --upgrade pyparsing
  7. sudo pip install --default-timeout=100 --upgrade pyelftools

If the above steps can be properly installed, and then execute it in the following command, look at the version is correct or not any less of what does not depend on the library, if all the checks pass, and it shows no download process environment to build complete. If there is a software package download time-out, you can look down to see the "Resolution Three"

  • python -m pip install --user -r $IDF_PATH/requirements.txt

3, three solutions

This last approach is a way, if not to solve this, I will find no way out. The idea is to Python packages official website to download the offline package to install. Python package directly above the official online search methods have not been able to complete, and then download the corresponding version (this can be seen in the course of the above methods downloaded), and then use a browser to download it.
Here I cryptographypackage as an example:

  • I downloaded the command line in the process of downloading the cryptography-2.8-cp27-cp27mu-manylinux2010_x86_64version, so I chose cryptography 2.8the version, as shown below:
  • Find cryptography-2.8-cp27-cp27mu-manylinux2010_x86_64.whlpackages and then download

After downloading the find in the local cryptography-2.8-cp27-cp27mu-manylinux2010_x86_64.whl(usually in the ~/Downloads/directory) is installed, and then execute the following command:

  • sudo pip install --default-timeout=100 ~/Downloads/cryptography-2.8-cp27-cp27mu-manylinux2010_x86_64.whl
  • python -m pip install --user -r $IDF_PATH/requirements.txt Check there is no need to install

The above method should be able to experience the complete package python by turn

Fifth, the compiler first demo

编译和烧写的过程可以参考乐鑫官网,这里就不过多介绍了,上面的的环境都安装成功了,一般都能正确编译。烧写的过程可能需要改一下串口的权限。环境装好了,剩下就靠自己去怎么耍了。如果个人以后做了什么比较好玩的demo也会更新上来。

Guess you like

Origin www.cnblogs.com/gulan-zmc/p/11992359.html