OpenOCD w/ STM32

這篇文章是留給自己日後可以參考, 不要時間久了之後就忘了 XD


method 1 : openocd

compiling openocd. (link):
  1. cd /tmp; git clone https://git.code.sf.net/p/openocd/code openocd
  2. cd /tmp/openocd
  3. 確定 libusb-dev 有安裝(使用環境為 Linux Mint 17.3 'Rosa') 後, 於 openocd 根目錄執行
    ./bootstrap
  4. 因為僅需要使用到 STLink 所以組態僅指定 enable-stlink
    ./configure --prefix=/usr --enable-stlink
    跑完程式組態後, 最後可以概略知道 openocd 支援的功能清單:
    --------------------------------------------------
    OpenOCD configuration summary
    --------------------------------------------------
    MPSSE mode of FTDI based devices yes (auto)
    ST-Link JTAG Programmer yes TI ICDI JTAG Programmer yes (auto)
    Keil ULINK JTAG Programmer yes (auto)
    Altera USB-Blaster II Compatible yes (auto)
    Versaloon-Link JTAG Programmer yes (auto)
    OSBDM (JTAG only) Programmer yes (auto)
    eStick/opendous JTAG Programmer yes (auto)
    Andes JTAG Programmer yes (auto)
    USBProg JTAG Programmer yes (auto)
    Raisonance RLink JTAG Programmer yes (auto)
    Olimex ARM-JTAG-EW Programmer yes (auto)
    CMSIS-DAP Compliant Debugger no
    Altera USB-Blaster Compatible no
    ASIX Presto Adapter no
    OpenJTAG Adapter no
    SEGGER J-Link Programmer yes (auto)
  5. 最後...
    make
  6. 編譯完程式後, **不要安裝** 依據上面文章的建議, 在特定目錄建立 openocd 的程式目錄即可; 我是將其放在 ~/program/openocd 內
    cd /tmp/openocd
    mkdir ~/program/openocd
    cp -r tcl/* ~/program/openocd
    cp src/openocd ~/program/openocd
  7. done!
Programming an STM32F103XXX with a generic "ST Link V2" programmer from Linux. (link)

先執行 openocd
~/program/openocd$ sudo ./openocd -f interface/stlink-v2.cfg -f board/stm32l4discovery.cfg
~/program/openocd$ sudo ./openocd -f interface/stlink-v2.cfg -f board/stm32f7discovery.cfg
連線至 openocd 作業
$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
adapter speed: 480 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000200 msp: 0x20000400
> flash write_image erase fw.bin 0x08000000
auto erase enabled
device id = 0x10016435
flash size = 256kbytes
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000050 msp: 0x20000400
block write succeeded
wrote 131072 bytes from file dump.bin in 5.715645s (22.395 KiB/s)
> reset run
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
adapter speed: 480 kHz
測試過可以正常連線 STM32F767 & STM32L432; 有實際編譯 ChibiOS/RT 寫入 STM32L432.


method 2 : ST-Link


這個方式最為簡便 - 只需要購置 ST-Link or ST-Link/V2 再配合 stlink 即可.


(本 BKSPtw Blog 內任何一篇文章皆可自由轉載, 但是煩請註明出處並附上文章連結. 感謝!)

若各位朋友有任何保養/維修的需求, 歡迎來電或者留言詢問. Thanks!
較新的 較舊