安装
安装cargo工具
cargo install cargo-generate
安装stlink v2驱动
sudo apt-get install git make cmake libusb-1.0-0-dev
sudo apt-get install gcc build-essential
git clone https://github.com/stlink-org/stlink.git
cd stlink/
mkdir build
cd build
cmake ..
make
cd bin/
sudo cp st-* /usr/local/bin
cd ../lib/
sudo cp *.so* /lib32
cd ../../
sudo cp config/udev/rules.d/49-stlinkv* /etc/udev/rules.d/
安装烧录和调试的工具
Linux, macOS
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh
WIndows
irm https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.ps1 | iex
安装适用于ARM Cortex-M目标的rust-std组件
rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf
创建工程
cargo generate --git https://github.com/burrbull/stm32-template/
输入项目相关信息
根据自己的需求和芯片型号进行填写
字段 | 值 |
---|---|
Project Name | simple-stm32f4 |
What HAL version to use? | last-release |
Is it RTIC-based application? | false |
Will this program use defmt logger? | false |
What microcontroller name? | stm32f407vgt6 |
编译工程并烧录
进入项目目录
cd simple-stm32f4
执行编译&烧录命令:
cargo-flash --release --chip STM32F407VGTx
如果看到以下输出则表示编译烧录都正常了
其他配置
如果在启动串口时提示权限不足,可以将当前用户添加到dialout用户组中,然后重启电脑:
sudo usermod -a -G dialout username
安装JLInk
sudo apt-get -y install libjaylink-dev