linuxcortex-mopenocdnrf51

OpenOCD fails to connect with cortex processor


I'm trying to flash a cortex m0 based SoC from a Raspberry Pi 3 Compute Module GPIOs but it keeps failing with the same error.

Error: Could not initialize the debug port

I'm following this https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi?view=all and this tutorials https://movr0.com/2016/09/02/use-raspberry-pi-23-as-a-jtagswd-adapter/. Compilation and install happens without issues.

The cortex m0 SoC is a Nordic Semiconductor nRF51822 bluetooth chip packaged in ISP1302 module.

The module GND and 3.3V are wired directly to the Compute module dev-kitand SWDCLK and SWDIO are wired on the GPIO 25, 24 as per tutorials. There's no connection for SRST or TRST.

The configuration file is as follows:

source [find interface/raspberrypi2-native.cfg]
bcm2835gpio_swd_nums 25 24
transport select swd

# target
source [find target/nrf51.cfg]

init
targets

(and I removed bcm2835gpio_srst_num 18 from the raspberrypi2-native.cfg)

executing with sudo openocd -f config.cfg

The raspberry Pi CM3 is running with the option core_freq=250 on /boot/config.txt and I need this option to reliably access UART1. I thought it could be something related to the clock, but not sure how to change/fix if it is.

I've tried several combinations of reset_config nothing changed the error. The full initialization stack is as follows:

Open On-Chip Debugger 0.10.0+dev-00111-gca9dcc8 (2017-04-24-15:30)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO nums: swclk = 25, swdio = 24
cortex_m reset_config sysresetreq
adapter speed: 1000 kHz
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 1001 kHz
Info : SWD DPIDR 0x00150634
Error: Could not initialize the debug port
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* nrf51.cpu          cortex_m   little nrf51.cpu          unknown

No matter what I tried I always get this "Error: Could not initialize the debug port".

Interesting enough, using a ST-Link/V2 adapter connected to the PI USB and modifying the interface on the configuration it works without issues.

Any suggestions? What am I doing wrong? Is there some initialization on the GPIO needed?

edit:

I've noticed someone voted to close the question as "unclear what's asking".

I'm asking: How can I connected the Raspberry Pi to a nRF51 SoC using its GPIO? Refer above everything I tried.


Solution

  • Not exactly the same configuration, but searching for pi3 on http://forum.doozan.com/read.php?3,21789,21927 reveals raspberry123-native.cfg, in which we find a change to the clockspeed:

    # Please set the right peripheral_base address and Transition delay depending on which Raspi (1,2 or 3) you use.

    interface bcm2835gpio

    # Raspi2 and Raspi3 peripheral_base address

    bcm2835gpio_peripheral_base 0x3F000000

    # Raspi1 peripheral_base address
    # bcm2835gpio_peripheral_base 0x20000000

    # Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
    # These depend on system clock, calibrated for stock 700MHz
    # bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET

    # Raspi3 BCM2837 (1200Mhz):
    bcm2835gpio_speed_coeffs 194938 48

    # Raspi2 BCM2836 (900Mhz):
    # bcm2835gpio_speed_coeffs 146203 36

    # Raspi1 BCM2835: (700Mhz)
    # bcm2835gpio_speed_coeffs 113714 28