ESP8266开发环境搭建
乐鑫官方配置教程
ESP8266官方编程手册
一、下载ESP8266_RTOS_SDK源码
(1)推荐方式
- 这里使用了徐宏大佬同步到gitee 的乐鑫仓库,下载速度快一些,先不拉取子模块,git 指令如下:
git clone https://gitee.com/xuhongv/esp-idf.git
- 记事本打开
.gitmodules
,全部替换为下面内容:
#
# All the relative URL paths are intended to be GitHub ones
# For Espressif's public projects please use '../../espressif/proj', not a '../proj'
#
[submodule "components/esptool_py/esptool"]
path = components/esptool_py/esptool
url = https://gitee.com/xuhongv/esptool.git
[submodule "components/bt/controller/lib"]
path = components/bt/controller/lib
url = https://gitee.com/xuhongv/esp32-bt-lib.git
[submodule "components/bootloader/subproject/components/micro-ecc/micro-ecc"]
path = components/bootloader/subproject/components/micro-ecc/micro-ecc
url = https://gitee.com/xuhongv/micro-ecc.git
[submodule "components/coap/libcoap"]
path = components/coap/libcoap
url = https://gitee.com/xuhongv/libcoap.git
[submodule "components/nghttp/nghttp2"]
path = components/nghttp/nghttp2
url = https://gitee.com/xuhongv/nghttp2.git
[submodule "components/libsodium/libsodium"]
path = components/libsodium/libsodium
url = https://gitee.com/xuhongv/libsodium.git
[submodule "components/spiffs/spiffs"]
path = components/spiffs/spiffs
url = https://gitee.com/xuhongv/spiffs.git
[submodule "components/json/cJSON"]
path = components/json/cJSON
url = https://gitee.com/xuhongv/cJSON.git
[submodule "components/mbedtls/mbedtls"]
path = components/mbedtls/mbedtls
url = https://gitee.com/xuhongv/mbedtls.git
[submodule "components/asio/asio"]
path = components/asio/asio
url = https://gitee.com/xuhongv/asio.git
[submodule "components/expat/expat"]
path = components/expat/expat
url = https://gitee.com/xuhongv/libexpat.git
[submodule "components/lwip/lwip"]
path = components/lwip/lwip
url = https://gitee.com/xuhongv/esp-lwip.git
[submodule "components/mqtt/esp-mqtt"]
path = components/mqtt/esp-mqtt
url = https://gitee.com/xuhongv/esp-mqtt.git
[submodule "components/protobuf-c/protobuf-c"]
path = components/protobuf-c/protobuf-c
url = https://gitee.com/xuhongv/protobuf-c.git
[submodule "components/unity/unity"]
path = components/unity/unity
url = https://gitee.com/xuhongv/Unity.git
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
url = https://gitee.com/xuhongv/tinyxml2.git
[submodule "components/bt/host/nimble/nimble"]
path = components/bt/host/nimble/nimble
url = https://gitee.com/xuhongv/esp-nimble.git
[submodule "components/cbor/tinycbor"]
path = components/cbor/tinycbor
url = https://gitee.com/xuhongv/tinycbor.git
[submodule "components/esp_wifi/lib"]
path = components/esp_wifi/lib
url = https://gitee.com/xuhongv/esp32-wifi-lib.git
[submodule "components/tinyusb/tinyusb"]
path = components/tinyusb/tinyusb
url = https://gitee.com/xuhongv/tinyusb.git
[submodule "examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib"]
path = examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib
url = https://gitee.com/xuhongv/esp-cryptoauthlib.git
[submodule "components/cmock/CMock"]
path = components/cmock/CMock
url = https://gitee.com/xuhongv/CMock.git
- 更新子模块,进入ESP8266_RTOS_SDK文件夹下,git指令如下:
git submodule update --init --recursive
(2)官方方式
使用子模块递归方式拉取GitHub仓库,慢的要命,
但还是记录一下,指令如下:
git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git
二、下载预制编译环境和工具链
-
预制编译环境
下载完成后解压到自定义目录,文件夹名
msys32
https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_esp2020r2_toolchain-20200601.zip
-
工具链
点击下方地址进入,查看Readme,选择适合自己的平台下载
ESP8266_RTOS_SDK
我下载的是:xtensa-lx106-elf-win32-1.22.0-100-ge567ec7-5.2.0.zip
解压后将xtensa-lx106-elf
整个放到\msys32\opt
路径下
三、添加工具链路径
找到\msys32\etc\profile.d\esp32_toolchain.sh
这个文件,
记事本打开,修改内容,下面是我的路径,需要根据你自己的路径做修改:
# This file was created by ESP-IDF windows_install_prerequisites.sh
# and will be overwritten if that script is run again.
export PATH="$PATH:/opt/xtensa-lx106-elf/bin"
export IDF_PATH="D:/ESP-IDF/msys32/home/William/ESP8266_RTOS_SDK"
四、编译测试
双击mingw32.exe
,第一次打开会初始化home
文件夹内容
从ESP8266_RTOS_SDK\examples\
复制一个例程出来,编译就行了。
make all