rust 嵌入式esp23 《hello word》

学习rust嵌入式之esp32单片机,从打印hello word开发。 rust 嵌入式 ESP23

搭建环境:

相关连接:docs.espressif.com/projects/ru...

安装rust www.rust-lang.org/zh-CN/tools... 验证是否安装成功:

shell 复制代码
cargo -V

安装espup

shell 复制代码
cargo install espup --locked

espup 安装相关依赖

shell 复制代码
espup install

安装ldproxy 相关配置

shell 复制代码
cargo install ldproxy

安装esp-generate项目生成工具:

shell 复制代码
cargo install esp-generate

运行项目:

构建项目代码 (your-project)自定义项目名称

js 复制代码
esp-generate --chip=esp32c6 your-project

项目结构

file 复制代码
├── build.rs
├── .cargo
│   └── config.toml
├── Cargo.toml
├── .gitignore
├── rust-toolchain.toml
├── src
│   ├── bin
│   │   └── main.rs
│   └── lib.rs
└── .vscode
    └── settings.json

修改src/bin/main.rs的代码

rs 复制代码
#![no_std]
#![no_main]
#![deny(
    clippy::mem_forget,
    reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
    holding buffers for the duration of a data transfer."
)]

use esp_hal::{
    clock::CpuClock,
    main,
    time::{Duration, Instant},
};
use esp_println::println;

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
    loop {
        println!("111 world!");
        println!("Panic!");
    }
}

// This creates a default app-descriptor required by the esp-idf bootloader.
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();

#[main]
fn main() -> ! {
    // generator version: 0.5.0
    let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
    let _peripherals = esp_hal::init(config);

    loop {
        println!("hello world!");
        let delay_start = Instant::now();
        while delay_start.elapsed() < Duration::from_millis(500) {}
    }

    // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-rc.0/examples/src/bin
}

插入esp32设备连接电脑usb

运行项目

shell 复制代码
cargo run

结果成功

!如果未插入设备标识运行成功但是没有烧录

相关推荐
tom021814 小时前
软考中级《嵌入式系统设计师》全套备考资料(真题 + 教材 + 笔记)
笔记·嵌入式·软考·自学·电子技术·电子资料·变成
番茄灭世神19 小时前
PN学堂GD32教程第21篇——WiFiIOT
c语言·stm32·单片机·嵌入式·gd32
NPE~1 天前
[嵌入式]嵌入式在线仿真平台 —— Wokwi 入门指南
stm32·嵌入式·esp32·教程·平台
番茄灭世神1 天前
Vscode开发/调试ARM单片机最新教程
c语言·arm开发·vscode·stm32·嵌入式·gd32
lularible2 天前
从沙子到车辙(3.3):数据通路与控制器的“双人舞“
开源·嵌入式·汽车电子
lularible2 天前
从沙子到车辙(3.5):存储层次
开源·嵌入式·汽车电子
lularible2 天前
从沙子到车辙(3.4):流水线——指令级并行的艺术
开源·嵌入式·汽车电子
lularible2 天前
从沙子到车辙(3.1):组合逻辑——没有记忆的计算
开源·嵌入式·汽车电子
济6172 天前
ROS开发专栏---创建软件包 和编写第一个节点---适配Ubuntu 22.04
嵌入式·ros2·机器人方向
Jason_zhao_MR2 天前
RK3576 MIPI Camera ISP调试:主观调优与工程实战(下)
stm32·嵌入式硬件·安全·系统架构·嵌入式