Nordic Chip Programming (using nRF Connect Programmer software)

Nordic Chip can be nRF52840, nRF52832, nRF9160

Methods of Programming Nordic Chips

There are 4 ways of loading your program onto Nordic chip.

  1. Debug header (for use of programming of the full image of the chip memory *.hex). This can be done using nRF52840-DK or nRF9160-DK board as a J-LINK programmer, or using a J-LINK programmer like the j-link Base, j-link BASE Compact or J-Link EDU Mini Programmer.
  2. USB Bootloader (USB Wired DFU, programming of the non-boot loader, application memory *.hex). This can be done using the onboard USB peripheral.
  3. Bluetooth Firmware Loader (Wireless DFU, programming of the non-boot loader, application memory *.bin). This can be done when your chip is pre-flash with bootloader firmware and SoftDevice firmware.
  4. USB Mass Storage (drag and drop *.hex file into the JLINK storage drive to automatically program the chip). This can be done through the nRF52840-DK or nRF9160-DK board.

Tools Required

  • An nRF52840-DK kit board to act as the programmer for the chip
  • nRF Connect Software

Extra programmer tool like the j-link Base, j-link BASE Compact or J-Link EDU Mini Programmer may come in handy when the tool or chip fails. Besides for nRF chip, this j-link programmer can also be used for other microcontroller chip listed on this page -> click here for supported devices J-Link.

Debug Header Method

This is the most fundamental method of loading in firmware into the Nordic nRF52840 chip.

Connect up the nRF52840-DK or nRF9160-DK kit. They are used as a programmer in this example. These boards contains a programmer chip that uses Jlink driver for connection as a programmer, to upload *.hex file into the nRF52840 or nRF9160 chips.

There is typically 3 *.hex module that you need to load into the chip’s memory. Namely,

  • Bootloader
  • Soft-Device
  • Your Application

Different chip has its own memory map where the *.hex file should be loaded to. Here is the memory map for nRF52832, nRF52840.

Memory Map of nRF52832 and nRF52840

Go to the software “nRF Connect” and open the “Programmer” program.

You will come to the screenshot as follows.

Selecting Programmer Board

There is a drop-down list on the top.
When you board is connected, there should be an option in the drop down list for you to choose from. Select the programmer shown in the list.

If there is no board listed even when you got your board connected to the computer. You may also see error message in red color at the log box below. Check out the last section to see if there is a solution to resolve your problem.

Load Bootloader *.hex file

Bootloader *.hex file is the part that allows you to use USB cable to directly load the program into the chip.

It enables the chip to be able to receive it firmware through wired USB.

Click on the “Add HEX file” on the right side. Choose the bootloader that you want to use.

On the memory map, you will see green (bootloader sectors in use) on the top and bottom of the memory map.

Load SoftDevice *.hex file

SoftDevice is a bluetooth stack codes that you can choose to load into the chip.

There are many version to choose from. You can download them from S132 SoftDevice.
https://www.nordicsemi.com/Software-and-tools/Software/S132

Click “Add HEX file” again to load SoftDevice *.hex file.

The SoftDevice *.hex file is loaded in the other memory of the chip. You can see from the purple color zone in the memory map shown on the right side box.

Load Application *.hex file

Lastly, this is the *.hex file for your custom application.

Click on “Add HEX file” again and select the *.hex file of your application.

Download Code into the Chip

Click on the button “Erase & write” to start down loading the firmware containing the 3 sector of the *.hex code into the chip at one go.

nRF52840, “Hello World” Example

Let’s use a simple project “Blinky” as our hello world example to help you kick start your chip programming experience.

Problem Encounter Case Study

Problem encounter from, nRF Connect -> Programmer

Problem “Error occured when get serial numbers”

Error encounter:
Error while probing devices: Error occured when get serial numbers. Errorcode: CouldNotCallFunction (0x9) Lowlevel error: INVALID_OPERATION (fffffffe)numbers.

This error occurred if JLINK driver is not installed on the system.

Problem “Unsupported device. The detected device could not be recognized as neither JLink device nor Nordic USB device.”

This error occurred when the JLink driver is not working.

(doesn’t work) May need to reinstall SEGGER J-Link driver. Install version 6.22g. Download the J-Link Software and Documentation Pack from

https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack

Solution 2, can consider reinstalling “nrfprog tool” as the previous example.

Problem: The nRF Programmer got hang when connecting to the nRF9160 chip. Log message halt at “Using nrfjprog to communicate with target”

Somehow during one of the attempt to program the nRF9160 chip on Thingy91, the programmer halt.

Upon retry to connect with the chip, the log always stops at “Using nrfjprog to communicate with target”.

It doesn’t happens to the nRF52840 chip on the Thingy91. Only the nRF9160 chip is affect.

I thought it was a hardware issue. Alan from Avnet managed to recover this hang sequence by using the following command (program via command prompt)

> nrfjprog -f UNKNOWN --eraseall

Once this command is issue, the block is clear and the chip can be program normally.

<- Back to Bluetooth Resources Page