Skip to content

How to Program the nRF52840 M.2 Module


The M.2 Dock included in the Developer Kit features a fully-integrated DAPLink debugger, which enables you to program and debug the nRF52840 M.2 Module.

This section describes how to program the nRF52840 M.2 Module using the M.2 Dock. You have the following two options to program your module:

Prepare for Programming

  1. Mount the nRF52840 M.2 Module
  2. Connect the Debugger USB port to your PC using the provided USB-C Cable
  3. A disk drive called M2-DOCK will be automatically detected by the computer.

Drag-n-Drop Programming

Drag-n-Drop is an optional intuitive programming feature. It allows programming of your target MCU in a very simple way: dragging and dropping a file (.hex-format) onto the M2-DOCK drive.

There is no need to install application software. Anyone that can drag and drop a file to a USB memory stick can now program the target module.


Upon completion, the drive remounts. If a failure occurs, the file FAIL.TXT appears on the drive containing information about the failure.

Using pyOCD Command Tool

pyOCD is an open source Python package for programming and debugging Arm Cortex-M microcontrollers using the DAPLink debugger. It is fully cross-platform, with support for Linux, macOS, and Windows.

The latest stable version of pyOCD can be installed via pip as follows. Skip the installation if pyOCD already exists.

pip install -U pyocd

List information about the debugger connected to your computer by running:

pyocd list

The output should be similar as below:

  #   Probe                   Unique ID
  0   ARM DAPLink CMSIS-DAP   10283602185129a100000000000000000000000097969902

The following commands demonstrate how to flash/erase the nRF52840 M.2 Module:

  • To erase the whole flash of the nRF52840 target:

    pyocd erase -t nrf52840 --chip
  • To flash the nRF52840 target with .hex-format firmware:

    pyocd flash -t nrf52840 Sample.hex
  • To flash the nRF52840 target with a plain binary:

    pyocd flash -t nrf52840 --base-address 0x1000 Sample.bin
    The --base-address option is used for setting the address where to flash a binary. Defaults to start of flash.


Run pyocd --hlep to get the available commands and additional help.


Create an Issue

Interested in contributing to this project? Want to report a bug? Feel free to click here: