nRF51/nRF52

Developing nRF51 & nRF52 series software using Eclipse

Bluetooth® Low Energy SoC





I have been building BLE applications using Nordic’s popular nRF51822, nRF51422 & nRF52832 series ultra low power System on Chip (SoC).   It integrates the nRF51 series 2.4GHz transceiver, a 32 bits ARM® Cortex-M0 MCU, Flash memory, analog and digital I/O, supporting both Bluetooth Low Energy, ANT and proprietary protocols.  The nRF52 series sports a Cortex-M4 MCU.  It took me longer than I would have liked to get the development, debug, and build environment up and running on my Mac.  I hope this post gives you insight into the lessons I learned along the way - saving you precious time along the way.

The hardware used in my project are the IMM-NRF5x series modules and CMSIS-DAP Debug JTAG programmer for debugging.  The one in the picture bellow integrates an nRF51822 with all available I/O are routed out to the pads.  The pads are both through hole and SMT so that it can be easily prototype any application and SMD in for production.  There are 3 modules IMM-NRF51822, IMM-NRF51422 and IMM-NRF52832.  They are all pin compatible, though you can use any module interchangeably on your PCB.



Available on CrowSupply




IMM-NRF51422 module 23x17mm with all I/O routed out.
IMM-NRF52832 module 23 x 17 mm with 30 I/O 
IMM-NRF52832-NANO ultra small 10 x7 x 1.6 mm

Available on

On Tindie
On CrowSupply

The software development environment with Eclipse & GCC


While there are several IDE options, I chose the Eclipse IDE because it fully free and available cross platforms Windows, OS X & Linux.


  • Follow the Eclipse page on this blog to setup the Eclipse development environment for ARM.   
  • Clone the EHAL source tree.   This can be done using git command line tools or use SourceTree from this site http://www.sourcetreeapp.com.  github : https://github.com/I-SYST/EHAL
  • Download the Nordic Bluetooth SDK from Nordic Semiconductor.  
  • Put the SDK in the appropriate folder as indicate bellow. 
  • Download the CMSIS SDK, follow the EHAL page to download and setup the environment.


The  development source tree should look like bellow :

