文章和参考
- 官方文档 https://docs.rust-embedded.org/book/intro/install/windows.html
第一步 安装交叉编译器
- 我下载的是最新版本的交叉编译器和编译工具 https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.exe 可能是网络不好吧,我这失败了好几次。下载过后进行安装,同样修改了路径,最后不要忘记最后一步选择“添加到环境变量”
2. 试下环境变量是否生效
安装QEMU(模拟器)
- 网址是
新建工程
1. cargo install cargo-generate
江湖惯例出现了问题
一顿操作,芭比Q了,需要付费板。使用免费的吧
2. 使用git 创建工程
git clone https://github.com/rust-embedded/cortex-m-quickstart app
cd app
- 添加工程信息
[package]
authors = ["{{authors}}"] # "{{authors}}" -> "John Smith"
edition = "2018"
name = "{{project-name}}" # "{{project-name}}" -> "app"
version = "0.1.0"
# ..
[[bin]]
name = "{{project-name}}" # "{{project-name}}" -> "app"
test = false
bench = false
3.编译一下
3.1 cargo build --target thumbv7m-none-eabi (M3内内核的数据)
处理报错:
PS D:\app> rustup target add thumbv7m-none-eabi
info: downloading component 'rust-std' for 'thumbv7m-none-eabi'
info: installing component 'rust-std' for 'thumbv7m-none-eabi'
3.2 cargo build --target thumbv7m-none-eabi (M3内内核的数据)编译通过了
4.安装binutil
cargo install cargo-binutils
//安装时真的慢
cargo readobj --bin app -- --file-headers
//查看下环境
PS D:\app> cargo readobj --bin hello -- --file-headers
Finished dev [unoptimized + debuginfo] target(s) in 0.19s
Could not find tool: readobj
at: C:\Users\Administrator\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\llvm-readobj.exe
Consider `rustup component add llvm-tools-preview`
- 安装rustup
rustup component add llvm-tools-preview
6 .执行程序
D://qemu/qemu-system-arm.exe -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel target/thumbv7m-none-eabi/debug/hello
Timer with period zero, disabling
Hello, world!
至此编译环境基本通了,等下下一次开发吧