# Building and Programming an Application

### Building an application: the wild wild **West** way :smile:

`west` is the swiss-army knife command-line tool for Zephyr. Zephyr provides several `west` extension commands for building, flashing, and interacting with Zephyr programs running on a device.

To build an application, navigate to the `conexio-firmware-sdk` directory that we installed [<mark style="color:red;">previously</mark>](/master/building-and-programming-an-application/fetch-stratus-sample-applications.md) and choose a sample application. Here we will choose the `led_blink` sample.

> `/opt/nordic/ncs/v2.6.0/conexio_firmware_sdk/samples/conexio_blitz/led_blink`

This sample tests two different functionalities of the BLITZ device:

1. The user-programmable LED on the mainboard.
2. That the USB serial communications are working correctly and the log output gets printed on the terminal window.

To compile the application, open the terminal in the sample application directory as described [<mark style="color:red;">here</mark>](/master/programming-and-debugging/nrf-connect-sdk-ncs-installation.md)  and issue the following `west` command.

For the BLITZ device, the build command is:&#x20;

> `west build -b conexio_blitz_cpuapp`

## Updating Through USB

You can update the BLITZ application firmware over USB by using MCUboot, which is a secure bootloader that you can use to update applications without an external debugger.

### Flashing an application: DFU Mode (Device Firmware Upgrade)

BLITZ device comes preprogrammed with the MCUBoot bootloader allowing users to directly update the firmware via the USB interface. **Each sample is already configured to enable the Zephyr application to be booted by the MCUBoot after resetting the board.**&#x200B;​&#x20;

This is handled internally by the Zephyr configuration system and is wrapped in the `CONFIG_BOOTLOADER_MCUBOOT` Kconfig variable, which is enabled in the application’s `prj.conf` file as&#x20;

> `CONFIG_BOOTLOADER_MCUBOOT=y`

More information can be found [<mark style="color:red;">here</mark>](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/readme-ncs.html).

After the compilation has been completed, you will notice a `build` folder being generated, which will contain the following binary:

> build/zephyr/app\_update.bin

{% hint style="info" %}
&#x20;When an application is built with the option `CONFIG_BOOTLOADER_MCUBOOT` set, `app_update.bin`, a signed variant of the firmware in binary format (as opposed to intelhex) is automatically generated and can be used for firmware over-the-air (FOTA) upgrades.
{% endhint %}

To program the BLITZ via USB, you will need to put the device into DFU mode first. This mode triggers the onboard bootloader that accepts firmware binary files. To enter DFU mode:

* Hold down BOTH the buttons
* Release only the RESET button, while holding down the MODE/USER button
* Wait for the white LED to turn on (steady-state)
* Release the MODE button

The device now is in DFU mode. 🚨

Flash the compiled firmware using `newtmgr`:

> `newtmgr -c serial image upload build/zephyr/app_update.bin`

Give it a few seconds for the transfer to complete and then, hit the `RESET` button. You should now see the LEDs blinking every second. If you have a serial logger such as TeraTerm, Putty, or similar, select the correct COM port and set the baud rate = 115200, hit the `RESET` button, and notice the following being printed on the console window:

```
SPM: NS image at 0x20200
SPM: NS MSP at 0x20015528
SPM: NS reset vector at 0x21a31
SPM: prepare to jump to Non-Secure image.
*** Booting nRF Connect SDK v2.6.0 ***
Hello from conexio_blitz
```

Now you are all set! Stratus is alive and ready for development :clap:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.conexiotech.com/getting-started-with-conexio-blitz/conexio-blitz-overview/programming-and-debugging/building-and-programming-an-application/building-and-programming-an-application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
