正如标题所言,Rust 已经启动起来了,
前几天(半年了)已经占贴 了关于使用 Rust 来写嵌入式,搁置了许久,来一期环境配置。环境配置相比于ESP32来说没有多大的区别,主要是用好 手里的板子,让他 blink。(我在 ESP3写了不少blink led 的代码,手上还有一块Ch32v307的板子,发现也可以blink led )
用到的工具主要有
Windows 的 WSL /Linux/Mac
烧录工具 wchisp wlink
IDE notepad /nvim
AGI CHATGPT
Windows 下的配置
第一部分 WSL 安装 rust 的安装
可以参阅 这里 ,可以观看环境里面的部分安装。
(我使用的是Arch linux ,如果碰见安装命令不同可以尝试询问CHATGPT)
WSL USB Manager
Rust 工具链的配置
rustup toolchain install nightly --component rust-src
cargo install --git https://github.com/ch32-rs/wlink
cargo install cargo-generate
cargo install wchisp --git https://github.com/ch32-rs/wchisp
OR cargo install wchisp --force
5.
❯ wlink status
Error: USB error: Access denied (insufficient permissions)
Caused by:
Access denied (insufficient permissions)
~
❯ wlink status
Error: USB error: Access denied (insufficient permissions)
Caused by:
Access denied (insufficient permissions)
~
❯ sudo wlink status
[sudo] password for s413:
sudo: wlink: command not found
~
❯ ls -l /dev/ttyACM0
crw-rw---- 1 root uucp 166, 0 Aug 31 16:15 /dev/ttyACM0
~
❯ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 1a86:8010 QinHeng Electronics WCH-Link
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
~
❯ groups $USER
wheel uucp docker s413
~
❯ wlink status
Error: USB error: Access denied (insufficient permissions)
Caused by:
Access denied (insufficient permissions)
~
❯ sudo nvim /etc/udev/rules.d/99-usb-serial.rules
写入 SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8010", MODE="0666", GROUP="uucp"
~
❯ sudo udevadm control --reload-rules
sudo udevadm trigger
~
❯ ls -l /dev/ttyACM0
crw-rw---- 1 root uucp 166, 0 Aug 31 16:19 /dev/ttyACM0
~
❯ wlink status
08:19:54 [INFO] Connected to WCH-Link v2.11(v31) (WCH-LinkE-CH32V305)
08:19:54 [INFO] Attached chip: CH32V30X [CH32V307VCT6] (ChipID: 0x30700528)
08:19:54 [INFO] Chip ESIG: FlashSize(288KB) UID(af-d0-be-7b-54-50-c1-9c)
08:19:54 [INFO] Flash protected: false
08:19:54 [INFO] RISC-V ISA(misa): Some("RV32ACFIMUX")
08:19:54 [INFO] RISC-V arch(marchid): Some("WCH-V4A")
08:19:54 [WARN] The halt status may be incorrect because detaching might resume the MCU
08:19:54 [INFO] Dmstatus {
.0: 0x382,
allhavereset: false,
anyhavereset: false,
allresumeack: false,
anyresumeack: false,
allunavail: false,
anyunavail: false,
allrunning: false,
anyrunning: false,
allhalted: true,
anyhalted: true,
authenticated: true,
version: 0x2,
}
08:19:54 [INFO] Dmcontrol {
.0: 0x80000001,
haltreq: true,
resumereq: false,
ackhavereset: false,
ndmreset: false,
dmactive: true,
}
08:19:54 [INFO] Hartinfo {
.0: 0x312380,
nscratch: 0x3,
dataaccess: true,
datasize: 0x2,
dataaddr: 0x380,
}
08:19:54 [INFO] Abstractcs {
.0: 0x8000002,
progbufsize: 0x8,
busy: false,
cmderr: 0x0,
datacount: 0x2,
}
08:19:54 [INFO] haltsum0: 0x
一般来说,配置环境最大的问题是网络,各位注意准备好自己的网络哦!
附图
参考 https://github.com/ch32-rs