/your_root     - Development root directory
 |-- external    - Contains downloaded SDKs from silicon vendors
 |   |-- CMSIS            - ARM CMSIS SDK for all ARM platform (download from ARM)
 |   |   |--CMSIS
 |   |   |...
 |   |-- nRF5_SDK_12    - Nordic SDK 12.3, nRF51 & nRF52 (download from nordicsemi.com)
 |   |   |   |-- components
 |   |   |   |-- examples
 |   |   |   |-- external
 |   |   |   |   |--- micro-ecc
 |   |   |   |   |   |--- micro-ecc - Micro-ECC (download from https://github.com/kmackay/micro-ecc)
 |   |   |   |...
 |   |.... 
 |   |-- nRF5_SDK    - Latest Nordic SDK 15.3, nRF52 only (download from nordicsemi.com)
 |   |   |   |-- components
 |   |   |   |-- examples
 |   |   |   |-- external
 |   |   |   |   |--- micro-ecc
 |   |   |   |   |   |--- micro-ecc - Micro-ECC (download from https://github.com/kmackay/micro-ecc)
 |   |   |   |...
 |   |-- BSEC - Bosch Sensortec Environmental Cluster (BSEC) Software (https://www.bosch-sensortec.com/bst/products/all_products/bsec)
 |   |....
 |-- EHAL      - Put the EHAL here
 |   |-- include     - Generic include common to all platform
 |   |-- src            - Generic source common to all platform
 |   |-- ARM
 |   |   |-- include    - Common include for all ARM platform
 |   |   |-- src           - Common source for all ARM platform
 |   |   |-- Nordic
 |   |   |   |--include - Common include for all nRF5x 
 |   |   |   |--src        - Common source for all nRF5x
 |   |   |   |-- nRF51 - Nordic nRF51x22 Target
 |   |   |   |   |-- CMSIS   - static library of CMSIS system functions for nRF51
 |   |   |   |   |-- EHAL    - Embedded Hardware Abstraction Library project for Nordic nRF51 (static lib)
 |   |   |   |   |   |-- include
 |   |   |   |   |   |-- src
 |   |   |   |   |-- exemples - exemple projects
 |   |   |   |   |   |--dfu      - SDK12 Secure DFU 
 |   |   |   |   |...
 |   |   |   |-- nRF52 - Nordic nRF52xx Target (except nRF52840)
 |   |   |   |   |-- CMSIS   - static library of CMSIS system functions for nRF52
 |   |   |   |   |-- EHAL    - Embedded Hardware Abstraction Library project for Nordic nRF52 (static lib)
 |   |   |   |   |   |-- include
 |   |   |   |   |   |-- src
 |   |   |   |   |-- exemples - example projects are in here
 |   |   |   |   |   |--dfu      - SDK13 Secure DFU 
 |   |   |   |   |...
 |   |   |   |-- nRF52840 - Nordic nRF52840 Target
 |   |   |   |   |-- CMSIS   - static library of CMSIS system functions for nRF52840
 |   |   |   |   |-- EHAL    - Embedded Hardware Abstraction project for Nordic nRF52840 (static lib)
 |   |   |   |   |   |-- include
 |   |   |   |   |   |-- src
 |   |   |   |   |-- exemples - example projects are in here
 |   |   |   |   |   |--dfu      - SDK13 Secure DFU 
 |   |   |   |   |...
 |--- private   - your own private working folder
   
Start Eclipse and set the Workspace to your private folder.  Select the 'import'  to import CMSIS and EHAL projects into the workspace.  Do the import project without copying files since it is already located inside the workspace.

Require change to compile the SDK with GCC in the file nrf_svc.h.  This file is located in headers folder of each Softdevice.  Nordic default cast was uint8_t.  This is wrong it needs to be casted cot uint16_t

        "bx r14" : : "I" ((uint16_t)number) : "r0" \

Cast (uint16_t) is needed if you compile C++ code.  The default startup code from the SDK does not work with C++.  Use the one from EHAL.  See example code for details.

Now you can start creating projects.  To create Eclipse projects for nRF51, follow the steps further down this page.

Migrating to SDK 12  

The new nRF5 SDK12 has changed a lot. There are many compile error for GCC with C++.  The extern "C" { was added to most .h files now but you may find compile error du to the fact that the opening was placed within a conditional define and the ending was outsite or vice versa.   The SDK also contains ridiculous conditional compilation in every source files.  By adding the source file to your project is not sufficient.  You need a also add those defines for each source.  So depending on how many sources you are using from the SDK.  You may ended up with hundreds of conditional compilation defines.  The EHAL lib is already updated to SDK12.  I am updating gradually the examples to SDK.  It will take some times to get all updated.


Compile bug in SDK14


File fstrorage.h in components/libraries/fstorage folder needs to be changed as follow :

line 115 : typedef struct nrf_fstorage_api const nrf_fstorage_api_t;
line 144 : nrf_fstorage_api_t * p_api;
line 174 : struct nrf_fstorage_api
line 188 : };

This bug is fixed in SDK15

CMSIS library


The CMSIS library project now includes build for RTX kernel in the build configurations.  Precompiled libs are available in github.  The default initialization of RTX version was modified to use RC oscillator so it can start on any nRF5x without the 32KHz Crystal.  The default RTX build from Nordic requires the 32KHz crystal to run.
  

Examples code :


Most of the examples code on this site are not Nordic examples.  They are written from scratch targeted to use with the IMM-NRF51822 module (see Hardware section bellow) and generic board.  To compile the examples, you need first compile the CMSIS library, few examples may need the EHAL library.  All BLE examples have accompanying iOS code as well.  iOS code is here : https://github.com/I-SYST/iOS

The Blinky_ble exemples is not actually to make the LED blink.  It is a custom service example that uses the iPad to configure the Gpio as input or output, turn it on/off, read it state. All 30 i/o can be controlled at once or individually.  Now SDK 8.

dfu_nrf51 is now the Eclipse project for SDK 8 DFU.  It contains only project file.  Source code are not in github.  Project has virtual link to source files in nrf51_sdk folder except for main.c and incude folder which need to be copy from the sdk sample over to DFU project folder.

dfu_sdk7 is the DFU Eclipse project for SDK 7.2.  Dfu BLE is now functional with iOS nRFToolbox 1.5.  Dfu Serial does not seems to work with nRFGo.  Currently I am too busy to debug it.  Let me know if you can get it to work in serial mode.

The LMXDisplay_ble is an example demonstrate the use of long write characteristic.  It gets a text message from a mobile device and  displays it on LED matrix multi-displays.  The LedMx library is used to control display on multiple IDM-LMX3208 series LED matrix display (See my Arduino page for more details).  The display controller is the IBB-LMXBLUE, which can dive up to 16 displays boards.

Different UART over BLE example than the one from Nordic.  This example uses only one characteristic for both TX and RX.  Uses app_uart API rather than simple_uart.

To create an Eclipse based project for nRF5x, see instruction at the end of this page.


Flashing the nRF51 & nRF52 


Nordic provides utilities to flash the nRF5x but those utilities only work with the JLink.   The Nordic development kit has an on board JLink that can be used to flash other board.  It can not be used to flash commercial products due to its usage license.  For commercial use, you need to buy the full JLink which is very expensive.   This section presents several methods to flash using the much cheaper alternative without a limited usage license.

Parallel gang Flashing nRF51 & nRF52 with IDAP-Link using IDAPnRFProg on OS X and Windows


IDAPnRFProg now allows flashing just Softdevice or combines with either app firmware and/or DFU.

IDAP-Link/M Software Download now support readback protection.  Available for OS X and Windows XP and above.

PM me if you need Linux version


Flashing Softdevice + Firmware + DFU

IDAPnRFProg s110_nrf51822_7.1.0_softdevice.hex Blinky_ble.hex dfu_sdk7.hex


$ ./IDAPnRFProg s110_nrf51_8.0.0_softdevice.hex Blinky_ble.hex dfu_nrf51.hex
IDAPnRFProg version 0.2
Copyright 2015, I-SYST inc. All rights reserved

Found IDAP-Link - S/N : 0000000000001
Found IDAP-Link - S/N : 0000000000002
IDAP-Link-0030415000005 : nRF51822-QFAA R2, Rev.2, HWID = 0x003C, DEVID = 0x299C1D17BD361134
IDAP-Link-0030415000005 : Flash size = 262144, Ram size = 16384
IDAP-Link-0030415000017 : nRF51822-QFAA R1, Rev.1, HWID = 0x001D, DEVID = 0x32B4DDFECEE22394
IDAP-Link-0030415000017 : Flash size = 262144, Ram size = 16384

IDAP-Link found : 2

IDAP-Link-0030415000005 : Erase Flash
IDAP-Link-0030415000017 : Erase Flash
IDAP-Link-0030415000005 : Blank checking...
IDAP-Link-0030415000017 : Blank checking...
IDAP-Link-0030415000005 : Programming...
IDAP-Link-0030415000017 : Programming...
IDAP-Link-0030415000005 : Firmware start address 0x18000
IDAP-Link-0030415000005 : DFU start address 0x3c000
IDAP-Link-0030415000017 : Firmware start address 0x18000
IDAP-Link-0030415000017 : DFU start address 0x3c000
IDAP-Link-0030415000005 : Programmed 256 KB in 21.524 sec at rate 11.894 KB/s
IDAP-Link-0030415000005 : Verifying...
IDAP-Link-0030415000017 : Programmed 256 KB in 21.524 sec at rate 11.894 KB/s
IDAP-Link-0030415000017 : Verifying...
IDAP-Link-0030415000005 : Flashing succeeded.
IDAP-Link-0030415000017 : Flashing succeeded.

Total Flashed 2 nRF51 devices in 51.112 sec, 1024 KB R/W transfered, rate = 20.035 KB/s



Flashing nRF5x using microSD card with IDAP-Link

Prerequisite :

Prio to use this Flashing method.  The IDAP-Link must set to nRF51 target.  Use the IDAPSetTarget command line program to set it.  Executing IDAPSetTarget without any argument will show a list of available target core.  Then execute IDAPSetTarget again with the nRF51 target index number to set it.  This is needed to be done only once.  IDAPSetTarget is needed again only when target change is needed.  The IDAP firmware can only recognized predefined file name when Flashing with this method.  File naming is preset by the target definition.  For nRF51 file name must be as follow:

Softdevice.hex - for softdevice
firmware.hex - Application firmware
DFU.hex - OTA Bootloader

It is not require to have all 3 files to flash.  Copy the require files onto a microSD card.  Insert it in the IDAP-Link.  Power the IDAP-Link.  Press ISP/Program button.  The green LED will light up.  When Flashing is done, all LED are off if successful.  Blink red LED if failed.  If the IDAP-Link is still connected to PC, make sure to eject USB MSC from the PC for better Flashing performance.  Normally it should take about 26s to flash all 3 hex files.  If the USB MSC is not ejected from the PC, it may take a lot longer depending how much access the PC is performing on the microSD.  It is due to PC access has priority over the internal access.

Flashing softdevice with OpenOCD.


Using low cost alternative IDAP-Link.  You can flash the softdevice using OpenOCD command.  Version 0.9 is require.  To install latest OpenOCD on OS X using the command

brew install --HEAD openocd

Then flash Softdevice with

openocd -f interface/cmsis-dap.cfg -f target/nrf51.cfg -c "program s110.hex verify"

Unlock nRF52 protection using OpenOCD

openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "program dap apreg 1 0x04 0x01"

Eclipse debugging using IDAP-Link with OpenOCD

Create an OpenOCD debug configuration.  Set the OpneOCD config option in the Debuger tab with :

-f interface/cmsis-dap.cfg
-f target/nrf51.cfg
-c "cms-dap-serial ###"

where ### is the serial # of IDAP-Link to use when multiple IDAP-Link are connected to the same PC (see IDAP-Link page for more details)









The Hardware


IMM-NRF51822, IMM-NRF51422 & IMM-NRF52832 


The IMM-NRF5x series are 23 x 17 mm micro-module with embedded PCB antenna.  It allows developers to take full advantage of the nRF5x series by making all its I/O available via 35 SMD/Through hole 1.27mm pitch pads.   The module can be mounted with header pins in order to re-use during development and prototyping phase and SMD it for production to be the most cost effective.  IMM-NRF51822 ModuleModule user man




IMM-NRF51822 and IMM-NRF51422 micromodule 23x17mm with all I/O routed out.

Also available on Tindie and SemiconductorStore


IBK-BLUEIO
Breakout PCB for the IMM-NRF5x modules available on
Tindie

I/O layout of the IMM-NRF51822 module.  All 30 I/O pins are routed to the pads.

Debug JTag connection


The IMM-NRF51822 micro-module has exposed the SWD (Serial Wire Debug) pins SWDIO & SWCLK, see I/O layout picture above. The module can be directly connected to a Jtag tool for development by wiring the 2 SWD pins to the appropriate pins on the Jtag connector. The VIN must be wire to the VCC pin on the Jtag. GND pad is also require to be connected to GND on Jtag.  The default JTAG supported by Nordic is the Segger.  Other low cost option is using CMSIS-DAP JTAG such as the IDAP-Link.  The IDAP-Link can also be used for production flashing multi-boards in parallel.  See IDAP-Link page for details.



IMM-NRF51822 mounted on breakout board connected to the IDAP-Link.
3.3v power is provided by the IDAP-Link.



Other accessories





UART to RS-232 Breakout board
Available on Tindie






Creating Eclipse project


To create a new nRF51 project with Eclipse, select New from the File menu then select either you want C or C++ project.  In the dialog, select the project type 'Hello World ARM ..." with toolchains 'Cross ARM GCC'.  Do not use any other templates.

Once the new project is created, open project settings dialog.  Change the target processor to Cortex-M0 for nRF51 and Cortex-M4 for nRF52

Set target processor to cortex-m0

There are a few preprocessor definitions require by the SDK.  If BLE stack not needed, only NRF51 or NRF52 is required.  If BLE stack is needed, the following are required

BLE_STACK_SUPPORT_REQD
NRF51

Preprocessor settings


In case of a C++ project, those preprocessor settings are also needed to be set in C++ preprocessor section.  Next are the include path settings.  Assuming the SDK is located in nrf51_sdk as described previously.  These are the minimum require include paths for BLE project.



For SDK 6 :

"${ProjDirPath}/src"
"${ProjDirPath}/../../EHAL/include"
"${ProjDirPath}/../../CMSIS/include"
"${ProjDirPath}/../../../../../include"
"${ProjDirPath}/../../../../CMSIS/CMSIS/include"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/sdk"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble/device_manager"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble/ble_services"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/sd_common"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/s110"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/app_common"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/gcc"
"${ProjDirPath}/../../nrf51_sdk/nrf51822/Include"

For SDK 8, the way the folders are organized is the worst.

"${ProjDirPath}/src"
"${ProjDirPath}/../../EHAL/include"
"${ProjDirPath}/../../CMSIS/include"
"${ProjDirPath}/../../../../../include"
"${ProjDirPath}/../../../../CMSIS/CMSIS/include"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_hids"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu/experimental"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/gpiote"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_debug_assert_handler"
"${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/ble_flash"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_error_log"
"${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/pstorage"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/trace"
"${ProjDirPath}/../../nrf51_sdk/components/softdevice/common/softdevice_handler"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/timer"
"${ProjDirPath}/../../nrf51_sdk/components/softdevice/s110/headers"
"${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/nrf_soc_nosd"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/util"
"${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/hal"
"${ProjDirPath}/../../nrf51_sdk/components/device"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/scheduler"
"${ProjDirPath}/../../nrf51_sdk/components/ble/common"
"${ProjDirPath}/../../nrf51_sdk/components/ble/device_manager"
"${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu/ble_transport"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_bas"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_dfu"
"${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_dis"

For SDK11

"${ProjDirPath}/src"
"${ProjDirPath}/../../EHAL/include"
"${ProjDirPath}/../../CMSIS/include"
"${ProjDirPath}/../../../../include"
"${ProjDirPath}/../../../../../include"
"${ProjDirPath}/../../../../CMSIS/CMSIS/include"
"${ProjDirPath}/../../../nrf5_sdk/components/device"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/bootloader_dfu"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/fstorage"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/gpiote"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/timer"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/scheduler"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/trace"
"${ProjDirPath}/../../../nrf5_sdk/components/libraries/util"
"${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/hal"
"${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/delay"
"${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/ble_flash"
"${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/pstorage"
"${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/common"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/common"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/device_manager"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/advertising"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/ble_debug_assert_handler"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/ble_error_log"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/ble_services/ble_bas"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/ble_services/ble_dfu"
"${ProjDirPath}/../../../nrf5_sdk/components/ble/ble_services/ble_dis"
"${ProjDirPath}/../../../nrf5_sdk/components/softdevice/common/softdevice_handler"
"${ProjDirPath}/../../../nrf5_sdk/components/softdevice/s130/headers"

There are a few to set in the linker settings as well.  First thing is the linker script.

for BLE project

"${ProjDirPath}/../../src/gcc_nrf51_s110_xxaa.ld"

Non BLE project

"${ProjDirPath}/../../src/gcc_nrf51_blank_xxaa.ld"

Linker settings
Require libraries and path in linker setting.  Minimum require is the CMSIS lib.  Set the library path to

"${ProjDirPath}/../../CMSIS/Debug"  - Debug build
"${ProjDirPath}/../../CMSIS/Release" - Release build

Optionally if EHAL is used, add EHAL to the lib and path

"${ProjDirPath}/../../EHAL/Debug"
"${ProjDirPath}/../../EHAL/Release"


Library & path for the linker


That's about it for project settings.  What's left to do is to add source code in the project.

Add source files


There are many files to be added to the project depending on what is require for the application.  One file must always be added to all projects is the Vector_nRF51.c.  It is located in scr folder in the nRF51 workspace.  It is the interrupt vector and the reset function.  It can be added by doing import then chose filesystem.



143 comments:

  1. Hi Nguyen,

    Thanks for your effort on the tutorial. Greatly appreciated.

    I had a few fun examples in Keil but I like to use Eclipse and GCC for being free. Now, it seems my Keil projects ported to Eclipse wont work, given me alot of weird errors, debugged, but when eventually compiled, it didnt work. :-(

    I am using Luna, Win7, SDK9.0 with bug fixes.

    I got lost much earlier than expected following through your tutorial.
    Importing the EHAL and CMSIS projects, I suppose to import 2 separate projects available in the workspace? is this expected? then if I am to use Blinky_ble, it will be the third?

    Project Explorer
    \
    |---CMSIS
    |---EHAL
    |---Blinky_ble

    Can you be able to share the screenshot of your project explorer tree of your Eclipse?please.

    I am Hardware Engineer by trade and relatively new to Eclipse, so I am not so familiar with jargons and work arounds.

    Thanks,
    Arthur

    ReplyDelete
    Replies
    1. Your imports look fine. Have you downloaded CMSIS library from ARM with the links I provided ? You should try Blinky first. Get it compile and download to the board using the debugger. Once you get that working, you can move up to Blnky_ble which will require Softdevice. Most of the errors are caused by wrong Path. Can you show me the errors ? I can't show the screenshot because my workspace have a lot of project. It will confuse you.

      Delete
    2. Thanks for the quick reply.
      I successfully built and tested the Blinky project.
      Now, stepping up to Blinky_ble, I had errors as below;
      .........pstorage.c:224:44: error: 'PSTORAGE_NUM_OF_PAGES' undeclared here (not in a function)

      In Keil, it is on "pstorage_platform.h", and the value is different depending on the project.
      The "pstorage_platform.h", in the EHAL "..../Blinky_ble/src" dont have the 'PSTORAGE_NUM_OF_PAGES' defined.

      So what I did add a line in pstorage.c, #define PSTORAGE_NUM_OF_PAGES 1.
      Now, I just randomly pick value of "1". How would I know?
      It did build successfully, and flashed the S110, and Application.

      Using nRF Master Control Panel, I did successfully connected, and the Pin 30 toggled to HI (always ON except disconnected).
      Now, should it suppose to blink? Should I send a value on a service?

      Thanks,
      Arthur

      Delete
    3. Replace the storage_platform.h from the Blinky_ble with the new file from the SDK9. The new is located in in the SDK9 under drivers_nrf/pstorage/config. Copy it over the Blinky_ble.

      Delete
    4. The GPIO 30 is used in to indicate connected state in the Blinky_ble project and most of my exemples code.

      Delete
    5. Thanks again.
      With Blinky_ble, my understanding in the gpiote_event_handler(), tries to read the GPIO level and pin location, then pass it to ble_blinkys_on_data_change(), but what is next after that?
      Then, what is the function of blinkys_write_handler()?

      Delete
    6. The ble_blinky_on_data_change() sends the data to the Central.
      The bliny_write_handler() is called when receiving data from the Central.
      See the accompanying iOS example code.

      Delete
    7. Thanks. Unfortunately I havent had iOS device. I used Android nRF Master control Panel.
      I tried to add IAS service and had no luck triggering to the on_ias_evt(). I'm not sure what I missed.

      Delete
    8. I haven't try Android yet. There are many Android applications on GooglePlay that allows you to scan for BLE device.

      Delete
  2. I am using nRF52 from nordic semiconductor. I have some problems popping up like:- make No rule to make target 'all'. Gcc not found and g++ not found. Eclipse and GCC is being used to run blinky program. I would be helpful If you could give me some suggestions on that.

    ReplyDelete
    Replies
    1. It looks like your Eclipse couldn't find the GCC compiler. Look in the Eclipse preference. There is a place where you can set the Path for the GCC compiler and toolset.

      Delete
  3. Now path is set. It overcome that problem. Now only left with the:- make No rule to make target 'all'. I am following this link too:-https://devzone.nordicsemi.com/tutorials/7/development-with-gcc-and-eclipse/ . Still Make error is there.

    ReplyDelete
    Replies
    1. Nordic uses makefies for their project. You should check the path in the makfile. I can try the nRF52 Blinky pure Eclipse project I posted here.

      Delete
  4. Nguyen,
    Thanks for posting this very enlightening article. I have been looking at the CC2541, but it requires a $3K development ide to just get started!
    Am I understanding you correctly that all the software that you used in your example was downloaded AT NO COST? If so, this is quite compelling, and may convince me to switch to the nRF51 device. Also, just to be clear, the IDAP-Link J-Tag probe and nRF51 module are the only hardware (besides a PC/mac) required?
    Thanks in advance.

    ReplyDelete
    Replies
    1. Hi,
      The SDK is provided by Nordic free of charge with full source code. But it's main support was Keil and J-Link. This blog is about alternative way to use free Eclipse & Gcc as environment to develop with nRF5x series. The IDAP-Link is a low cost alternative to the J-Link. The minimum requirements for development are the module, the breakout board and the J-Tag (IDAP-Link or J-Link).

      Delete
  5. Cám ơn bài hướng dẫn tuyệt vời của anh.

    Anh cho em hỏi. Em có thể dùng làm theo hướng dẫn của anh Flash cho board Nrf81822 này được không, Có cũng có các Pin SWD, SCLK ? Link board: http://world.taobao.com/item/523149247914.htm

    Cám ơn anh, Chúc anh sức khỏe

    ReplyDelete
    Replies
    1. Hello Mai,

      Em cần có một cái JTAG để flash. Dùng cái IDAP-Link để flash cũng được. Em xem trang IDAP-Link sẽ rõ hơn. Có thể mua nó ở semiconductorstore.com. Nếu cần hướng dẫn nhiều hơn thì mail cho anh biết.

      Delete
  6. Nguyen, thank you for the post!

    "The default startup code from the SDK does not work with C++. Use the one from EHAL. See example code for details."

    I couldn't find the c++ startup code. Where in EHAL can I find it? What steps do I need to take if I want to run c++ code on the nRF51?

    Thanks!

    ReplyDelete
    Replies
    1. Hi,

      The startup code is split in 2 section. The generic portion to all ARM cortex M is located in ARM/src. The file ResetEntry.c. It contains the reset initialization code. It is compiled in CMSIS library in each MCU. The specific protion per MCU is located in src of each. The file name starts with Vectors_xxx.c. It contains the interrupt vector mapping. This file is to be included in each executable project. You are also require the LD files for to use with the EHAL startup code

      Delete
    2. Thanks! For context: I am trying to compile the https://github.com/FastLED/FastLED cpp project with one of the nRF51 samples that are all written in c and have makefiles and startup code that is for c only.

      I'll try to work with the files you suggested

      Delete
    3. Were you successful in integrating the FastLED code?
      That would interest me...

      Delete
    4. I don't know about FastLED and haven't tried it.

      Delete
  7. Hi,
    Thank you for this wonderful tutorial. I was able to complete the setup and build your sample Blinky and UART BLE examples. However, these are all C projects and I could not find any C++ demo project in it. I tried creating a new C++ project but could not build it successfully. Could you please share any sample C++ project with BLE soft device enabled? Thanks so much

    ReplyDelete
    Replies
    1. Have you read my blog post about changes you need to do in the SDK code? The LMXDeisplayDemo is an Eclipse C++ project. It does not use BLE but you can easily add it.

      Delete
    2. Thank you directing me to this CPP project. However, I hit the below error when I build the project

      arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g -T C:\NordicProject\ARM\Nordic\nRF51\src\gcc_nrf51_blank_xxaa.ld -Xlinker --gc-sections -L"C:\NordicProject\ARM\Nordic\nRF51\CMSIS\Release" -L"C:\NordicProject\ARM\Nordic\nRF51\CMSIS\Debug" -Wl,-Map,"LMXDisplayDemo.map" --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lc -lm -lrdimon -Wl,--end-group -o "LMXDisplayDemo.elf" ./src/LMXDisplayDemo.o ./src/Vectors_nRF51.o -lEHAL
      c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: cannot find -lEHAL
      collect2.exe: error: ld returned 1 exit status
      make: *** [LMXDisplayDemo.elf] Error 1

      I have changed for all includes and linker directories from relative project path to absolute project path. Could you please help me resolve this error. Thanks

      Delete
    3. You need to compile the EHAL library.

      Delete
    4. Thank you so much. It worked! However, do you add C++ wrapper to all the nordic SDK files to get in compiled. Is there a quick workaround for this?

      Delete
    5. Wrap all Nordic include files within extern "C" { #include ... }

      Delete
  8. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
  9. Hi Hoang,
    I'm having issues getting things working in Eclipse. I have downloaded the CMSIS and EHAL as well as the Nordic SDK v.11. But I don't know where to begin as far as getting an example project working. I have the IDAP-link for programming the module, and two nrf51422 modules that I have soldered to the breakout board.

    I would like to implement a program to detect the proximity of two connected IMM-NRF51422 modules to each other. One module will be connected to a vibration motor, and if the two get too far apart, it will turn the motor on. I saw an example Proximity program in the BLE examples in the sdk under the BLE peripheral folder. I plan on starting there once I am able to figure out how to use Eclipse.

    For now, I could use your help with understanding how to start with the basics of how to get a simple program set up in eclipse and programmed onto the board. I hope you see this soon, I'm under a bit of a time crunch.

    Thanks, Taylor

    ReplyDelete
    Replies
    1. I have updated some of the examples to the new SDK11. You can import them to try.

      Delete
  10. What is a good low cost ARM SWD programmer to use with these? Will Nucleo board from ST work as a SWD programmer -- one of those is coming in the mail already.

    Thanks,

    John in Texas

    ReplyDelete
    Replies
    1. You can use the IDAP-Link. See the IDAP-Link page. It is a full CMSIS-DAP Debug J-Tag. Compatible with all major IDE such as KEIL, CrossWorks, IAR, Eclipse & OpenOCD, etc... The ST may work too. Some people use it but I haven't tried it myself.

      Delete
  11. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
  12. Hi!

    Can you comment about the tools paths when using SDK11? Thanks for the awesome post

    ReplyDelete
    Replies
    1. The location of the SDK11 is shown in the folder tree at the top of this blog page. Some of the examples (Blinky, Bliky_ble,...) have been ipdated to SDK11. You'll find all the path in the project settings.

      Delete
    2. Sorry, I wasn't clear enough.

      I was talking about the include paths for SDK11. You have already mention this for SDK6 And SDK8. i wonder if those are the same for SDK11. Thanks again

      For SDK 6 :

      "${ProjDirPath}/src"
      "${ProjDirPath}/../../EHAL/include"
      "${ProjDirPath}/../../CMSIS/include"
      "${ProjDirPath}/../../../../../include"
      "${ProjDirPath}/../../../../CMSIS/CMSIS/include"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/sdk"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble/device_manager"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble/ble_services"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/sd_common"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/ble"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/s110"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/app_common"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include/gcc"
      "${ProjDirPath}/../../nrf51_sdk/nrf51822/Include"

      For SDK 8, the way the folders are organized is the worst.

      "${ProjDirPath}/src"
      "${ProjDirPath}/../../EHAL/include"
      "${ProjDirPath}/../../CMSIS/include"
      "${ProjDirPath}/../../../../../include"
      "${ProjDirPath}/../../../../CMSIS/CMSIS/include"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_hids"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu/experimental"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/gpiote"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_debug_assert_handler"
      "${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/ble_flash"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_error_log"
      "${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/pstorage"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/trace"
      "${ProjDirPath}/../../nrf51_sdk/components/softdevice/common/softdevice_handler"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/timer"
      "${ProjDirPath}/../../nrf51_sdk/components/softdevice/s110/headers"
      "${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/nrf_soc_nosd"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/util"
      "${ProjDirPath}/../../nrf51_sdk/components/drivers_nrf/hal"
      "${ProjDirPath}/../../nrf51_sdk/components/device"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/scheduler"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/common"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/device_manager"
      "${ProjDirPath}/../../nrf51_sdk/components/libraries/bootloader_dfu/ble_transport"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_bas"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_dfu"
      "${ProjDirPath}/../../nrf51_sdk/components/ble/ble_services/ble_dis"



      There are a few to set in the linker settings as well. First thing is the linker script.

      for BLE project

      "${ProjDirPath}/../../src/gcc_nrf51_s110_xxaa.ld"

      Non BLE project

      "${ProjDirPath}/../../src/gcc_nrf51_blank_xxaa.ld"

      Delete
    3. One more time, THANK YOU. I'll try to set up all .

      Delete
    4. One more time, THANK YOU. I'll try to set up all .

      Delete
  13. How can I buy the IMM-NRF52832?.
    Is there any example to send like 10 or 100KB of data with at baud rate of 115200 or 9600 over BLE between two nrf52 dk (central and peripheral)? because the example in Nordic "ble_app_uart_c" when I program the one as central and the other as peripheral, I just get 260 bites received.

    ReplyDelete
    Replies
    1. Unfortunately Central mode is very slow. Only optimization you can do is to reduce the connection interval. Use only notification to send 20 bytes at time. Long write is very slow. You can never achieve 100KB for sure.

      Delete
  14. thanks for the answer!! is there any documentation of the practical maximum data rate and the acceptable amount of data that can be sent over BLE in Nordic nrf52 dk (is it using a GATT BLE profile ? ) ?

    ReplyDelete
    Replies
    1. All docs are avail on Nordic Devzone and on bluetooth.org

      Delete
  15. Hi Nguyen Hoan Hoang

    Thanks for pointing out your site to me.

    I am interersted in doing some BLE Beacon type work with IOS Apps.

    Any guidance you can give would be appreciated.

    Iain

    ReplyDelete
    Replies
    1. You'll need to get a hardware kit. You buy the IMM-NRF5x module showed in this blog along with a breakout board and the IDAP-Link (see IDAP-Link page) or the Nordic DK. Then download Nordic SDK and follow my guide on this page to setup your eclipse development environment. There are example code here to get you going with Eclipse and iOS. The Nordic SDK has a lot more example code which also include a Beacon example. There are quite some learning you need to go through.

      Delete
  16. We want to use the IMM-NRF52832, the question is when we are currently using the nrf52 dk development board we program is with keil micro vision / J-tag (via USB).
    When the size is then so small like in the future with the IMM-NRF52832, how can we program it (are there pins to connect)?.

    ReplyDelete
    Replies
    1. The SWD and all I/O pins are routed out on the edge of the module.

      Delete
  17. thanks a lot Nguyen Hoan Hoang :) !! when is the IMM-NRF52832 available for ordering ?

    ReplyDelete
    Replies
    1. It is being produced. We'll have some available in about a week or so.

      Delete
  18. great !! please keep us updated when and how to order as soon as they're available

    ReplyDelete
    Replies
    1. I received the IMM-NRF52832 from production.

      Delete
    2. Great !! can you send the link to order the IMM-NRF52832 ?

      Delete
    3. Now available on Tindie https://www.tindie.com/stores/hnhoan/

      Delete
  19. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
  20. hi,
    i am working on Eclipse IDE for ble_hrs example from the nRF_SDK.
    i have created work space on desktop and created one source file.
    in which i placed all files which i have needed from nRF_SDK. and include all the file paths(bcoz getting errors like .h file not found) by c/c++ Build->paths and symbols.
    then it worked fine all files are building (with out including main.c of example ble_hrs).
    but while calling functions(which are present in nRF_SDK source files) from my main.cpp like SOFTDEVICE_HANDLER_INIT(CLK_SRC, NULL) and time_init i am getting bugs which i am unable to solve.
    please help me to solve this.
    and how to initialise softdevice (priority of calling softdevice functions ormacros).

    ReplyDelete
    Replies
    1. Have you tried to encapsulate the __cplusplus, extern thing I told you about ?

      Delete
    2. hi, thank you its working fine. but while calling softdevice_enable() i am getting. undefined reference to `__data_start__' y i am getting these errors continuously.

      Delete
    3. i mean how the code can recognise symbols present in the linkerScript. and memory restriction like this.
      MEMORY
      {
      FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000
      RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x6000
      }

      Delete
    4. You are missing main linker script.

      Delete
  21. hi i am using nRF51 development kit. i have gone through your blog build was successful it is creating release folder in which i am getting .elf file. but if i want to flash to file by using debug configuration option i am getting fallowing message.

    Error in services launch sequence Launching command [/JLinkGDBServerCL.exe -if jtag -device nRF51822_xxAA -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0 -nogui] failed. Launching command [/JLinkGDBServerCL.exe -if jtag -device nRF51822_xxAA -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0 -nogui] failed. Cannot run program "/JLinkGDBServerCL.exe": Launching failed

    please help me from this..

    ReplyDelete
    Replies
    1. Is the path to your JLinkGDBServerCL.exe good ? Check the path make sure that you have installed Segger driver software

      Delete
    2. Target halted (DBGRQ, PC = 0xFFFFFFFE)
      Reading all registers
      Read 4 bytes @ address 0xFFFFFFFE (Data = 0x049182A0)
      Read 2 bytes @ address 0xFFFFFFFE (Data = 0x0000)
      Read 4 bytes @ address 0xFFFFFFF4 (Data = 0x00000000)
      Read 4 bytes @ address 0xFFFFFFF0 (Data = 0x00000000)
      Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
      Read 4 bytes @ address 0xFFFFFFF4 (Data = 0x00000000)
      Read 4 bytes @ address 0xFFFFFFF4 (Data = 0x00000000)
      Read 4 bytes @ address 0xFFFFFFFF (Data = 0x00FFFFFF)


      unable to flash code to nrf51

      Delete
    3. Are you using softdevice ? if you do, then first you need to flash the softdevice in using nrfjprog from Nordic. There are instructions on the devzone. You need only do this once. Second make sure you use the right linker script for the softdevice version you are using s110 or s120 or s130.

      Delete
    4. i am using s130 .ld file is

      MEMORY { FLASH (rx) : ORIGIN = 0x00020000, LENGTH = 0x20000
      RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x6000 }

      all ready added soft device to nrf51 kit using nRFGO studio. but unable to flash blinky through eclipse. getting some register information and stopping procedure.

      Delete
    5. your memory map is wrong. For S130 of SDK11.

      FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
      RAM (rwx) : ORIGIN = 0x20002100, LENGTH = 0x5F00

      Delete
    6. even i updated the .ld file no progress getting same issue.

      Delete
    7. Which blink example are you using ? You may have bad firmware

      Delete
  22. hi,
    i have created new project(in eclipse IDE) like blinky in which i added main.c from (sdk blinky example) and added required files from nrf SDK10 (added s130 nrf51_xxaa.ld as linker script). and compiled it (which is creating debug folder in my project including .elf and .hex files) i am trying to flash generated .elf file using eclipse IDE on PC10028. using run configuration. (is my procedure is ok).

    ReplyDelete
    Replies
    1. here the my project source tree https://www.dropbox.com/sh/01jssfvr7c5rlhp/AAAPEOsJGnsw2YmzJ6XVLKpBa?dl=0

      Delete
    2. SDK10 memory map is different. The one I gave you was for SDK11.
      SDK10 I believe FLASH should be 0x1c000. Check the HRS example to be sure. You will also need to re-flash the softdevice. It might be corrupted be previous flashing off your app at wrong location.

      Delete
  23. hi,
    i am working on accelerometer adxl335 with nrf51 development kit. i want to get readings of accelerometer by connecting to nrf51 development kit. the code is available in this link https://github.com/NordicSemiconductor/nrf51-ADC-examples.(ble_app_uart_adc_simple).

    i am connecting x out put of adxl335 to p0.01(analog input of nrf51 kit). so i am getting strange values on uart(in windows termite). which is increasing by one every time even i am changing the direction of the accelerometer. please help me from this.

    ReplyDelete
    Replies
    1. I think by default the example is sample the internal vcc. You need to configure the adc to sample from external pin.

      Delete
  24. Hi Nguyen,

    Thanks for this great tutorial. I was slightly confused in the beginning with the tree structure and getting the EHAL and CMSIS projects compiled without errors, but going through the comments helped and I got it right.

    I have two problems though.

    1. I don't know why I have the two projects, CMSIS and EHAL?
    2. I have the DK for nRF52 with PCA10040 and I can't seem to get your blinky program working. It compiles and debugs without errors and I start it in debug perspective, but not getting any leds to blink. Any advice?

    Thanks again for great write up.

    ReplyDelete
    Replies
    1. The default pin map is for the blueio breakout board. To use with the Nordic DK, you need to change the pin defines to match it.

      Delete
  25. Hi,

    I have set up the Eclipse and GCC according to Nordic blog, and using the nRF_SDK_12.2.0_ble_app_hrs_pca10040.zip as the project file. It compiles, loads and debugs as expected with the nRF52DK. When I switch to Segger Jlink and IMM-NRF52832, it programs without problem, and almost work. I use the iOS app from Nordic, I can see the device boardcast, get connected, but no Heartrate received. I also enabled the serial log, it works fine as well. I also used the prebuilt hex file, ble_app_hrs_pca10040_s132.hex, same behaviour. BLE discovered, connected, but no data. Can you think of anything?

    ReplyDelete
    Replies
    1. Hi,

      I don't know for sure but I think it needs the buttons on the DK. What happen if you modify the code to use the button on the IBK-BLUEIO breakout board ? Or wire up a button to the same pin as on the DK.

      Delete
  26. Hi,

    do you have an estimate when IDAP-Link will be again in stock at Tindie?

    I apologise if this is not the right place to ask this question, please direct me if this is the case.

    BR,
    Borut

    ReplyDelete
    Replies
    1. If you are not in a hurry, the new batch would come in about 4-6 weeks. If you are in a hurry then contact me via email.

      Thanks,
      Hoan

      Delete
  27. hi sir i am working on NRF52 to get MMA8652FC accelerometer data i am using twi driver to read XYZ data from MMA8652. when i do nrf_drv_tx and nrf_drv_rx operations it is returning NRF_SUCCESS for both operations but i am unable to get read data to buffer here is my code.

    #define MMA8652_I2C_ADDR 0X1D
    uint8_t err_code;
    uint8_t rx_data[6] = {0};
    uint8_t tx_data = MMA8652_REG_OUT_X_MSB;
    err_code = nrf_drv_twi_tx(&m_twi_mma_8652, MMA8652_I2C_ADDR, &tx_data, sizeof(tx_data), false);
    while(m_xfer_done == false);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_twi_rx(&m_twi_mma_8652, MMA8652_I2C_ADDR, rx_data, sizeof(rx_data));
    APP_ERROR_CHECK(err_code);
    unable to get data to rx_data buffer

    can you help me out
    https://drive.google.com/open?id=0ByjgT_Zt3YyJS2tKQko3cW10SlU

    ReplyDelete
    Replies
    1. What do you mean by not getting data ? What do you get in rx_data ? Have you hook up a logic analyzer to check the signal ?

      Delete
  28. Hi Hoan,
    Need to know what versions of softdevice and bootloader are shipped on the IMM-NRF51822 module to get back to a baseline. I purchased this module and an IDAP-LINK for project development, I successfully used IDAPSetTarget and IDAPnRFProg_1_2_170726, but after programming no BLE is discovered and "DFUTarg" is no longer discovered. I need to restore IMM-NRF51822 back to as hipped condition so I can troubleshoot.
    Thanks Roy

    ReplyDelete
    Replies
    1. Hi,
      The modules are shipped empty. You probably had a very old version which is no longer supported. You can use the latest Nordic SDK 12. The Softdevice is provided with the SDK. The DFU source is provided in the Nordic SDK. An Eclipse native project to compile the DFU is available via Github link at the top of the page.
      Best
      Hoan

      Delete
    2. Hi Hoan, I got the Eclipse Mars environment setup and can compile both your sample apps and also the Nordic SDK examples and dfu. I have been unable to get anything that downloads and reports as verified using IDAPnRFProg to actually be detected by nRF Connect. The DFU start address is 0x35C00 and the App Start Address is 0x1B000. Am I missing some other step to getting things flashed properly? I am building everything with nRF_SDK version 12.3.0

      Delete
    3. Hi Hoan, I am trying to debug using J-Link debugger, and not able to single step. Is the blinky project that you have on github configured expecting a 32 kHz crystal to be attached to IMM-nRF51822 or should it run without one? If it is setup to use the crystal, is it easy to switch to the internal oscillator for a quick test.

      Delete
    4. You can run without the crystal. All you need to do is to change the code to use RC oscillator instead. I haven't tested Blinky_ble for a while. Try the UartBleDemo and the PTHSensorTag. Those should work. Make sure you flash the Softdevice that came with SDK12.

      Delete
    5. For DFU, try compile in Release build. Debug build may not work well.

      Delete
    6. Hi Hoan, The DFU Release build uses a DFU start address of 0x3a800 instead of 0x35c00 does that make sense? I am still not able to get anything to run. Also when debugging with J-Link it does not reach the breakpoint in main.c and is not giving any source in the DEBUG Perspective, perhaps I have some other build environment issue.

      Delete
    7. Yes, they are not at the same address because compile result does not have the same size. For debugging, you need to first flash softdevice + dfu that you want to debug then you can debug in Eclipse. This is particular to DFU due to softdevice jumping to App if UICR is not written with dfu start address. I just recompile and tested the dfu. It showed up in nRFConnect correctly. email me, i'll send you my hex file to try.

      Delete
    8. Thanks Hoan, my email is roy.greenwood@enginasion.com
      I am also having an issue trying to use OpenOCD, I get "undefined debug reason 7 - target needs reset" when I try to debug, perhaps this is related to not having the soft device and dfu properly loaded.
      I went back through the complete tutorial and rebuilt my Eclipse Mars folder structure carefully to match what you have in the blog, everything is compiling using nRF_SDK12.2 as recommended. I am able to build dfu.hex, and PTHSensorTag.hex I will be interested to see whether or not your hex file works, do I load just your dfu.hex or combine it with
      s130_nrf51_2.0.1_softdevice.hex

      Delete
    9. You need to load SD + DFU. DFU alone will not work.

      Delete
  29. Hi,

    I am working on NRF52 custom board with 3.7mA 27mAH battery, working on BLE app UART example SDK11 with SoftdeviceS132V2.0.

    I made BLE advertise for 20 sec interval on button action, if I observe current across the Battery it is continuously showing 57microAmp. Once I connect the device with NRF Tool box app through BLE the and if send any command to operate PWM current across the Battery increases to 6mA. After disconnecting BLE and also stoping PWM the current reading is still 6mA and not dropping back to 50microAmp.

    Could you please suggest me what to do so that the current drops back to initial stage i.e 57microAmp

    Thank you in advance.

    ReplyDelete
  30. Hi,
    regarding above Question i am using BLE command to start PWM then current consumption is increasing to 6mA. i commented some of the lines and tested for current consumption so i found that in PWM
    ret_code_t app_pwm_channel_duty_set(app_pwm_t const * const p_instance,
    uint8_t channel, app_pwm_duty_t duty)
    {
    uint32_t ticks = ((uint32_t)app_pwm_cycle_ticks_get(p_instance) * (uint32_t)duty) / 100UL;
    return app_pwm_channel_duty_ticks_set(p_instance, channel, ticks);
    }

    is the cause of the problem and also that to the line

    uint32_t ticks = ((uint32_t)app_pwm_cycle_ticks_get(p_instance) * (uint32_t)duty) / 100UL;

    which is doing arithmetical operation is the issue.

    ReplyDelete
    Replies
    1. Have you check the pwm disable code ? I guess the timer may still be on. This question is better asked on the Nordic Devzone. There are Nordic employee that can answer this since it's their code. I have not used this part of the SDK. I don't know how it is done internally.

      Delete
  31. Hi there,

    thanks for the tutorial, great work.

    I have managed to setup Nordic Semi SDK 14 and the gcc-arm-none-eabi toolchain, examples compile and work with the supplied make files in the directories, which is cool.

    I also installed Eclipse C/C++ and MCU which and setup the project with all files needed, compiles and links with no errors, uploading the hex file to
    the device via nrfjprog works fine ... but the it the code does not seem to execute. Flashing the original example hex file works fine.

    Building and uploading with Keil MDK works without a problem.

    What are the common errors here ? I concatenated the ld files (common + example ld file), checked that the same compile and linker commands and options are used. The elf files are different and the lengths of the hex files as well as .o files are different. I just do not understand why this is the case if the same compiler and options are used ... I am sure there is something obvious I am missing.

    I am running out of ideas ... any nudge into the right direction would be great.

    Regards,
    Mark

    ReplyDelete
    Replies
    1. Hi,
      First thing is to check whether Softdevice was flashed prior to flash your code. I have not used nrfjprog so I don't know how it manage it. Look for mergehex on the forum. Second thing to check is the linker script if you compiled with GCC. Setting in the LD about all those SECTION vars may have bugs. Compare them with mine. Usually the error was the missing of "> RAM AT > FLASH". Replace all the "> RAM" with "> RAM AT > FLASH". Third check the memory mapping in the LD file.

      Delete
    2. Thanks Nguyen,

      I found the problem and I think it is somehow interesting.

      While moving around the files I came across the ld file in the example directory and saw that it had an INCLUDE directive to load the nrf5x_common.ld file. Because I thought I am brilliant I just concat both files so replacing the INCLUDE directive with the linker code of the file to be included.

      As it turned out it was not so brilliant as it seems to make some sort of a difference because readelf -S would show a slightly different mapping than the original file compiled with the SDK makefile and it would not execute on the chip.

      Then I put both files into the eclipse workspace, removed the INCLUDE directive in the original example ld file and added this file and the nrf5x_common.ld to the eclipse MCU linker configuration.

      Now it works like a charm ! It is interesting though that concating the two files does generate problems.

      On nrfjprog, pretty simple to use, it is part of the Nordic Semi command line tools and needs Segger JLink tools to be installed on the system. The syntax then looks something like this

      nrfjprog -f NRF52 --program ./BlinkyNRF52.hex --sectorerase --reset

      Regards,
      Mark

      Delete
    3. It is possible to put all in one but you'll need reorder the sections to group them up.

      Delete
  32. tying to follow this tutorial ...and am completely lost ..after many hours

    ReplyDelete
    Replies
    1. How can I help ? Have you gone through Eclipse setup page and the EHAL page ? This page is for setting up the development specific to nRF5x series.

      Delete
    2. Nguyyen,
      thank you for your quick reply to my confusion.
      I set up the file structure that you proposed - The development source tree should look like bellow :
      Select the 'import' to import CMSIS and EHAL projects into the workspace - as import project from folder or archive
      C:\eclipse_dev\CMSIS then again C:\eclipse_dev\ehal and fixed "bx r14" : : "I" ((uint16_t)number) : "r0" \

      Now you can start creating projects. To create Eclipse projects for nRF51, follow the steps further down this page.
      have no idea what i'm to do

      what is this and do I have to enter it by hand ?
      For SDK11

      "${ProjDirPath}/src"
      "${ProjDirPath}/../../EHAL/include"
      "${ProjDirPath}/../../CMSIS/include"
      "${ProjDirPath}/../../../../include"
      "${ProjDirPath}/../../../../../include"
      "${ProjDirPath}/../../../../CMSIS/CMSIS/include"
      "${ProjDirPath}/../../../nrf5_sdk/components/device"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/bootloader_dfu"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/fstorage"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/gpiote"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/timer"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/scheduler"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/trace"
      "${ProjDirPath}/../../../nrf5_sdk/components/libraries/util"
      "${ProjDirPath}/../../../nrf5_sdk/components/drivers_nrf/hal"

      I'm lost - please help me understand ..... I would like to work with nRF5x series have worked a little with Keil but that too seems not to work for me ( building examples on standard Nordic Dev boards ) is ok but the next steps are rather frustrating as I haven't go a grasp on the concepts, thought Eclipse would be simpler

      Thanks again

      Delete
    3. The current EHAL is with SDK14 for nRF52 and SDK12 for nRF51. All the EHAL project that you imported already have the paths set. The paths are needed only when you create a new project of your own.

      Delete
  33. ok I impoted them .....now I have a project explorer with project starting with AdcDemo .....ending with UartRetargetDemo ..

    I have Blinky as an example How do I build it ?
    00:26:24 **** Incremental Build of configuration Debug for project Blinky ****
    make all
    make: *** No rule to make target 'C:/eclipse_dev/private/src/Vectors_CC3200.c', needed by 'src/Vectors_CC3200.o'. Stop.

    00:26:24 Build Finished (took 139ms)

    ReplyDelete
    Replies
    1. I think you imported the wrong project CC3200 is the TI CC3200 not Nordic nRF5x. You need to import from the target folder ARM/Nordic/nRF51 for nRF51 ARM/Nordic/nRF52 for nRF52

      Delete
  34. ok ....makes sense
    so what do I do now to empty and start again? and given that I'm following your file structure I should import what from where
    ie: C:\eclipse_dev\CMSIS\CMSIS C:\eclipse_dev\ehal <-- which selection there are many ..

    ReplyDelete
  35. |-- EHAL - Put the EHAL here
    | |-- docs - Contains EHAL Doxygen documentations. (https://i-syst.github.io/docs/EHAL/)
    | |-- include - Generic include common to all platform
    | | |-- bluetooth - Generic definition for Bluetooth
    | | |-- converters - Generic definition for ADV, DAC, etc...
    | | |-- miscdev - Generic definition for other non categorized devices
    | | |-- sensors - Generic definition for al sort of sensors (environmental, motion, etc...)
    | | |-- usb - Generic definition for USB
    | |-- src - Generic implementation source common to all platform
    | |
    | |-- ARM - Cortex-M series based MCU
    | | |-- include - Common include for all ARM platform
    | | |-- src - Common source for all ARM platform


    which ones this import is a bit confusing for me ...

    ReplyDelete
    Replies
    1. I already gave the answer in the previous comment
      EHAL/ARM/Nordic/nRF51 for the nRF51
      EHAL/ARM/Nordic/nRF52 for nRF52

      Delete
  36. sorry to be such a pain, but have been at it for a few hours

    when running blinky I get path errors
    Description Resource Path Location Type
    Invalid project path: Include path not found (C:\eclipse-dev\external\CMSIS\CMSIS\Core\Include). Blinky pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\CMSIS\CMSIS\Core\Include). CMSIS pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\CMSIS\CMSIS\Core\Include). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_advertising). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_db_discovery). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_services\ble_dis). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\common). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\nrf_ble_gatt). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\peer_manager). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\device). Blinky pathentry Path Entry Problem

    when I looked at the archive of C:\Users\walter\Downloads\ARM.CMSIS.5.2.0.pack\CMSIS\ core only has Template
    it seems that the inc path should be C:\Users\walter\Downloads\ARM.CMSIS.5.2.0.pack\CMSIS\Include\

    on the extracted workspace its the same of course C:\eclipse-dev\external\CMSIS\CMSIS\Core has only Template and
    C:\eclipse-dev\external\CMSIS\CMSIS\Include has the includes

    I don't know what is wrong .........please comment thank you

    ReplyDelete
    Replies
    1. I just downloaded the new CMSIS_5-5.2.0. After extracting it, the Include folder is still inside Core as well as Templates. Are you sure you didn't moved it by mistakes ?

      Delete
  37. i downloaded the ARM.CMSIS.5.2.0.pack which has the problem
    CMSIS_5-develop.zip from git is ok so that now is fixed ....

    what is the min that I can import -> C:\eclipse-dev\EHAL\ARM\Nordic\nRF51 1- nRF51 2 nRF51\CMSIS 3 nRF51\EHAL 4- nRF51\exemples\blinky when I do that I get
    Description Resource Path Location Type
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_advertising). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_db_discovery). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\ble_services\ble_dis). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\common). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\nrf_ble_gatt). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\ble\peer_manager). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\device). Blinky pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\device). CMSIS pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\device). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\clock). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\common). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\delay). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\hal). Blinky pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\hal). CMSIS pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\hal). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\rng). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\drivers_nrf\twi_master). EHAL pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK_12\components\libraries\bootloader\dfu). EHAL pathentry Path Entry Problem

    ReplyDelete
    Replies
    1. Have you downloaded the Nordic SDK12 and put it there ?

      Delete
  38. ops ..... nRF51_SDK_12 was named wrong ....

    mow only
    Description Resource Path Location Type
    cannot find -lEHAL Blinky C/C++ Problem
    impossible constraint in 'asm' EHAL line 69, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\softdevice\s130\headers\nrf_svc.h C/C++ Problem
    make: *** [makefile:44: Blinky.elf] Error 1 Blinky C/C++ Problem
    make: *** [src/subdir.mk:138: src/ble_app_nrf51.o] Error 1 EHAL C/C++ Problem
    'void sec_req_timeout_handler(void*)' defined but not used [-Wunused-function] ble_app_nrf51.cpp /EHAL/src line 821 C/C++ Problem
    asm operand 0 probably doesn't match constraints EHAL line 69, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\softdevice\s130\headers\nrf_svc.h C/C++ Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK\components\device). Blinky pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK\components\device). CMSIS pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK\components\drivers_nrf\hal). Blinky pathentry Path Entry Problem
    Invalid project path: Include path not found (C:\eclipse-dev\external\nRF5_SDK\components\drivers_nrf\hal). CMSIS pathentry Path Entry Problem
    in expansion of macro 'SVCALL' EHAL line 1452, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\softdevice\s130\headers\ble_gap.h C/C++ Problem
    in expansion of macro 'SVCALL' EHAL line 523, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\softdevice\s130\headers\ble_gattc.h C/C++ Problem
    in expansion of macro 'SVCALL' EHAL line 614, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\softdevice\s130\headers\ble_gatts.h C/C++ Problem

    ReplyDelete
  39. Building target: Blinky.elf
    Invoking: Cross ARM C Linker
    arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -mabi=aapcs -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g3 -T "../../../src/gcc_nrf51_blank_xxaa.ld" -Xlinker --gc-sections -L"../../../CMSIS/Debug" -L"../../../EHAL/Debug" -Wl,-Map,"Blinky.map" --specs=nano.specs -o "Blinky.elf" ./src/Vectors_nRF51.o ./src/main.o -lEHAL
    c:/program files (x86)/gnu tools arm embedded/7 2017-q4-major/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lEHAL
    collect2.exe: error: ld returned 1 exit status
    make: *** [makefile:44: Blinky.elf] Error 1

    ReplyDelete
    Replies
    1. You need to compile both CMSIS & EHAL projects in both Debug & Release before compiling any example projects.

      Delete
  40. ok ....
    here is the error when I build the debug version ( i don't know how to set up release ver in Eclipse)

    Description Resource Path Location Type
    make: *** No rule to make target 'C:/eclipse-dev/EHAL/ARM/Nordic/src/nrf_log_backend_printf.c', needed by 'src/nrf_log_backend_printf.o'. Stop. EHAL C/C++ Problem
    'bool TphgBme680::vbSpi' [-Wreorder] tphg_bme680.h /EHAL/include/sensors line 460 C/C++ Problem
    when initialized here [-Wreorder] tphg_bme680.h /EHAL/include/sensors line 275 C/C++ Problem
    'TphgBme680::vbGasData' will be initialized after [-Wreorder] tphg_bme680.h /EHAL/include/sensors line 463 C/C++ Problem
    'void sec_req_timeout_handler(void*)' defined but not used [-Wunused-function] ble_app_nrf51.cpp /EHAL/src line 821 C/C++ Problem
    no return statement in function returning non-void [-Wreturn-type] tph_ms8607.cpp /EHAL/src/sensors line 120 C/C++ Problem
    no return statement in function returning non-void [-Wreturn-type] tph_ms8607.h /EHAL/include/sensors line 184 C/C++ Problem
    unused variable 'bsec_status' [-Wunused-variable] tphg_bme680.cpp /EHAL/src/sensors line 529 C/C++ Problem
    unused variable 'count' [-Wunused-variable] tph_ms8607.cpp /EHAL/src/sensors line 298 C/C++ Problem
    unused variable 'crc' [-Wunused-variable] tph_ms8607.cpp /EHAL/src/sensors line 108 C/C++ Problem
    unused variable 'd' [-Wunused-variable] diskio_flash.cpp /EHAL/src line 70 C/C++ Problem
    unused variable 'regaddr' [-Wunused-variable] tphg_bme680.cpp /EHAL/src/sensors line 469 C/C++ Problem
    unused variable 'retval' [-Wunused-variable] tph_ms8607.cpp /EHAL/src/sensors line 180 C/C++ Problem
    unused variable 't2' [-Wunused-variable] tph_ms8607.cpp /EHAL/src/sensors line 255 C/C++ Problem
    unused variable 'timeout' [-Wunused-variable] tph_bme280.cpp /EHAL/src/sensors line 370 C/C++ Problem

    ReplyDelete
    Replies
    1. I update the files. You can the new one and recompile.

      Delete
  41. Thank you for all your help and patience. I finally got blinky compiled I was looking at your BLUEIO_BOARD pinouts
    Is this a product? I saw your tindie catalog and there was no mention of the BLUEIO_BOARD.
    also IMM-NRF52832-NANO shows FCC logo is it certified for use in CANADA and USA? Your manual makes no mention of the certification which would be important to integrate into a commercial product


    Merci et bonne nuit

    ReplyDelete
    Replies
    1. The defines for BLUEIO_BOARD are for the Breakout boards for the IMM-NRF5 series of products that you see on the page. The IMM-NRF52832 is fully FCC/CE certified. The IMM-NRF52832-NANO is a new product. It is in the process of certification. Should be completed around Q3 time frame.

      Delete
  42. since I got blinky working, tride the examples from nRF51 with the following errors :

    Description Resource Path Location Type
    'BLUEIO_UUID_BASE' was not declared in this scope UartBleDemo.cpp /UartBleDemo/src line 122 C/C++ Problem
    'BLUEIO_UUID_UART_RX_CHAR' was not declared in this scope UartBleDemo.cpp /UartBleDemo/src line 93 C/C++ Problem
    'BLUEIO_UUID_UART_SERVICE' was not declared in this scope UartBleDemo.cpp /UartBleDemo/src line 76 C/C++ Problem
    'BLUEIO_UUID_UART_SERVICE' was not declared in this scope UartBleDemo.cpp /UartBleDemo/src line 123 C/C++ Problem
    'BLUEIO_UUID_UART_TX_CHAR' was not declared in this scope UartBleDemo.cpp /UartBleDemo/src line 105 C/C++ Problem
    cannot convert 'bool' to 'app_timer_evt_schedule_func_t {aka long unsigned int (*)(void (*)(void*), void*)}' for argument '4' to 'uint32_t app_timer_init(uint32_t, uint8_t, void*, app_timer_evt_schedule_func_t)' Uart_ble line 160, external location: c:\eclipse-dev\external\nrf5_sdk_12\components\libraries\timer\app_timer.h C/C++ Problem
    fatal error: ble_db_discovery.h: No such file or directory ble_app.h /EHAL/include line 42 C/C++ Problem
    fatal error: bsec_interface.h: No such file or directory TPHSensorTag.cpp /TPHSensorTag/src line 57 C/C++ Problem
    fatal error: nrf5x_uart.h: No such file or directory main.cpp /Uart/src line 40 C/C++ Problem
    make: *** [makefile:59: BleAdvertiser.elf] Error 1 BleAdvertiser C/C++ Problem
    make: *** [src/subdir.mk:20: src/main.o] Error 1 Uart_ble C/C++ Problem
    make: *** [src/subdir.mk:20: src/TPHSensorTag.o] Error 1 TPHSensorTag C/C++ Problem
    make: *** [src/subdir.mk:20: src/UartBleBridge.o] Error 1 UartBleBridge C/C++ Problem
    make: *** [src/subdir.mk:20: src/UartBleDemo.o] Error 1 UartBleDemo C/C++ Problem
    make: *** [src/subdir.mk:34: src/main.o] Error 1 Uart C/C++ Problem
    make: *** No rule to make target 'C:/eclipse-dev/EHAL/ARM/Nordic/nrf5_sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c', needed by 'src/nrf5_sdk/softdevice/common/softdevice_handler/softdevice_handler.o'. Stop. Blinky_ble C/C++ Problem
    make: *** No rule to make target 'C:/eclipse-dev/EHAL/ARM/Nordic/nrf5_sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c', needed by 'src/nrf51_sdk/softdevice/common/softdevice_handler/softdevice_handler.o'. Stop. LMXDisplay_ble C/C++ Problem
    make: *** No rule to make target 'C:/Users/walter/eclipse-workspace/nrf51_sdk/components/libraries/button/app_button.c', needed by 'src/nrf51_sdk/app_button.o'. Stop. Beacon C/C++ Problem
    undefined reference to `BleAppAdvStart' BleAdvertiser.cpp /BleAdvertiser/src line 97 C/C++ Problem

    ReplyDelete
    Replies
    1. Sorry about that, I have updated UartBleDemo. I've been working a lot on the nRF52832 lately. Didn't have the chance to fully update the nRF51. The dev branch is the most up to date.

      Delete
  43. ok Thank - when you have it all fixed and tested please let me know.
    also can you fix exemples should be examples

    ReplyDelete
    Replies
    1. Fixed UartBleDemo, Advertiser, TPHSensorTag. You need to recompile EHAL project.

      Delete
    2. btw : exemples is the correct word. It is nnot a mistake. It's French for examples.

      Delete
  44. oh bien sûr - c'est bon comme ça !! Merci

    ReplyDelete
    Replies
    1. Un petit peu hors de l'ordinaire fait toujours du bien, n'est-ce pas?

      Delete
  45. Dear HOANG,

    how can i make a batch file witch flashes the SOFTDEVICE an the .hex File?

    Could you help me pls.

    Best Regards,
    Markus

    ReplyDelete
    Replies
    1. Hi,

      That depends on the jtag tool you are using.

      - For Jlink, use nrfjprog from Noridc. See Nordic website for instruction.
      - For IDAP-Link, use IDAPnRFProg. See Flashing nRF51 & nRF52 section of this blog.

      Best,

      Hoan

      Delete
  46. Hello Hoan,

    I have developed my own PCB with the nRF51822 chip and I am trying to follow your tutorial to start with the firmware implementation but I am lost.

    Do I need to import every folder as you say above or that its just for your examples?

    Can I just import the EHAL and the SDK for nRF51x libraries to start or it won't work?

    Thank you for your work and I hope you could help me,

    Alex :)

    ReplyDelete
    Replies
    1. You need to install the SDK as mentioned above and import 2 libraries project into your work space CMSIS & EHAL. There are also many example projects you can import. Select the location of the processor you want to use. It will list all available projects. Select only those you you want to use.

      Delete
  47. Sorry I forgot one thing, to start a new project you just mention that we have to change between Cortex M0(nRF51x) or M4(nRF52x) but what about the clock, flash and RAM size??

    Thanks again!

    ReplyDelete
    Replies
    1. The processor clock settings are all in the CMSIS project. It includes system initialization and interrupt vector. The setting for Flash & Ram size for each firmware project is defined in linker script and need to be included with each firmware project. Each MCU has its own generic version in nRF51/src or nRF52/src.

      Delete
  48. Hello. firstly so glad i found this link as i have been trying to get going with the nRF52832. I have the dev board from Nordic. All i want to do is use this board in BT mesh mode and send the onboard temp from each board to a "home" board. Is this possible? I have looked at fruitymesh on github and been researching for about 3 weeks now. Thanks

    ReplyDelete
    Replies
    1. Yes, it is possible. You can use full Nordic SDK Mesh with it.

      Delete
  49. Hi,

    Thank you for this blog. I have been trying to follow your tutorial for a couple of days now but I am finding it confusing. Can you please help me ? I am trying to develop a BLE application for your nrf51422 breakout board. I am using eclipse in linux. This is my current folder structure:

    root-folder: nrf-projects

    nrf-projects
    |--external
    ||||--CMSIS
    ||||--nRF_SDK_12
    |--EHAL
    |--private

    Steps I followed:
    1. Set eclipse workspace to 'nrf-projects'.
    2. Imported all the projects
    3. Built 'CMSIS' project ---SUCCESSFUL
    4. Built 'EHAL' project -- FAILED (.../EHAL/src/sensors/tphg_bme680.cpp:91:28: fatal error: bsec_interface.h: No such file or directory)
    5. Wanted to build some of your examples, but failed couldn't reach here as previous step failed

    This is where I am stuck.

    Few more questions:
    Do I have to build CMSIS and EHAL to try out your examples? What else do I have to do to try out the examples ?


    Looking forward to hearing back from you
    Thank you for your help!

    ReplyDelete
    Replies
    1. You need to download the BSEC library. The link is provided on the folder layout.

      Delete
    2. Hi,

      Sorry for late reply. I didn't get the notification about your message. The BME680 requires a library to be download from Bosch website. I have the link for the download on the folder tree layout. CMSIS & EHAL lib are required for the examples. Yo need to compile them first.

      Delete
  50. Hi Hoang, I am using NINA-B301 EVK with nRF52840 chipset. I could flash program with SEGGER Embedded Studio and nrfjprog command line tool . We are interfacing nRF52840 with i.MX6 CPU using USB hardware interface. Please let me know how can I port driver and basic test application with i.MX6 CPU build linux environment.

    ReplyDelete
    Replies
    1. I am not sure to understand what you want to do. Which driver are you referring to ?

      Delete
  51. Hi Hoang, I’ve just gotten your IDAP-Link and I’m trying to use it on an ISP1507 module (with a nRF52832) we have mounted on a PCB. We have Vcc, Ground, SWDIO, & SWDCLK lines we run to a programing connector that is connected to the IDAP-LINK 16 (pin) connector’s 3.3(14), ground(13), SWDIO(2), and SWDCLK(4) 1:1. Using a hex file we know is working for this board I keep getting “target not found” when I try either IDAPnRFProg or the SD card method (after using “IDAPSetTarget 2”)
    We can successfully program the target board using jumpers off Nordic’s nRF52832 eval board connected to the same pins using their nrfjprog software.
    I’ve tried with and without the 8K SD card installed. The IDAP-Link’s firmware is the current latest on sorceforge 1.6.181013 which I updated in my attempts to get this working. The IDAPnRFProg is 1.6.190113
    Can you make any suggestions on what to try or look for to get this system working together? perhaps I should try failing back to a build you know will work for this chip? Thanks

    ReplyDelete
    Replies
    1. Hi,

      The 3.3v on the IDAP connector is an optional power source that you can use to power your board. If your board is self-powered, then it is not required. However, you need to connect your board power (VCC) to the IDAP pin 1 (TVCC) Target VCC. That pin is required so that the IDAP can translate logic level to match your board. IDAP can flash target device from 1.75V- 3.6V. In resume for SWD to work TVCC, GND, SWDCLK, SWDIO.

      Delete
    2. This comment has been removed by the author.

      Delete
  52. Thank you Nguyen, after adding this jumper and improving the connections I was able program the unit with the IDAPnRFprog software.

    ReplyDelete
  53. Thank Nguyen, very informative material from your blog.!!!

    ReplyDelete