usage: openocd -f cmds/from/file.cfg -c "command inline" default -f path: /usr/share/openocd/scripts/ starts gdb automatically, gdb_port for setting port, default 3333. use gdb for cpu debugging can interactively enter commands, telnet_port, default 4444 === select interface (jtag dongle): -f interface/ifname.cfg eg. buspirate select cpu: -f target/targetname.cfg eg. zynq_7000 select devboard (jtag+cpu+...): -f board/boardname.cfg eg. stm32f0discovery see /usr/share/openocd/scripts/ for existing ones === general commands: help : get help for a command exit : close telnet session, leave openocd running shutdown : stop openocd adapter config: adapter driver : select adapter driver (cf. interfaces/*.cfg) transport select : select phsyical debug itf (jtag, swd, ...) adapter speed : select jtag/swd/.. speed debugging: init : need to run this before running commands that interact with the device, and after setting up all interfaces/targets/...! scan_chain : scan which jtag devices are available reg []: get/set registers halt : halt target for debugging resume []: resume cpu, optionally at addr step []: step 1 insn, opt. at addr reset : hard reset m[dw][bhwd] : memory Display/Write, byte/halfword/word/doubleword (8..64 bit) dump_image : dump memory to file load_image [] [] : write file to memory virt2phys : addr xlat if mmu enabled flash commands: flash banks : list flash existing on platform flash info : print info (size, prot, sectors, etc) of flash bank flash read_bank [ []] : dump flash to file program [preverify|verify|reset|exit|] : program flash flash erase_sector |last | erase_address : erases flash (mmapped). see flash banks/info output flash erase_check : check if flash is erased note: flash drivers can have extra options, w/ lock/protect/... stuff not covered: erasing flash nand commands: nand list : like flash banks nand probe : needs to be done before commands below nand info : show info nand dump : dump nand to file nand write : write image to nand nand erase [ ] : erase nand nand check_bad_blocks : check bad blocks on device putting it together: "i want to load my program into ram & debug it with gdb": openocd -f board/mydevboard.cfg -c init -c "load_image myfirmware.elf" -c "reset halt" # gdbserver now running on port 3333, halted at reset vector # or put this in a script file & then do -f ./thescript.cfg "but its not a devboard": openocd -f interface/probe.cfg -f target/mymcu.cfg -c init \ -c "load_image myfirmware.elf" -c "reset halt" # gdbserver now running on port 3333, halted at reset vector "tell me what this device is": openocd -f interface/probe.cfg -c "transport select jtag" -c "adapter speed khz" \ -c init -c scan_chain -c shutdown openocd -f interface/probe.cfg -c "transport select jtag" -c "adapter speed khz" \ -f target/themcu.fg -c init -c "flash banks" -c "flash info 0" -c shutdown "i want to dump the flash in this mcu i found": openocd -f interface/probe.cfg -f target/themcu.fg \ -c init -c "flash read_bank 0 flashdump.bin" -c shutdown