Using Raspberry Pi to Program BLE400 / NRF51822

Connect the BLE400 according to diagram shown in:

  • RPi GPIO PIN 24 to SWDIO (SWD, pin7)
  • RPi GPIO PIN 25 to SWD (SWD, pin9)
  • RPi GND to GND (SWD, pin18)

If you are using RPi 2 use the command from the same URL:

sudo openocd -f interface/raspberrypi2-native.cfg -c “transport select swd; set WORKAREASIZE 0″ -f target/nrf51.cfg

If you are using RPi 1 use the command:

sudo openocd -f interface/raspberrypi-native.cfg -c “transport select swd; set WORKAREASIZE 0″ -f target/nrf51.cfg

If you use the command for RPi 1 you will get below error:

Error: Require at least one of trst or srst gpios to be specified


Error: Require tck, tms, tdi and tdo gpios for JTAG mode and/or swclk and swdio gpio for SWD mode

To resolve this follow below steps:

  • Open /usr/local/share/openocd/scripts/interface/raspberrypi-native.cfg
  • Add below entries at the end of the file:
    • bcm2835gpio_swd_nums 25 24
    • bcm2835gpio_srst_num 18
    • reset_config srst_only srst_push_pull
  • Comment the entry “bcm2835gpio_jtag_nums 11 25 10 9”

If you encounter error like following during the “flash image” operation use “nrf51 mass_erase” to erase the existing flash.

Cannot erase protected sector at 0x0
failed erasing sectors 0 to 12


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">