ZEPHYR ESP32环境搭建

本文详细介绍了如何在Ubuntu16.04或14.04系统上为ESP32平台编译Zephyr实时操作系统。从环境搭建、软件安装到编译工具链配置,直至完成hello_world示例的编译与固件烧录,为开发者提供了全面的指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方推荐 Ubuntu 16.04 操作系统,经测试,Ubuntu 14.04 也可以编译运行成功。本文档是基于16.04 64位操作系统编译。
Git zephyr库
git clone https://github.com/zephyrproject-rtos/zephyr.git
更新操作系统
Sudo apt-get update
Sudo apt-get upgrade
安装所依赖的软件
sudo apt-get install –no-install-recommends git cmake ninja-build gperf \ ccache doxygen dfu-util device-tree-compiler \ python3-ply python3-pip python3-setuptools xz-utils file make gcc-multilib \ autoconf automake libtool

cd ~/zephyr # or to your directory where zephyr is cloned
pip3 install –user -r scripts/requirements.txt
Cmake的版本需求要在3.8.2或者之上,本文档使用的是3.8.2,如果你版本低于3.8.2
mkdir HOME/cmake && cd HOME/cmake && cd HOME/cmake
wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.sh
yes | sh cmake-3.8.2-Linux-x86_64.sh | cat
echo “export PATH= PWD/cmake3.8.2Linuxx8664/bin:$PATH">> P W D / c m a k e − 3.8.2 − L i n u x − x 86 6 4 / b i n : $ P A T H ">> HOME/.zephyrrc
source /zephyr-env.sh
cmake –version
二、 安装编译器
下载ESP32编译工具
https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
mkdir -p ~/esp
cd ~/esp
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
设置环境变量
export PATH=” PATH: P A T H : HOME/esp/xtensa-esp32-elf/bin”
下载SDK
cd ~/esp
https://github.com/espressif/esp-idf.git中下载最新版本,如果出错则在
https://github.com/espressif/esp-idf/releases中下载esp-idf-v3.0-rc1.zip版本(该版本名字不一样设置环境变量的时候要注意),下载完后解压
或者直接git clone –recursive https://github.com/espressif/esp-idf.git

设置环境变量
export ZEPHYR_TOOLCHAIN_VARIANT=”espressif”
export ESP_IDF_PATH=”/path/to/esp-idf”
export ESPRESSIF_TOOLCHAIN_PATH=”/path/to/xtensa-esp32-elf/”
/path/to/请根据PWD来填写
三、 编译hello_world
cd $ZEPHYR_BASE/samples/hello_world
mkdir build && cd build
cmake -GNinja -DBOARD=esp32 ..
ninja flash
进入zephyr里面找到zephyr.bin,下载到开发板中就OK了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值