nRF51 Development Kit complete setup for Linux
[Updated in 02/2020 - SDK 12.3.0]
Installation Steps
Toolchain
- download toolchain https://launchpad.net/gcc-arm-embedded/+download
SDK
- download nRF51 SDK :
store the SDK path under NRF51_SDK_DIR :
export NRF51_SDK_DIR=$PWD/your-sdk-folder/nRF5_SDK_12.3.0_d7731ad
- edit Makefile config :
vi $NRF51_SDK_DIR/components/toolchain/gcc/Makefile.posix
:
GNU_INSTALL_ROOT := <path_to_toolchain>
GNU_VERSION := 5.2.1
GNU_PREFIX := arm-none-eabi
Replace your toolchain path + your GNU version
For example :
GNU_INSTALL_ROOT := /home/user/adafruit-oled-st7735-dk51/gcc-arm-none-eabi-5_2-2015q4
GNU_VERSION := 5.2.1
GNU_PREFIX := arm-none-eabi
Uploader
get the nrf uploader :
https://www.nordicsemi.com/eng/nordic/Products/nRF51-DK/nRF5x-Tools-Linux/51392(not working anymore)- https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download#infotabs
Segger
- install Segger J-Link software from https://www.segger.com/jlink-software.html
Build
cd $NRF51_SDK_DIR/examples/peripheral/blinky/pca10028/blank/armgcc
make
Upload
make flash
Your blink example should be running
Debug your code (for manual testing using the makefiles)
I don't use the Segger files from the external folder in the SDK. I use the one from this gist : https://gist.github.com/bertrandmartel/25a566178766c7d0a7e04a18b341a732.
clone the gist and copy the folder under segger_rtt in the path below :
git clone https://gist.github.com/25a566178766c7d0a7e04a18b341a732.git
mkdir -p $NRF51_SDK_DIR/components/drivers_ext/segger_rtt
cp ./25a566178766c7d0a7e04a18b341a732/* $NRF51_SDK_DIR/components/drivers_ext/segger_rtt/
Update the blink example with #include "SEGGER_RTT.h"
and SEGGER_RTT_printf(0, "Hello world!\n");
in the loop
Update the Makefile :
sed -i -e 's/external\/segger_rtt/components\/drivers_ext\/segger_rtt/g' $NRF51_SDK_DIR/examples/peripheral/blinky/pca10028/blank/armgcc/Makefile
sed -i '/RTT_Syscalls_GCC.c/d' $NRF51_SDK_DIR/examples/peripheral/blinky/pca10028/blank/armgcc/Makefile
Compile & upload:
make
make flash
start debug :
JLinkExe -device nRF51422_xxAC -speed 4000 -if SWD
> connect
In another terminal :
JLinkRTTClient
You should now see Hello world!
in the client
Note: I used different Segger sources because I didn't find a good example how to compile properly the Segger files from the SDK. The only difference between the one of my gist & the SDK is SEGGER_RTT_Conf.h which is much simpler
CI script
A working CI script for DK 51 :
#!/bin/bash
wget -q https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
bzip2 -q -dc gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 | tar xf -
rm gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
chmod +x $PWD/gcc-arm-none-eabi-5_2-2015q4/bin/*
ls -al $PWD/gcc-arm-none-eabi-5_2-2015q4/bin
mkdir -p sdk
wget -q https://www.nordicsemi.com/-/media/Software-and-other-downloads/SDKs/nRF5/Binaries/nRF5SDK1230.zip -O sdk.zip
unzip -qq sdk.zip -d ./sdk
rm sdk.zip
export NRF51_SDK_DIR=$PWD/sdk/nRF5_SDK_12.3.0_d7731ad
echo "GNU_INSTALL_ROOT := `pwd`/gcc-arm-none-eabi-5_2-2015q4"$'\r\n'"GNU_VERSION := 5.2.1"$'\r\n'"GNU_PREFIX := arm-none-eabi"$'\r\n' > ${NRF51_SDK_DIR}/components/toolchain/gcc/Makefile.posix
mkdir -p $NRF51_SDK_DIR/components/drivers_ext/segger_rtt
git clone https://gist.github.com/25a566178766c7d0a7e04a18b341a732.git
cp ./25a566178766c7d0a7e04a18b341a732/* $NRF51_SDK_DIR/components/drivers_ext/segger_rtt/
echo $NRF51_SDK_DIR
echo $PATH
make