Skip to content

Instantly share code, notes, and snippets.

@BCadet
Last active June 13, 2022 14:34
Show Gist options
  • Save BCadet/7b81799f6d1060de2d96f199ccc4887f to your computer and use it in GitHub Desktop.
Save BCadet/7b81799f6d1060de2d96f199ccc4887f to your computer and use it in GitHub Desktop.
basic openocd infos to debug/flash ARM devices

OPENOCD BASICS

download openocd

windows

You can download openocd from the official github mirror Release page This relase does not require admin access to be used. Everything is already compiled and run from inside the folder.

linux

You can install from APT or from sources. That's a lot easier !

create a cfg file for your project

To link openocd to your project, you can create a cfg file in your project folder. This file is basically just a script in the openocd format that is passed to openocd at the execution.

In this script, you want to provide the informations of your probe and the ARM device.

Example of config file to setup communication to an ATSAMC21E18 with a Atmel-ICE JTAG/SWD in-circuit debugger:

# Atmel-ICE JTAG/SWD in-circuit debugger.
# interface cmsis-dap
# cmsis_dap_vid_pid 0x03eb 0x2141

source [find interface/cmsis-dap.cfg]

# Chip info 
set CHIPNAME at91samc21e18
source [find target/at91samdXX.cfg]

bindto 0.0.0.0
init

This script setup:

  • a GDB server on port 3333 (default)
  • a telnet server on port 4444 (default)
  • open those interfaces to be reachable from the network

Description

  • source [find interface/cmsis-dap.cfg] Source the cmsis-dap.cfg to communicate with a generic ARM compatible jtag/swd interface.

  • set CHIPNAME at91samc21e18 Set a variable name CHIPNAME containing the precise reference of the chip.

  • source [find target/at91samdXX.cfg] Source the generic target file for the atsam chips.

  • bindto 0.0.0.0 This line open the openocd socket to outsid of the computer. You need to add this line if you want to connect to a running instance of openocd from another commputer.

  • init Start the openocd init routine.

program

You can flash your binary with openocd with the line program app.hex verify reset exit

run openocd

Use the command line to run openocd with the command: <path_to_openocd>/openocd -f <your_cfg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment