Hi,
We are trying to use the Orin Nano to flash an external MCU using OpenOCD v12.
For our prototype, we’re connecting a SparkFun SAMD21 Dev Breakout Board (https://www.sparkfun.com/products/13672) to the Orin Nano. So we want to use “openocd” installed on the Orin Nano to flash the SAMD21G18A MCU that is on the Breakout Board.
We want to reserve 3 GPIO pins on the Orin Nano:
- SWC / PAA.03 / pin 37 on the 40-pin header
- SWD / PAA.02 / pin 33 on the 40-pin header
- RSTn / PAA.01 / pin 29 on the 40-pin header
Here are the steps I took to get where I am now:
- sudo apt-get install make libtool pkg-config autoconf automake texinfo libusb-1.0 gpiod libgpiod-dev
- sudo git clone http://openocd.zylin.com/openocd
- cd openocd
- ./bootstrap
- ./configure --enable-dln-2-gpiod --enable-linuxgpiod
- make
- make install
- Open “/usr/local/share/openocd/scripts/interface/dln-2-gpiod.cfg” and change it accordingly:
# SPDX-License-Identifier: GPL-2.0-or-later
# Use DLN-2 GPIO through linuxgpiod
#
# +-----------+-------------+-------------+
# | signal | DLN-2 | gpio offset |
# +-----------+-------------+-------------+
# | SWCLK | PAA.03 | 3 |
# | SWDIO | PAA.02 | 2 |
# | RSTn | PAA.01 | 1 |
# +-----------+-------------+-------------+
adapter driver linuxgpiod
adapter gpio swclk 3 -chip 0
adapter gpio swdio 2 -chip 0
adapter gpio srst 1 -chip 0
reset_config trst_and_srst separate srst_push_pull
- Connect SWCLK on the MCU breakout board to pin 37 on the J50 header.
- Connect SWDIO on the MCU breakout board to pin 33 on the J50 header.
- Connect RESETn on the MCU breakout board to pin 29 on the J50 header.
- Connect 3.3V on the MCU breakout board to pin 1 on the J50 header.
- Connect GND on the MCU breakout board to pin 39 on the J50 header.
- cd /home/openocd
- touch openocd.cfg
- Edit “openocd.cfg” accordingly:
--------------------------------------------------------
adapter driver linuxgpiod
transport select swd
# Chip info
set CHIPNAME at91samd21g18a
set ENDIAN little
source [find interface/dln-2-gpiod.cfg]
source [find target/at91samdXX.cfg]
# Commands
init
targets
reset halt
shutdown
--------------------------------------------------------
- Run “openocd”.
After finally running all these commands, I get a generic error saying "Error connecting DP: cannot read IDR"
(please see example picture below).
I understand this is a generic error, but can you please help me debug this issue? Have you had success with running “openocd” on the Orin Nano specifically?
Is there something we have to do to reserve the GPIO pins before running OpenOCD, for example?