主要内容
在 macOS 上安装 esp32-s3 开发环境 (std版)
std和no_std
- 包含标准库,即乐鑫官方提供的基于C的开发框架
ESP-IDF- 丰富的功能: 可以访问 ESP-IDF 中存在的许多功能,包括线程、互斥锁和其他同步原语、集合、随机数生成、套接字等
- 可移植性
- 快速开发
- 不包含标准库,裸机开发, 但是可以使用
core库中的功能- 内存占用小
- 直接的硬件控制
- 实时性约束或时间关键型应用
- 自定义需求
S3芯片
- 内核:搭载低功耗 Xtensa® LX7 32 位双核处理器
- 主频:最高 240 MHz
- SRAM: 512 KB _ 片外 RAM:8 MB PSRAM
- 嵌入式 flash:4 MB SPI Flash
- 外部 flash:16 MB Flash
安装rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装工具链
针对 RISC-V & Xtensa (S3 是 Xtensa 架构)
# Use `espup` to
# 1. add targets for ESP32-S3
# 2. install nightly toolchain
# 3. install LLVM branch for Xtensa
cargo install espup
# Use "-s" to skip GCC installation
espup install -s
std 依赖
# Install cargo-binutils
brew install cmake ninja dfu-tuil
# If not installed or outdated
brew install python
# Forward linker arguments to the actual linker executable
# https://github.com/esp-rs/embuild/tree/master/ldproxy
cargo install ldproxy
# A library and command-line tool for flashing Espressif devices.
# https://github.com/esp-rs/espflash
cargo install espflash
创建项目
使用 cargo-generate 生成模版项目
cargo install cargo-generate
# Template for `std` version
# https://github.com/esp-rs/esp-idf-template
cargo generate esp-rs/esp-idf-template cargo
运行
# Check the serial port
ls /dev/cu.usbmodem*
# Check the board info
espflash board-info
# Flash the program
cargo run
最后应该可以在终端内看到输出
...
I (401) main_task: Started on CPU0
I (411) main_task: Calling app_main()
I (411) esp32_s3: Hello, world!
I (411) main_task: Returned from app_main()
...
其他
- 对于
std版本,esp-idf-sys会自动安装esp-idf,可以不需要手动安装esp-idf。- 所以只需要Linux 和 macOS 平台工具链的标准设置的第一步即可。
评论