[Update 20210413: All issues resolved. See below.]
This experiment ran OpenOCD on a Pi4 under Ubuntu 20.10.
Source code for OpenOCD compiled with no errors on 20210411.
Done with all recent updates applied before compiling.
The Pi4 runs faster than earlier versions, so changed two config files:
usr/local/share/openocd/scripts/interface/raspberrypi4-native.cfg
/home/pi/bootloader/openocd.cfg
Connected the Pi4 to a target board, and ran OpenOCD as follows:
cd /home/pi/bootloader
sudo openocd
On the first run, the output hung:
pi@ubuntu:~/bootloader$ sudo openocd
Open On-Chip Debugger 0.11.0+dev-00069-g68e50415a-dirty (2021-04-10-15:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/b...
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
^Cshutdown command invoked
On a second run, it hung differently:
pi@ubuntu:~/bootloader$ sudo openocd
Open On-Chip Debugger 0.11.0+dev-00069-g68e50415a-dirty (2021-04-10-15:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/b...
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000294 msp: 0x20002de0
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
^Cshutdown command invoked
On a third run, it hung in yet another way:
pi@ubuntu:~/bootloader$ sudo openocd
Open On-Chip Debugger 0.11.0+dev-00069-g68e50415a-dirty (2021-04-10-15:03)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/b...
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error: DP initialisation failed
Info : SWD DPIDR 0x0bc11477
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00000294 msp: 0x20002de0
Polling target at91samd21g18.cpu failed, trying to reexamine
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Polling target at91samd21g18.cpu failed, trying to reexamine
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
^Cshutdown command invoked
The tested configuration used an Adafruit Metro M0 as a target board.
Connections:
Pi4 Pin Target Pin
--------------------------
22 (GPIO25) SWDCLK
18 (GPIO24) SWDIO
14 (GND) GND
12 (GPIO18) nRST
--------------------------
Created "usr/local/share/openocd/scripts/interface/raspberrypi4-native.cfg" file.
Content of the configuration file was as follows:
adapter driver bcm2835gpio
bcm2835gpio_peripheral_base 0xFE000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 236181 60
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 22 18 26 10
# bcm2835gpio_jtag_nums 25 24 7 15
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 22 18
bcm2835gpio_swd_nums 25 24
# If you define trst or srst, use appropriate reset_config
# Original header pin numbers: TRST - 26, SRST - 18
# bcm2835gpio_trst_num 7
# reset_config trst_only
# bcm2835gpio_srst_num 18
# reset_config srst_only srst_push_pull
# or if you have both connected,
# reset_config trst_and_srst srst_push_pull
Adjusted settings in the other config file before running.
Content of "/home/pi/bootloader/openocd.cfg" file:
source [find interface/raspberrypi4-native.cfg]
transport select swd
set CHIPNAME at91samd21g18
source [find target/at91samdXX.cfg]
#reset_config srst_only
#reset_config srst_nogate
adapter srst delay 100
adapter srst pulse_width 100
init
targets
reset halt
That is the basic configuration.
Anyone who has this working, please explain config file changes.