Skip to content

Instantly share code, notes, and snippets.

@george-hawkins
Last active November 11, 2023 06:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save george-hawkins/f77054c71a046c5b5f83 to your computer and use it in GitHub Desktop.
Save george-hawkins/f77054c71a046c5b5f83 to your computer and use it in GitHub Desktop.

BLE Nano and the nRF51822 SDK

If you've tried using the nRF51822 SDK with the BLE Nano (after following the RedBearLab guide) you may have come to a dead end.

Even the simplest examples didn't work for me. I assumed I had a dead Nano (despite the upload process seeming to work fine).

The reason turned out to be that the latest SDK versions assume you have a nRF51822 chip with 32KB of RAM rather than the 16KB that the nRF51822 on the Nano has.

James Willcox explains this in a post to the RedBearLab BLE Nano support forum.

The details are rather brief there, so here is a walk through of getting things working on Ubuntu. Things should be almost identical on Mac OS X.


Download the latest nRF51 SDK from Nordic (choose the zip file that does not end in _packs.zip).

Then install it:

$ cd
$ unzip ~/Downloads/nRF51_SDK_8.0.0_5fc2c3a.zip
$ NRF51_SDK=$HOME/nRF51_SDK_8.0.0_5fc2c3a

Install James Willcox's custom board file:

$ cd $NRF51_SDK
$ cd examples/bsp
$ curl --output custom_board.h http://redbearlab.zendesk.com/attachments/token/fQCYu6RkcjOKZiOAxL0hfcDK9/?name=custom_board.h

Now an example of adjusting the Makefile and loader script of the standard heart rate sensor example and getting things to build:

$ cd $NRF51_SDK
$ cd examples/ble_peripheral/ble_app_hrs/pca10028/s110/armgcc
$ vi Makefile
Find `CFLAGS += -DBOARD_PCA10028` and change `BOARD_PCA10028` to `BOARD_CUSTOM` and save.
$ ls *.ld
ble_app_hrs_gcc_nrf51.ld
$ vi ble_app_hrs_gcc_nrf51.ld
Find `RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x6000` and change `LENGTH = 0x6000` to `LENGTH = 0x2000` and save.
$ make all

Now upload the result to your Nano:

$ cd _build
$ SOFTDEVICE=$NRF51_SDK/components/softdevice/s110/hex/s110_softdevice.hex
$ OUTPUT=output.hex
$ ls *.hex
nrf51422_xxac_s110.hex
$ INPUT=nrf51422_xxac_s110.hex
$ srec_cat $SOFTDEVICE -intel $INPUT -intel -o $OUTPUT -intel --line-length=44
$ cp $OUTPUT /media/$USER/MBED

Note: on Mac OS X you may need to change the mount options for the Nano and use the -X flag for the cp step, as discussed in this support forum post.


The above assumes you already have the "GNU Tools for ARM Embedded Processors" installed.

On Ubuntu the easiest way to do this is to use Terry Guo's PPA.

And you also need srec_cat installed, on Ubuntu this just requires:

$ sudo apt-get install srecord
@holla2040
Copy link

yeah! thanks for the great info. It all makes sense.

Did you happen to struggle through getting DFU/FOTA running as well for the nano at 16K?

@maayanH
Copy link

maayanH commented May 31, 2016

Great! I had some troubles until I found this helpful guide.
Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment