NRF51 Firmware Development Notes


NRF51 Firmware Development Notes

Documentation

nRF51-specific documentation:

Generic ARM documentation:

Chip Details

Address Map

0xE000 0000 Private Peripherals Bus
            ...
            ...
0x5000 0000 ABH Peripherals
            ...
0x4000 0000 APB Peripherals
            ...
0x2000 0000 Data RAM
            ...
0x1000 1000 UICR
            ...
0x1000 0000 FICR
            ...
0x0000 0000 Code FLASH

[[!img Error: pdf image processing disabled in img_allowed_formats configuration]]

Flash and RAM Areas

| Device | Flash ||| RAM ||| Device | Size | Start | End | Size | Start | End | ------- | ------ | ----------- | ----------- | ------ | ----------- | ----------- | xxAA | 256kB | 0x0000 0000 | 0x0002 0000 | 16kB | 0x2000 0000 | 0x2000 4000 | xxAB | 128kB | 0x0000 0000 | 0x0001 0000 | 16kB | 0x2000 0000 | 0x2000 4000 | xxAC | 256kB | 0x0000 0000 | 0x0002 0000 | 32kB | 0x2000 0000 | 0x2000 8000 | [Available resources for chip variants]

Debugging

screen /dev/ttyACM0 115200,-ixon,-ixoff

GDB

Show a single value : print <symbol>

Show all registers : info registers

Set a breakpoint : break <symbol>

Show all breakpoints : info break

Delete breakpoint : delete break <breakpoint index>

Step into : step

Step over : next

Step out : finish

Remote Debugging

  • target remote localhost:2331
  • disconnect or detach
  • the generic monitor commands sends jlink-specific commands. monitor reset

When using GDB, make sure you use the version for arm:

arm-none-eabi-gdb

I often start GDB like this:

arm-none-eabi-gdb -ex "file build/*.out" -ex "target remote localhost:2331" -ex "monitor reset"

This select the correct image so you can say break main, connects to the JLink remote GDB server and performs a reset of the board.

Debugging Commands

step : step into function

next : step over function

The JLink tools

JLinkGDBServer

This program is normally executed as

JLinkGDBServer -if SWD

It should find the target and wait for an TCP connection on port 2331.

Sometimes it will refuse to listen to the socket, just waiting (around 10 seconds) for a while seems to fix the problem.

Example output:

$ JLinkGDBServer -if SWD
SEGGER J-Link GDB Server V4.98e Command Line Version

JLinkARM.dll V4.98e (DLL compiled May  5 2015 11:49:35)

-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               off
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 unspecified
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled May  4 2015 13:48:48
Hardware: V1.00
S/N: 681084376
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
Connected to target
Waiting for GDB connection...