#!/bin/sh # Usage: ./gdb.sh path/to/my/firmware.elf # call ocd.sh script before this ELF_FILE=$1 # disable confirmation messages, connect to MCU via openocd server, reset MCU # and instantly stop execution arm-none-eabi-gdb "${ELF_FILE}" \ -ex 'set confirm off' \ -ex 'target extended-remote localhost:3333' \ -ex 'monitor reset halt' # now you can flash the firmware with 'load' and run it with 'run'