測試環境
- VM虛拟機Ubuntu20
- 基于STM32F103C8T6的開發闆
- J-LINK(V9版本)使用SWD調試口和CDC序列槽
- 配置使能jlink 并安裝好的openocd
- test.bin燒錄固件(簡單的序列槽列印)
- 任一序列槽工具(minicom/picocom/putty/cutecom)
操作步驟
将J-LINK連接配接到ubuntu中
在VMware->可移動裝置 選擇上Segger J-LINK,連接配接好後,終端執行指令
lsusb
出現如下SEGGER USB字樣表示J-LINK已連接配接上
接下來确認JLINK的CDC序列槽也連接配接上
ls /dev/ttyACM*
配置openocd cfg
cd ~
mkdir test
wget http://mcai.oss-cn-shenzhen.aliyuncs.com/conf/jlink-swd-stm32f10x.cfg
openocd -f jlink-swd-stm32f10x.cfg
出現如下starting gdb server 資訊表示已經啟動調試
附上jlink-swd-stm32f10x.cfg内容,可以修改更換bin檔案名和燒錄位址
# openocd setup
source [find interface/jlink.cfg]
transport select swd
source [find target/stm32f1x.cfg]
# write image and restart target
proc program {} {
init
reset init
halt
flash write_image erase USART.bin 0x08000000
reset run
shutdown
}
# reset target and attach to debug
proc attach {} {
init
reset run
}
燒錄
新開一個終端(注意要新開)先下載下傳bin檔案
cd ~/test
wget http://mcai.oss-cn-shenzhen.aliyuncs.com/bin/stm32f103c8t6/USART.bin
然後通過telnet連接配接gdb server
telnet 127.0.0.1 4444
如下可以順利進入
telnet下輸入
halt
program
出現如下,直接輸入program無法halt住,最後執行了shutdown退出了telnet,由于bin檔案很小燒錄很快
驗證
使用picocom序列槽工具,設定波特率115200,序列槽為/dev/ttyACM0
picocom -b 115200 /dev/ttyACM0
複位目标闆,出現“uart loop test ok.”字樣表示程式燒錄ok
REF參考内容
- stm32-tests/openocd-um232.cfg at 1a2ef8e0b35233e5a17721c1101247b20e0bdbab · geomatsi/stm32-tests · GitHub
- Running — NuttX latest documentation (apache.org)