esp8266-window7-environment-installation

esp8266 window7开发环境搭建

最新代码

https://github.com/espressif/ESP8266_RTOS_SDK

安装toolchain

下载msys32

在windows环境下我们需要msys32,在linux不需要

https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain-20181001.zip

下载8266对应的toolchain

在默认的msys下是没有8266的toolchain的,我们需要下载:

https://dl.espressif.com/dl/xtensa-lx106-elf-gcc8_4_0-esp-2020r3-win32.zip

将解压后的xtensa-lx106-elf放到/msys32/opt/下

安装python环境

# python -m pip install --user -r $IDF_PATH/requirements.txt
Requirement already satisfied: setuptools in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 4)) (40.4.3)
Collecting click>=5.0 (from -r requirements.txt (line 8))
  Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB)
    49% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                | 40kB 450kB/s eta 0:00    61% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒            | 51kB 248kB/s eta     74% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒        | 61kB 296kB/s     86% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    | 71kB 344k    98% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒| 81kB     100% |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒| 92kB 385kB/s
Requirement already satisfied: pyserial>=3.0 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 9)) (3.4)
Requirement already satisfied: future>=0.15.2 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 10)) (0.16.0)
Requirement already satisfied: cryptography>=2.1.4 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 11)) (2.3.1)
Requirement already satisfied: pyparsing<2.4.0,>=2.0.3 in g:/msys32/mingw32/lib/python2.7/site-packages (from -r requirements.txt (line 12)) (2.2.0)
Collecting pyelftools>=0.22 (from -r requirements.txt (line 13))
  Using cached https://files.pythonhosted.org/packages/6f/50/3d7729d64bb23393aa4c166af250a6e6f9def40c90bf0e9af3c5ad25b6f7/pyelftools-0.27-py2.py3-none-any.whl
Requirement already satisfied: idna>=2.1 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (2.7)
Requirement already satisfied: asn1crypto>=0.21.0 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (0.24.0)
Requirement already satisfied: six>=1.4.1 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.11.0)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.10.0)
Requirement already satisfied: enum34 in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.1.6)
Requirement already satisfied: ipaddress in g:/msys32/mingw32/lib/python2.7/site-packages (from cryptography>=2.1.4->-r requirements.txt (line 11)) (1.0.22)
Requirement already satisfied: pycparser in g:/msys32/mingw32/lib/python2.7/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.1.4->-r requirements.txt (line 11)) (2.19)
Installing collected packages: click, pyelftools
Successfully installed click-7.1.2 pyelftools-0.27

编译工程

设置环境变量

因为我们使用的是msys32的虚拟环境,所以我们只要设置msys32的虚拟环境变量即可,不需要设置windows的环境变量。这样正好可以让我们在window系统下同时兼容esp32和esp8266的开发环境。
修改/home/xxx[用户]/.bashrc

新增:

export IDF_PATH=~/esp/ESP8266_RTOS_SDK
export PATH=/opt/xtensa-lx106-elf/bin:$PATH

检验环境变量:
重新打开mingw32.exe,执行

xtensa-lx106-elf-gcc -v
# xtensa-lx106-elf-gcc -v
Using built-in specs.
COLLECT_GCC=G:\msys32\opt\xtensa-lx106-elf\bin\xtensa-lx106-elf-gcc.exe
COLLECT_LTO_WRAPPER=g:/msys32/opt/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/8.4.0/lto-wrapper.exe
Target: xtensa-lx106-elf
Configured with: /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=i686-host_w64-mingw32 --target=xtensa-lx106-elf --prefix=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf --with-headers=/builds/idf/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG esp-2020r3-49-gd5524c1' --disable-__cxa_atexit --enable-cxx-flags=-ffunction-sections --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-mpfr=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-mpc=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --with-isl=/builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-lx106-elf/buildtools/complibs-host --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-libstdcxx-time=yes
Thread model: posix
gcc version 8.4.0 (crosstool-NG esp-2020r3-49-gd5524c1)

下载最新代码

务必git pull,不要zip解压,windows下很多隐藏文件容易出问题

git pull https://github.com/espressif/ESP8266_RTOS_SDK.git

menuconfig

进入需要编译的工程例子目录

make menuconfig

进行必要的配置。为了接下来的下载,我们需要配置串口:Serial flasher config > Default serial port,根据实际的串口来配置。

On Windows, serial ports have names like COM1. On MacOS, they start with /dev/cu.. On Linux, they start with /dev/tty

编译

make

# make
Toolchain path: /opt/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
Toolchain version: esp-2020r3-49-gd5524c1
Compiler version: 8.4.0
Python requirements from G:/msys32/home/zcj/esp/ESP8266_RTOS_SDK/requirements.txt are satisfied.
App "wifi_softAP" version: v3.4-28-g08e225dd
To flash all build output, run 'make flash' or:
python /home/zcj/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 2MB 0x0 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/bootloader/bootloader.bin 0x10000 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/wifi_softAP.bin 0x8000 /home/zcj/esp/ESP8266_RTOS_SDK/examples/wifi/getting_started/softAP/build/partitions_singleapp.bin

编译 & 下载

make flash

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注