Skip to content

Board: yunjia nrf51822

Hauke Petersen edited this page Aug 5, 2014 · 27 revisions

Overview

The NRF51822 module by Yunjia Technology is a minimalistic but very low-priced module utilizing Nordics NRF51822QFAA SoC. The SoC features 16Kb of RAM, 256Kb of flash ROM and comes on top of the usual micro-controller peripherals with a 2.4GHz radio that supports both Nordics proprietary ShockBurst as well as Bluetooth Low Energy (BLE).

The board is available for example on ebay or at aliexpress for something around 8-10 USD.

Hardware

yunjia-nrf51822

The hardware matches the nrf51822 board, but it has no programmer.

Flashing the Device

TODO description cabeling with pictures

Software

To flash the device one can use the programmer from the STM32FX-discovery boards.

Side node: Use openocd from git / master because the support is pretty new.

After build and installation, openocd has a bug for this target: solved in http://openocd.zylin.com/#/c/1664/. Alternatively comment out the code to match it to:

$ cat /usr/local/share/openocd/scripts/target/swj-dp.tcl
# ARM Debug Interface V5 (ADI_V5) utility
# ... Mostly for SWJ-DP (not SW-DP or JTAG-DP, since
# SW-DP and JTAG-DP targets don't need to switch based
# on which transport is active.
#
# declare a JTAG or SWD Debug Access Point (DAP)
# based on the transport in use with this session.
# You can't access JTAG ops when SWD is active, etc.

# params are currently what "jtag newtap" uses
# because OpenOCD internals are still strongly biased
# to JTAG ....  but for SWD, "irlen" etc are ignored,
# and the internals work differently

# for now, ignore non-JTAG and non-SWD transports
# (e.g. initial flash programming via SPI or UART)

# split out "chip" and "tag" so we can someday handle
# them more uniformly irlen too...)

#if [catch {transport select}] {
# echo "Info : session transport was not selected, defaulting to JTAG"
# transport select jtag
#}

proc swj_newdap {chip tag args} {
 if {[using_jtag]} { eval jtag newtap $chip $tag $args }
 if {[using_swd]} { eval swd newdap $chip $tag $args }
 if {[string equal [transport select] "cmsis-dap"]} { eval cmsis-dap newdap $chip $tag $args }
}

To use openocd you need this config file:

 $ cat nrf51822module.cfg
# nRF51822 Target
source [find interface/stlink-v2.cfg]
 
set WORKAREASIZE 0x4000
source [find target/nrf51_stlink.tcl]

# use hardware reset, connect under reset
#reset_config srst_only srst_nogate
  1. Start openocd with: sudo /usr/local/bin/openocd -d3 -f nrf51822module.cfg
  2. open a new terminal an connect with telnet: telnet 127.0.0.1 4444
  3. do the following steps to flash (only use bank #0 starting from address 0):
> flash banks
#0 : nrf51.flash (nrf51) at 0x00000000, size 0x00040000, buswidth 1, chipwidth 1
#1 : nrf51.uicr (nrf51) at 0x10001000, size 0x000000fc, buswidth 1, chipwidth 1

> halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x00000e1a msp: 0x20001b2c

> flash erase_address 0 0x00040000
erased address 0x00000000 (length 262144) in 6.382628s (40.109 KiB/s)

> flash write_image /home/c/Downloads/s110_nrf51822_7.0.0_softdevice.bin 0
wrote 86692 bytes from file /home/c/Downloads/s110_nrf51822_7.0.0_softdevice.bin in 26.804939s (3.158 KiB/s)

> flash write_image /home/c/Downloads/ble_app_proximity_s110.bin 0x00016000
wrote 9960 bytes from file /home/c/Downloads/ble_app_proximity_s110.bin in 3.062963s (3.176 KiB/s)

> reset

Debugging

You need to have openocd running. Enter the following in a new terminal:

$ arm-none-eabi-gdb -tui "<your binary ELF>"

(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x000119ce in ?? ()

(gdb) load
Loading section .text, size 0x2284 lma 0x16000
Loading section .ARM.exidx, size 0x8 lma 0x18284
Loading section .data, size 0x458 lma 0x1828c
Loading section .jcr, size 0x4 lma 0x186e4
Transfer rate: 2 KB/sec, 2490 bytes/write.

(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0

(gdb) break ble_stack_init
Breakpoint 3 at 0x16892: file ../main.c, line 206.

(gdb) continue
Continuing.
Clone this wiki locally