Ubuntu環境下openocd編譯安裝及bootloader下載
-
編譯安裝openocd
- 進入openocd-0.10.0 目錄 (cd XX/bootloader/openocd-0.10.0)
- 配置文件(./configure --enable-stlink)
如果提示ST-Link JTAG Programer yes 表示stlink配置完成。否則跳轉到最後問題解決。
- 編譯源代碼( sudo make )輸入密碼後開始編譯
- 安裝openocd (sudo install )輸入密碼後開始安裝
- bootloader燒寫
- 將st-link連接上飛控,再連接上電腦。
- 打開命令行(ctrl alt t)
- openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase /home/zcb/bootloader/xxx.bin 0x08000000" -c "reset run" -c shutdown
出現 adapter speed:2000kHz
Shutdown command invoked 表示下載成功。
若出現找不到st-link,則爲st-link接口未配置編譯安裝導致的。以下是解決方法。
-
問題解決
- 若出現st-link配置失敗
- 打開命令行窗口(ctrl alt t),輸入sudo apt-get install libudev-dev (輸入密碼後運行)
- 進入libusbx-1.0.17文件夾中 (cd XX/bootloader/libusbx-1.0.17)
- ./configure 配置
- sudo make 編譯
- sudo install 安裝
- 返回openocd-0.10.0文件夾中重新配置即可。