Learn, Implement and Share

Nordic Semiconductor and ARM KEIL Build and Flash Toolchain
Nordic Semiconductor and ARM KEIL Build and Flash Toolchain
nRF52840 Running Blinky Program

This Tutorial is a part of nRF52840 IOT Tutorial Series.

nRF52840 ToolChain and nRF5 SDK Setup

In this tutorial, we will be discussing the steps to set up the Software Build Toolchain [ Windows OS ] in ARM KEIL MDK v5 for nRF52840. We will also set up the Toolchain for CMSIS-DAPLink Flashing and Debugging. We will concentrate on the Seeedstudio Grove Mesh Kit nRF52840-MDK IOT Development Kit which has a DAPLink for Flashing and Debugging compared to the Official Development Kit from Nordic Semiconductor which has a J-Link Debugger. I will also Explain the ARM GCC ToolChain setup also in case you don’t want to use the ARM KEIL Microcontroller Development Tools.

I will explain to you how to modify and use the nRF5 SDK from Official Release of Nordic Semiconductor as well as I will explain to you how to use the nRF52840-MDK release from makerdiary especially for the hardware.

Setting Up ARM Keil MDK and µVision® IDE

MDK helps us to create embedded applications for ARM Cortex-M Processor based devices. MDK is a powerful, yet easy to learn and use development system. It consists of MDK-Core and software packs, which can be downloaded and installed based on the requirements of our application. MDK-Core consists of the genuine Keil µVision IDE and debugger with leading support for Cortex-M processor-based microcontroller. MDK includes two ARM C/C++ Compilers with assembler, linker, and highly optimize run-time libraries tailored for optimum code size and performance.

There are different editions of MDK Available :

  • MDK-Lite is code size restricted to 32 KByte and intended for product evaluation, small projects, and the educational market.
  • MDK-Essential supports Cortex-M processor-based microcontrollers up to Cortex-M7 and non-secure programming of Cortex-M23 and M33 targets.
  • MDK-Plus adds middleware libraries for IPv4 networking, USB Device, File System, and Graphics. It supports ARM Cortex-M, selected ARM Cortex-R, ARM7, and ARM9 processor-based microcontrollers. It also includes DS-MDK for programming heterogeneous devices.
  • MDK-Professional contains all features of MDK-Plus. In addition, it supports IPv4/IPv6 dual-stack networking, IoT connectivity, and a USB Host stack. It also offers secure and non-secure programming of Cortex-M23 and M33 targets as well as multicore debugging of heterogeneous devices including the Linux kernel and Streamlines performance analysis.

Out of all these MDK-Lite is free and all other requires a License to Use. I recommend you to use the Lite Version if you are not making very big applications. It is enough for Learning Purpose.

1. Download the latest Installer of MDK-ARM from the Below Link.

 https://www.keil.com/demo/eval/arm.htm

2. Start the Installer and follow the instructions to install MDK-Core on your local computer. The installation also adds the software packs for ARM CMSIS and MDK Middleware.

3. After the MDK-Core installation is complete. Download the Device Family Pack from Below Link.

 https://www.keil.com/dd2/nordicsemiconductor/nrf52840_xxaa/ 

4. Start the Installer and follow the instructions to install the Device Family Pack.

5. Once both the MDK-Core and Device Tree is Installed, start the Keil uVision5 Application. You should see something like below.

6. If you click the Pack Installer Button you will get a window like below. You should be able to find Nordic Semiconductor -> nRF52 Series -> nRF52840_xxAA. You should also be able to find ARM::CMSIS, Keil::ARM_Compiler, Keil::MDK-Middleware. These are important components for the projects to build.

Setting Up the nRF5 SDK from Nordic Semiconductor

nRF5-SDK
nRF5-SDK

Software development kit for the nRF52 series and the nRF51 series SoC. The nRF5 SDK is your first stop for building fully featured, reliable and secure applications with the nRF52 and nRF51 Series. It offers developers a wealth of varied modules and examples right across the spectrum including numerous Bluetooth Low Energy profiles, Device Firmware Upgrade (DFU), GATT serializer and driver support for all peripherals on all nRF5 Series devices. The nRF5 SDK will almost certainly have something for your needs in developing exciting yet robust wireless products.

