ESP8266在Ubuntu下的环境搭建

Setup Toolchain(Ubuntu)

sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial
download: https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-92-g8facf4c-5.2.0.tar.gz

1.Download this file, then extract it in ~/esp directory:

mkdir -p ~/esp
cd ~/esp
tar -xzf ~/Downloads/xtensa-lx106-elf-linux64-1.22.0-92-g8facf4c-5.2.0.tar.gz

2.The toolchain will be extracted into ~/esp/xtensa-lx106-elf/ directory.
To use it, you will need to update your PATH environment variable in ~/.profile file. To make xtensa-lx106-elf available for all terminal sessions, add the following line to your ~/.profile file:
export PATH="$PATH:$HOME/esp/xtensa-lx106-elf/bin
Alternatively, you may create an alias for the above command. This way you can get the toolchain only when you need it. To do this, add different line to your ~/.profile file:
vi ~/.profile file
add this linealias get_lx106='export PATH="$PATH:$HOME/esp/xtensa-lx106-elf/bin"'


我的PATH的添加

xan@xan:~/esp/xtensa-lx106-elf/bin$ pwd
/home/xan/esp/xtensa-lx106-elf/bin
xan@xan:~/esp/xtensa-lx106-elf/bin$ PATH=$PATH:$(pwd)
xan@xan:~/esp/xtensa-lx106-elf/bin$echo $PATH

在这里插入图片描述

3.Log off and log in back to make the .profile changes effective. Run the following command to verify if PATH is correctly set:

printenv PATH

You are looking for similar result containing toolchain’s path at the end of displayed string:

$ printenv PATH
display/home/user-name/bin:/home/user-name/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

Get ESP8266_RTOS_SDK

Besides the toolchain (that contains programs to compile and build the application), you also need ESP8266 specific API / libraries. They are provided by Espressif in ESP8266_RTOS_SDK https://github.com/espressif/ESP8266_RTOS_SDK repository.

To obtain a local copy: open terminal, navigate to the directory you want to put ESP8266_RTOS_SDK, and clone the repository using git clone command:
cd ~/esp
git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git

Setup Path to ESP8266_RTOS_SDK

The toolchain programs access ESP8266_RTOS_SDK using IDF_PATH environment variable. This variable should be set up on your PC, otherwise projects will not build. Setting may be done manually, each time PC is restarted. Another option is to set up it permanently by defining IDF_PATH in user profile.

xan@xan:~/esp/project_template$vi Makefile 

add
ESP8266在Ubuntu下的环境搭建_第1张图片

Install the Required Python Packages

Python packages required by ESP8266_RTOS_SDK are located in the $IDF_PATH/requirements.txt file. You can install them by running:
python -m pip install --user -r $IDF_PATH/requirements.txt

note

请调用将与ESP8266_RTOS_SDK一起使用的那个版本的Python解释器。可以通过运行命令python -version来检查解释器的版本,并且根据结果,你可能想要使用python2,python2.7或类似的而不是python,例如:

python2.7 -m pip install --user -r $IDF_PATH/requirements.txt

Start a Project

Copy get-started/project_template to ~/esp directory:

cd ~/esp
cp -r $IDF_PATH/examples/get-started/project_template .
使用这个解决环境变量问题
python2.7 -m pip install --user -r requirements.txt
在project_template下
vi Makefile
添加IDF_PATH=/home/xan/esp/ESP8266_RTOS_SDK

Connect & Configure

cd ~/esp/project_template
make menuconfig
编译project_template
make
ESP8266在Ubuntu下的环境搭建_第2张图片

Build and Flash

打开工程目录
make flash,编译并烧录进esp8266,
a) 出现Connecting…时,将GPIO5脚拉低,才可连接上
b) 烧录完成后,将GPIO5脚复位,才能正常启动
ESP8266在Ubuntu下的环境搭建_第3张图片

Monitor

To see if “project_template” application is indeed running, type make monitorESP8266在Ubuntu下的环境搭建_第4张图片

https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html

你可能感兴趣的:(ubuntu)