openocd 烧录单片机
Program elf/hex
openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg -c "program app.elf verify reset exit"
Binary files need the flash address passing
openocd -f board/stm32f3discovery.cfg -c "program filename.bin exit 0x08000000"
Reset MCU
openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg -c init -c halt -c reset -c exit
Use flash command
flash hex:
/d/OpenOCD/bin/openocd.exe -f /d/OpenOCD/share/openocd/scripts/interface/cmsis-dap.cfg -f /d/OpenOCD/share/openocd/scripts/target/ke0x.cfg -c "init" -c "reset halt" -c "flash write_image erase filename.hex" -c "reset" -c "exit"
flash bin:
/d/OpenOCD/bin/openocd.exe -f /d/OpenOCD/share/openocd/scripts/interface/cmsis-dap.cfg -f /d/OpenOCD/share/openocd/scripts/target/ke0x.cfg -c "init" -c "reset halt" -c "flash write_image erase filename.bin 0x08000000" -c "reset" -c "exit"
erase chip(bank0)
/d/OpenOCD/bin/openocd.exe -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg -c "init" -c "halt" -c "flash erase_sector 0 0 last" -c "exit"
erase chip(bank1)
/d/OpenOCD/bin/openocd.exe -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg -c "init" -c "halt" -c "flash erase_sector 1 0 last" -c "exit"
erase sector 0
/d/OpenOCD/bin/openocd.exe -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg -c "init" -c "halt" -c "flash erase_sector 0 0 0" -c "exit"
erase sector 14-15
/d/OpenOCD/bin/openocd.exe -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg -c "init" -c "halt" -c "flash erase_sector 0 14 15" -c "exit"
Ref: OpenOCD Doc