1. Download the latest ZIP of nRF5 SDK from the Below Link

 https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK 

2. Extract the Zip in a Folder. You should have the subfolders like below.

nRF5 SDK Folder Structure
nRF5 SDK Folder Structure

3. Install the nRF5x_MDK_8_24_1_Keil4_NordicLicense.msi

Verify Installation using Example Blinky Project

1. Download the below Blinky Project for testing nRF52840 Build and Flash ToolChain Setup.

2. Extract the Zip in Below Path. You should have something like the below picture. The build is path-sensitive.

\nRF52\nRF5_SDK_15.3.0_59ac345\examples\peripheral\

3. Open the File Blinky_www.ArnabKumarDas.com.uvprojx , You should be able to see something like below picture.

4. Select the Rebuild Option / Icon from the Top Bar.

5. Once the rebuild is complete you should see no errors and a .hex file will be created.

6. Connect the nRF8540 Hardware to the USB of the PC. It should Power on and a Green LED next to the USB Type-C Connector. Now Press the LOAD Option / Icon or F8 on Keyboard

7. After that, the Flashing will progress and once you see a message similar to the below one press the reset button on the Board and the LED should blink and change colour.

Load "E:\ELECTRONICS\nRF52\nRF5_SDK_15.3.0_59ac345\examples\peripheral\Blinky_www.ArnabKumarDas.com\_build\nrf52840_xxaa.axf" 
Erase Done.
Programming Done.
Verify OK.
Flash Load finished at 23:57:11

8. If nRF52840 Build and Flash ToolChain Setup don’t go around as expected. Please retry or write in comments.


Crazy Engineer

MAKER - ENGINEER - YOUTUBER

7 Comments

Rahul · July 14, 2019 at 1:33 pm

This is really helpful tutorial.

Jithin · January 23, 2020 at 1:23 pm

Hey i get this error while compiling…

Error: *** Project ‘Blinky_www.ArnabKumarDas.com’, Target ‘nrf52840_xxaa’, Device ‘Nordic Semiconductor::nRF52840_xxAA’ is not supported by Toolchain ! ***.

    Crazy Engineer · January 29, 2020 at 3:10 pm

    I am not sure why you get this error. Are you using the correct toolchain?

    Abdul Wasey · March 4, 2021 at 11:22 am

    I am also getting the same error have you got any solution so far?

dt · October 19, 2020 at 3:53 pm

Thank you for the tutorial. I arrived at step 4 Rebuild and got 16 errors listed below. Could you advise on the solution?

Thanks

Rebuild started: Project: Blinky_www.ArnabKumarDas.com
*** Using Compiler ‘V5.06 update 6 (build 750)’, folder: ‘C:\Keil_v5\ARM\ARMCC\Bin’
Rebuild target ‘nrf52840_xxaa’
creating preprocessor file for boards.c…
creating preprocessor file for main.c…
compiling boards.c…
“no source”: Error: #5: cannot open source input file “..\..\..\components\boards\boards.c”: No such file or directory
..\..\..\components\boards\boards.c: 0 warnings, 1 error
compiling main.c…
main.c(52): error: #5: cannot open source input file “nrf_delay.h”: No such file or directory
#include “nrf_delay.h”
main.c: 0 warnings, 1 error
creating preprocessor file for app_error_handler_keil.c…
creating preprocessor file for app_error.c…
compiling app_error.c…
“no source”: Error: #5: cannot open source input file “..\..\..\components\libraries\util\app_error.c”: No such file or directory
..\..\..\components\libraries\util\app_error.c: 0 warnings, 1 error
compiling app_error_handler_keil.c…
.
.
.
.

assembling arm_startup_nrf52840.s…
creating preprocessor file for system_nrf52840.c…
compiling system_nrf52840.c…
“.\_build\nrf52840_xxaa.axf” – 16 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:03

    Crazy Engineer · October 21, 2020 at 10:16 am

    Probably the include folders are not added into the build chain. Add the path to the project build properties.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.