esp32-arduino-lib-builder 构建您自己的编译库以在 Arduino IDE中使用 ubuntu
1.设置环境变量($IDF_PATH)
//如果你以安装esp-idf运行以下命令
. $HOME/esp/esp-idf/export.sh
在这之前需要安装Arduino IDE和ESP32 的 Arduino 内核(arduino-esp32)里面有安装说明
esp-idf官网安装步骤
如果你不安装也没关系,下面会自动帮你安装esp-idf
2.安装 esp32-arduino-lib-builder
//克隆esp32-arduino-lib-builder到主目录
1. git clone https://github.com/espressif/esp32-arduino-lib-builder
2. cd esp32-arduino-lib-builder
3. ./tools/update-components.sh
//如果您已经定义了 $IDF_PATH,它将使用您的本地存储库副本(没有将自动安装)
4. ./tools/install-esp-idf.sh
//生成
6. ./build.sh
esp32-arduino-lib-builder官方安装方法
build.sh会自动运行./tools/update-components.sh和./tools/install-esp-idf.sh
如果觉得慢可以修改build.sh将./tools/update-components.sh注释掉
如果在build过程中修改sdkconfig可以将build.sh中的idf.py menuconfig注释取消
修改前:
#!/bin/bash
if ! [ -x "$(command -v python)" ]; then
echo "ERROR: python is not installed! Please install python first."
exit 1
fi
if ! [ -x "$(command -v git)" ]; then
echo "ERROR: git is not installed! Please install git first."
exit 1
fi
mkdir -p dist
# update components from git
./tools/update-components.sh
if [ $? -ne 0 ]; then exit 1; fi
# install esp-idf and gcc toolchain
source ./tools/install-esp-idf.sh
if [ $? -ne 0 ]; then exit 1; fi
if [ -z $TARGETS ]; then
TARGETS="esp32c3 esp32s2 esp32"
fi
echo $(git -C $AR_COMPS/arduino describe --all --long) > version.txt
rm -rf out build sdkconfig sdkconfig.old
for target in $TARGETS; do
# configure the build for the target
rm -rf build sdkconfig sdkconfig.old
cp "sdkconfig.$target" sdkconfig
# uncomment next line to access menuconfig
idf.py menuconfig
# build and prepare libs
#idf.py build
if [ $? -ne 0 ]; then exit 1; fi
cp sdkconfig "sdkconfig.$target"
# build bootloaders
./tools/build-bootloaders.sh
if [ $? -ne 0 ]; then exit 1; fi
done
# archive the build
./tools/archive-build.sh
if [ $? -ne 0 ]; then exit 1; fi
#./tools/copy-to-arduino.sh
修改后:
#!/bin/bash
if ! [ -x "$(command -v python)" ]; then
echo "ERROR: python is not installed! Please install python first."
exit 1
fi
if ! [ -x "$(command -v git)" ]; then
echo "ERROR: git is not installed! Please install git first."
exit 1
fi
mkdir -p dist
# update components from git
#./tools/update-components.sh
if [ $? -ne 0 ]; then exit 1; fi
# install esp-idf and gcc toolchain
source ./tools/install-esp-idf.sh
if [ $? -ne 0 ]; then exit 1; fi
if [ -z $TARGETS ]; then
#TARGETS="esp32c3 esp32 esp32s2"
TARGETS="esp32"
fi
echo $(git -C $AR_COMPS/arduino describe --all --long) > version.txt
rm -rf out build sdkconfig sdkconfig.old
for target in $TARGETS; do
# configure the build for the target
rm -rf build sdkconfig sdkconfig.old
cp "sdkconfig.$target" sdkconfig
# uncomment next line to access menuconfig
idf.py menuconfig
# build and prepare libs
idf.py build
if [ $? -ne 0 ]; then exit 1; fi
cp sdkconfig "sdkconfig.$target"
# build bootloaders
./tools/build-bootloaders.sh
if [ $? -ne 0 ]; then exit 1; fi
done
# archive the build
./tools/archive-build.sh
if [ $? -ne 0 ]; then exit 1; fi
#./tools/copy-to-arduino.sh
我在build时无法生成esp32s2(esp32和esp32c3可以正常生成)
build生成好的文件在esp32-arduino-lib-builder/out/tools/sdk
运行tools/copy-to-arduino.sh可自动复制到Arduino IDE (目录$HOME/Arduino/hardware/espressif/esp32)中
最后需要将 .espressif/tools/xtensa-esp32-elf/ 下的 esp-2021r1-8.4.0/xtensa-esp32-elf 文件夹复制到Arduino/hardware/espressif/esp32/tools目录下替换原来的 xtensa-esp32-elf (如果不这样做Arduino IDE会编译失败)