> For the complete documentation index, see [llms.txt](https://headtracker.gitbook.io/head-tracker-v2.2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://headtracker.gitbook.io/head-tracker-v2.2/support/development/firmware-using-gitpod.io.md).

# Firmware using GitPod.io

{% hint style="info" %}
As of Apr 7, 2024 this is the easiest way to compile the firmware.
{% endhint %}

Using Zephyr's west tool to compile the code is quite a bit more powerful and makes using this code with different hardware easier.\
\
The downside of this is it's not as easy to get your build chain setup. I suggest using GitPod to get started. It allows quick code changes and easy building of firmware without having to install anything on your computer. If you want to hook up a debugger you will need to  setup the toolchain on your computer. [How to setup on your local PC](/head-tracker-v2.2/support/development/firmware-using-west.md)

### 1) Sign up for a Gitpod Account and Open this link

{% embed url="<https://gitpod.io/#https://github.com/dlktdr/headtracker/tree/master>" %}

If you already have a github account you can use it to login. This will automatically take you into the master branch of the github code.

### 2) Create the new Workspace

<figure><img src="https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2FWICBZ0nFJuTZSINOfqGi%2Fimage.png?alt=media&amp;token=e02e0d88-012b-4872-b254-515fe0d18d35" alt=""><figcaption></figcaption></figure>

### 3) Wait for the container to be downloaded or built.

The time required to build the container depends on the last connection made by an individual. This process might entail some waiting or necessitate rebuilding. GitPod retains binary files for a limited duration. You may encounter one of the following scenarios: if a rebuild is necessary, the initial opening might be slower.\
![](https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2F1DKd5ytyyUxVX3hOpReM%2Fimage.png?alt=media\&token=d0c50416-6943-422e-8a76-b33a02a7384d)![](https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2FArPYVrkMcUFzxSPeRrL6%2FScreenshot%202024-03-31%20110710.png?alt=media\&token=01dcfc82-5210-49f0-a582-097d15d79b37)

### 4) Once open you will see a Visual Studio Code like environment.

<figure><img src="https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2FYX0dwJIMAJDYJnx6F736%2Fimage.png?alt=media&amp;token=f530e6ce-213f-4a73-82f6-3b95f39b6eec" alt=""><figcaption></figcaption></figure>

Everything you need to build the project has been setup in this container. You will use the terminal to build for the various boards. To start with you need to enter the proper firmware folder.

```
cd firmware/src
```

Once in this folder ![](https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2FyHFPH0rAvSblhVHM6sok%2Fimage.png?alt=media\&token=a4b03052-c5ac-456d-b530-cfb3e7997aed)you can compile code the code for any of the below boards.

### Build Commands

<table><thead><tr><th width="431">Command</th><th>Board</th></tr></thead><tbody><tr><td>west build -p -b arduino_nano_33_ble</td><td><a href="https://store-usa.arduino.cc/products/arduino-nano-33-ble">Arduino Nano 33 BLE including Sense Variant</a></td></tr><tr><td>west build -p -b arduino_nano_33_ble -- -DBOARD_REV2=y</td><td><a href="https://store-usa.arduino.cc/collections/nano-family/products/nano-33-ble-rev2">Arduino Nano 33 BLE <strong>Rev 2</strong> including the Sense <strong>Rev 2</strong> Variant</a></td></tr><tr><td>west build -p  -b xiao_ble/nrf52840/sense</td><td><a href="https://www.seeedstudio.com/Seeed-XIAO-BLE-Sense-nRF52840-p-5253.html">XIAO NRF52840 Sense</a></td></tr><tr><td>west build -p -b xiao_esp32c3</td><td><a href="https://www.seeedstudio.com/Seeed-XIAO-ESP32C3-p-5431.html">XIAO ESP32C3</a></td></tr><tr><td>west build -p -b m5stickc_plus/esp32/procpu</td><td><a href="https://shop.m5stack.com/products/m5stickc-plus2-esp32-mini-iot-development-kit?variant=44269818216705">M5 Stick C Plus<strong>2</strong></a></td></tr><tr><td>west build -p -b dtqsys_ht</td><td>DTQSYS HeadTracker</td></tr><tr><td>west build -p -b esp32c3_devkitm</td><td><a href="https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html">ESP32C3 Devkit M</a></td></tr></tbody></table>

{% hint style="success" %}
To see the most updated versions of the above commands check files **build\_all.sh** (Linux, GitPod) or **build\_all.cmd** (Windows).  You can execute this file and all options will be built and placed in **firmware/src/build\_bins**
{% endhint %}

{% hint style="warning" %}
Not all the boards are actually functional, currently these are the only ones that are fully functional.

Nano33BLE (Includes Sense variant)\
Nano33BLE Rev 2 (Includes Sense variant)\
XAIO NRF52840\
XAIO NRF52840 Sense<br>

M5STICKC\_PLUS is close to working. No PPM in/out or display yet.
{% endhint %}

{% hint style="info" %}
The `-p` argument in all the build commands means do a pristine build. Which means clear everything and start from scratch. If your switching between different boards you will need this to clean up the build system.\
\
If your only working on a single board you can remove this argument and it will speed up the build to only compile the required changes.
{% endhint %}

Once the build is complete you can find the bin file that you can upload to your board under `firmware/src/build/zephyr`

<figure><img src="https://1791219135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FifYnTDP7IFJCZallDj96%2Fuploads%2FLDlTPrYcbPF4aYngBDbK%2Fimage.png?alt=media&amp;token=f85f5422-cc38-47f1-9fa0-c119c86f1413" alt=""><figcaption></figcaption></figure>

**5) Flashing**

Download the .bin file or .uf2 file\
\
**Arduino Nano boards** - You can use the HeadTracker GUI and select from local file to upload it. If you have problems double tap the reset button when it shows waiting for programming port.\
**XIAO or (Raspberry Pi Pico/RP2040 boards** - Copy the .uf2 to the drive that comes up when it's in bootloader mode. Double tap reset to bring up the drive\
**ESP32 variants** - ESPHome-Flasher is the easiest one I have found <https://github.com/esphome/esphome-flasher/releases>&#x20;
