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

结果成功

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

相关推荐
2023自学中7 小时前
make clean 与 make distclean
linux·嵌入式
栈时没有名字8 小时前
git仓库管理,commit或push上传服务器失败问题
git·嵌入式
CodeQingqing13 小时前
反汇编在嵌入式的使用
stm32·嵌入式·反汇编
济61716 小时前
FreeRTOS 控制任务设计 (3)--- 闭环控制验证:仿真电机模型与软反馈实现
嵌入式·freertos
凉、介17 小时前
C 语言类型强转引发的隐蔽内存破坏问题分析
c语言·开发语言·笔记·学习·嵌入式
嵌入式小企鹅2 天前
嵌入式面试宝典
学习·面试·嵌入式·嵌入式工程师·高薪offer
星瞳科技OpenMV2 天前
国家级高新技术企业星瞳科技,定义嵌入式机器视觉行业新标杆
人工智能·嵌入式·图像识别·机器视觉·openmv·星瞳科技·星瞳科技openmv
Hello_Embed2 天前
【无标题】
网络·笔记·网络协议·tcp/ip·嵌入式
XD7429716362 天前
001. MSP430G2553 入门总述:从零开始学习这颗单片机
单片机·嵌入式硬件·学习·嵌入式·msp430g2553
CinzWS2 天前
A53 FPGA原型验证:从RTL到可运行系统的挑战
arm开发·嵌入式·芯片验证·原型验证·a53