Skip to content

Build and Run your first Zephyr example

This section details how to build and run the simple Blinky example.

Before you start building, remember to set up the Zephyr development environment first:

Build the Blinky example

Now it's ready to build your first Zephyr example. Will use the Blinky example here to keep it simple.

The Blinky example shows how to blink the GREEN LED. The source code is located in examples/zephyr/blinky.

  1. Open terminal and navigate to the m2devkit directory created in the Setup the toolchain section:

    cd <sourcecode_root>/m2devkit
    
  2. Use west to build the example:

    west build -b nrf52840_m2 nrf52840-m2-devkit/examples/zephyr/blinky
    

Tip

If a build system is present, make the build folder pristine before building:

west build -t pristine

Flash the example

After compiled successfully, the firmware is located in m2devkit/build/zephyr with the name zephyr.hex.

Connect the debugger USB port to your PC using the provided USB-C Cable. A disk drive called M2-DOCK will be automatically detected by the computer.

Run the following command to flash the board:

west flash

After programmed, the application will run automatically. Observe that the LED will start to blink as shown in this figure:

Blinking

Next steps

Check out more Zephyr examples for nRF52840 M.2 Developer Kit:

Create an Issue

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