Categories
Allgemein

Getting Started with the nRF52840 DK

Introduction

Getting started to work with the NRF52840 this semester has been more challenging than expected. This post should clear up the most commonly encountered pitfalls when setting up a development environment. This will hopefully also help others facing similar issues.

Setup

Hardware setup:

  • Mac
  • Micro-USB 2.0 cable

Software setup:

  • MacOS
  • SEGGER J-Link Software

You can download the SEGGER J-Link Software utile on the official website and follow the setup instructions of the wizard.

For this post a Mac with macOS Catalina v. 10.15.1. was used.

Getting Started

For getting started, the NRF52840 Devkit User Guide was used to take the first steps.

First, some required applications should be downloaded and set up.

  1. For this purpose, we are using Visual Studio Code. You can obtain this software on the website and download it.
  2. Used compiler: GNU/GCC. Follow this instruction to set it up.
    1. Download the file:
      gcc-arm-none-eabi-9-2019-q4-major-mac.tar.bz2
    2. Unzip file
      tar -tf gcc-arm-none-eabi-9-2019-q4-major-mac.tar.bz2
    3. Make a directory to install it:
      mkdir /usr/local/gcc_arm
    4. Move the unzipped file
      sudo mv ~/Downloads/gcc-arm-none eabi-9-2019-q4-major/ /opt/local/gcc_arm
    5. Check the directory
      ls /opt/local/gcc_arm/arm-none-eabi/
    6. echo current path variable
      echo $PATH
    7. Add this path also to ./profile so that you don’t have to add this line to the path every time:
      vi ~/.profile
      export PATH="$PATH:/usr/local/gcc_arm/bin/"
    8. Check if everything was successful
      arm-none-eabi-gcc --version
  3. The next step is to download the Software Development Kit (SDK). For this semester project version 16.0.0 has been used (take a look here).
    Simply download the zip file and extract it where you want to set up your workspace.

Now that we have everything we need, we can actually start testing the development kit. Let’s start with the precompiled Blinky example. Therefore, follow these steps.

  1. Connect the boards to the computer with a USB cable.
  2. Make sure that the power switch is set to “on”.
  3. In the SDK directory open the Blinky example
    examples\peripheral\blinky
  4. In the hex folder, you find all the precompiled hex files. For the NRF52840 you choose blinky_pca10056.hex
  5. Now you can copy the hex file to the board.
    1. Therefore, open the finder.
    2. Now go to the _build folder and copy the hex file.
    3. As you can see in the picture below, you will find the “JLINK” driver under “Locations”. Open that folder and insert the hex file.
    4. The board will now restart and run the application.
  6. Finally, you should be seeing the blinking leds.

Of course, instead of just flashing binaries onto the target board it is essential to understand how to compile the source code. In order to compile a project, follow these steps for the blinky example.

  1. First, open the Makefile which is in the folder \blank\armgcc
  2. On the row 129 change Makefile.common to Makefile.posix
  3. Open the Makefile.posix file and change the path and version
  4. Now open the terminal in the …\armgcc folder and run the command make
  5. Now you got a _build folder and you will find the right hex file in there. According to point 5 from the precompiled blinky example you can copy this file to your board.

The benefit of using the blinky example for this guide is that you do not have to deal with the softdevice. The softdevice contains functionality for the BLE stack (and other functionality) and is proprietary and thus only exists in binary form.

Some examples require the softdevice.  For those examples you find the softdevice numbered folder in the pca10056 folder. In most cases where you need the BLE Stack, you will need to flash softdevice s140. In order to do so, open the terminal in the folder containing the makefile and run the command make flash_softdevice.

Hopefully, this post has helped you getting started on your own project. Let me know in the comments if it was helpful to you.

Leave a Reply

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