title: OpenOCD fails to connect with cortex processor
body: <p>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.</p>
  
  <blockquote>
    <p>Error: Could not initialize the debug port</p>
  </blockquote>
  
  <p>I'm following this <a href="https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi?view=all" rel="noreferrer">https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi?view=all</a> and this tutorials <a href="https://movr0.com/2016/09/02/use-raspberry-pi-23-as-a-jtagswd-adapter/" rel="noreferrer">https://movr0.com/2016/09/02/use-raspberry-pi-23-as-a-jtagswd-adapter/</a>. Compilation and install happens without issues.</p>
  
  <p>The cortex m0 SoC is a Nordic Semiconductor nRF51822 bluetooth chip packaged in ISP1302 module.</p>
  
  <p>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.</p>
  
  <p>The configuration file is as follows:</p>
  
  <pre><code>source [find interface/raspberrypi2-native.cfg]
  bcm2835gpio_swd_nums 25 24
  transport select swd
  
  # target
  source [find target/nrf51.cfg]
  
  init
  targets
  </code></pre>
  
  <p>(and I removed <code>bcm2835gpio_srst_num 18</code> from the raspberrypi2-native.cfg)</p>
  
  <p>executing with <code>sudo openocd -f config.cfg</code></p>
  
  <p>The raspberry Pi CM3 is running with the option <code>core_freq=250</code> on <code>/boot/config.txt</code> 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.</p>
  
  <p>I've tried several combinations of <code>reset_config</code> nothing changed the error. The full initialization stack is as follows:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>No matter what I tried I always get this "Error: Could not initialize the debug port".</p>
  
  <p>Interesting enough, using a ST-Link/V2 adapter connected to the PI USB and modifying the <code>interface</code> on the configuration it works without issues.</p>
  
  <p>Any suggestions? What am I doing wrong? Is there some initialization on the GPIO needed?</p>
  
  <p><strong>edit:</strong></p>
  
  <p>I've noticed someone voted to close the question as "unclear what's asking".</p>
  
  <p>I'm asking: How can I connected the Raspberry Pi to a nRF51 SoC using its GPIO? Refer above everything I tried.</p>