Using OpenOCD to program a homebrew nRF51822 board

I created a board to test the Bluetooth Low Energy using Nordic nRF51822 chip, see:

I did everything today (schematic, pcb routing, board etching, soldering SMD components and software test).

I used the nrf51-sdk from here:
https://github.com/relayr/nrf51-sdk.git

For flash programming I used OpenOCD with STLink-v2, this is my openocd.cfg:

$ cat openocd.cfg 
# nRF51822 Target

# Using stlink as SWD programmer
source [find interface/stlink-v2.cfg]

# SWD as transport
transport select hla_swd

# Use nRF51 target
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]

Then I just execute it from terminal:

$ sudo openocd -f openocd.cfg 
[sudo] password for alan: 
Open On-Chip Debugger 0.10.0-dev-00040-gd52070c (2015-11-01-10:42)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.233751
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000
auto erase enabled
Info : nRF51822-QFAC(build code: A1) 256kB Flash
Info : Padding image section 0 with 2112 bytes
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)
auto erase enabled
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)
Info : dropped 'telnet' connection

And in other terminal I execute:

$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger

> reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x00000a40 msp: 0x20004000

> flash write_image erase s110_softdevice.hex 0
auto erase enabled
nRF51822-QFAC(build code: A1) 256kB Flash
Padding image section 0 with 2112 bytes
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 93184 bytes from file s110_softdevice.hex in 4.252896s (21.397 KiB/s)

> flash write_image erase bletest.bin 0x18000
auto erase enabled
using fast async flash loader. This is currently supported
only with ST-Link and CMSIS-DAP. If you have issues, add
"set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
wrote 13312 bytes from file bletest.bin in 0.629010s (20.667 KiB/s)

> exit
Connection closed by foreign host.

 

I connected the OpenOCD to SWD pins as explained here:
https://github.com/RIOT-OS/RIOT/wiki/Board:-yunjia-nrf51822

That’s it!

Advertisements

3 thoughts on “Using OpenOCD to program a homebrew nRF51822 board

  1. Thank you Celem!
    I get used to PCB photographic process, then it is fast to do board prototype at home! BR, Alan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s