esp32-arduino-lib-builder构建自己的编译库在Arduino IDE中使用

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会编译失败)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值