RedBear

Firmware Development with nRF51822 SDK and GCC

This document provides information for developers who want to develop nRF51822 using GCC with Nordic nRF51822 SDK on Windows platform, other platforms such Mac OSX and Linux are also supported, please download appropriate version of tools.


Advantage using ARM GCC with Nordic nRF51822 SDK

  • Open source compiler, free of charge
  • Access to the latest BLE Stack and SDK
  • Easy to manage
  • Create your own license for your code


Requirements

  • RedBearLab nRF51822 board or BLE Nano with MK20 USB board
  • Nordic nRF51822 BLE SDK (version 6.1)
  • nRF51-Tools utility (mergehex.exe)
    • for Mac OSX and Linux, you need to use "srec_cat" command
  • nRF51822 SoftDevice S110 (version 7.0)
    • You can try S120 or S130 if you want to develop BLE Central role firmware
  • GNU Make utility
  • GNU ARM GCC
  • BLE Central Device with Nordic nRF ToolBox App installed e.g. an iPhone 4s or later


*Nordic has an Application Note for developers who want to use ARM GCC with Eclipse IDE.


Step By Step Guide

Step 1: Go to Nordic's nRF51822 download page


Step 2: Get nRF51822 SDK

  • Click nRF51-SDK-zip to download
    alt text
  • Please refer to "How To Download nRF51 SDK v7.x.x" if you want to use SDK 7.x.x version.

Step 3: Get nRF51822 SoftDevice (S110)

  • Click S110-SD-v7
    alt text
  • Note: current SDK requires S110 v7 to compile

Step 4: Get nRF51822 Tools

Note: See OSX/Linux session below if you are not using Windows.

  1. Download the nRFTools_6_1_0_Installer.exe
    alt text
  2. Run the .exe and install it
  3. We just need the mergehex.exe and it should be installed by default at
    C:\Program Files (x86)\Nordic Semiconductor\nrf51\bin\


Step 5: Get ARM GCC


Step 6: Get GNU Make utility

  1. Download GNU Make
    http://iweb.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-bin.zip

  2. Download GNU dependency files
    http://iweb.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81-dep.zip
    Note: For Windows, the make.exe needs some DLLs to run, these are in make-3.81-dep, put them into a same folder


Step 7: Putting all tools into a folder

  • Unzip all tools to a folder, for example "D:\nRF51822", we will use this as our development folder, and you should see the follow structure
    alt text


Step 8: Modify Makefiles

  • In this folder, modify Makefile.windows

    D:\nRF51822\nrf51_sdk_v6_1_0_b2ec2e6\nrf51822\Source\templates\gcc

    With the follow code:
 
ifeq ($(findstring 86, $(ProgramFiles)), )
    PROGFILES := C:/Program Files
else
    PROGFILES := C:/Program Files (x86)
endif

GNU_INSTALL_ROOT := D:/nRF51822/gcc-arm-none-eabi-4_8-2014q2-20140609-win32
GNU_VERSION := 4.7.3
GNU_PREFIX := arm-none-eabi
  • modify Makefile.common, add SDK_PATH and SDK_SOURCE_PATH:
 
DEVICE := NRF51
DEVICESERIES := nrf51

SDK_PATH = D:/nRF51822/nrf51_sdk_v6_1_0_b2ec2e6/nrf51822/
SDK_SOURCE_PATH = D:/nRF51822/nrf51_sdk_v6_1_0_b2ec2e6/nrf51822/Source/

SDK_INCLUDE_PATH = $(SDK_PATH)/Include/
SDK_SOURCE_PATH = $(SDK_PATH)/Source/
TEMPLATE_PATH += $(SDK_SOURCE_PATH)/templates/gcc/
OUTPUT_BINARY_DIRECTORY := _build

Step 9: Compile Heart Rate Sensor (HRS) example

  1. Start a Command Prompt:
  2. Go to this folder:
    D:\nRF51822\nrf51_sdk_v6_1_0_b2ec2e6\nrf51822\Board\nrf6310\s110\ble_app_hrs\gcc
  3. In command prompt, run:
    D:\nRF51822\make-3.81\make.exe -f ble_app_hrs.Makefile
  4. The firmware file (.hex) will be created inside the _build folder


Step 10: Merge HRS with SoftDevice Note: See OSX/Linux session below if you are not using Windows.

  1. Run merge tool:
    D:\nRF51822\mergehex.exe --merge D:\nRF51822\s110_nrf51822_7.0.0_softdevice.hex _build\ble_app_hrs_s110_xxaa.hex --output hrs.hex

  2. Sample screen output:

 
Parsing D:\nRF51822\s110_nrf51822_7.0.0_softdevice.hex file.
Parsing _build\ble_app_hrs_s110_xxaa.hex file.
Merging files.
Writing merged file.

Step 11: Load the compiled firmware

  1. Connect your nRF51822 board to an USB port
  2. Drag and drop the hrs.hex to the MSD drive, e.g. E:

**You should be able to do this if you follow the Getting Started - nRF51822


Step 12: Test it with Nordic nRF ToolBox App

  1. Go to App Store and download "nRF ToolBox"
  2. Run "HRM" and connect to the development board


alt text



alt text



alt text


Mac OSX

The mergehex.exe is only for Windows platform. Use srec_cat instead on Mac OSX.

Step 1: Install brew from Terminal

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Step 2: Install srecord using brew from Terminal

$ brew install srecord


Step 3: Merge using srec_cat command

$ sreccat s110nrf518227.0.0softdevice.hex -intel bleapphrss110xxaa.hex -intel -o hrs.hex -intel --line-length=44


Linux

The mergehex.exe is only for Windows platform. Use srec_cat instead on Linux.

Step 1: Install srecord

$ sudo apt-get install srecord


Step 2: Merge using srec_cat command

$ sreccat s110nrf518227.0.0softdevice.hex -intel bleapphrss110xxaa.hex -intel -o hrs.hex -intel --line-length=44