The Hardware here is simple and cheap, it can be done with any Pi, though I used a Pi Zero. For me, it was free because I had the Pi Zero and the wire.
The default pins are:
Ground to Ground
3.3V power to 3.3V power
Pi header pin 22 to swclk
Pi header pin 18 to swdio
At the time this was written, OpenOCD didn’t have bcm2835gpio in the main release so we git clone it.
The debugger/programmer install is:
cd ~/Downloads sudo bash apt-get install libtool libusb-dev libusb-1.0 autoconf automake texinfo git clone git://git.code.sf.net/p/openocd/code openocd-code cd openocd-code/ ./bootstrap ./configure --enable-sysfsgpio --enable-bcm2835gpio make make install
The raspberrypi-native.cfg didn’t have SWD support, so add them from raspberrypi2-native.cfg. I needed to comment out:
#bcm2835gpio_jtag_nums 11 25 10 9
and to add:
# Each of the SWD lines need a gpio number set: swclk swdio # Header pin numbers: 22 18 bcm2835gpio_swd_nums 25 24
The peripheral base address is different on some Pi models. You can check yours by grabbing the middle 8 digits from:
hexdump -s4 -n4 -e '"0x" 4/1 "%02X""\n"" "' /proc/device-tree/soc/ranges
Edit it with:
Check to be sure your default speed is 700Mhz, or adjust bcm2835gpio_speed_coeffs:
To run openocd:
openocd -f interface/raspberrypi-native.cfg -c "transport select swd; set WORKAREASIZE 0" -f target/nrf51.cfg
If it worked correctly, the last line should read (nothing before this indicates you successfully connected):
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
To connect from your development platform:
telnet pi0 4444
To burn the code, we need two files, in my case both are on a different machine (host) so I use sshfs to mount that.
mkdir ~/host sshfs user@host:/ ~/host
Since the path is rather long, I break it in two and store into variables. This is the proximity example from the SDK:
set BASEPATH ~/host/home/user/Downloads/nRF5_SDK_11.0.0_89a8197 set SOFTDEV $BASEPATH/components/softdevice/s130/hex/s130_nrf51_2.0.0_softdevice.hex set HEXFILE $BASEPATH/examples/ble_peripheral/ble_app_proximity/pca10028/s130/armgcc/_build/nrf51422_xxac_s130.hex #halt, erase, write softdevice and binary, verify both, run it. halt; nrf51 mass_erase; sleep 500; flash write_image $SOFTDEV 0; flash write_image $HEXFILE 0; verify_image $SOFTDEV 0; verify_image $HEXFILE 0; reset run
At this point, your sniffer or phone or whatever should see the Nordic_Prox device.