Firmware using West
You can use the online GitPod.io if you want a simple way to generate a new firmware without setting up this whole build system. Click the Link below. You can make quick changes and test things without all the setup.
If you plan on using a debugger or being able to use the west flash
command to write to your board quickly then continue on.
This guide mostly follows the instructions on the Zephyr Gettings started Guide. Some install locations have been modified so that code completion and debugging paths match what is set in ht/firmware/src/headtracker.code-workspace and ht/firmware/src/.vscode/c_cpp_properties.json
Install Chocolatey + Required Packages
Follow the instructions here to install chocolatey. You could install all the requirements yourself but this makes the installation easy.
Run the following commands to install the necessary files
You can skip the optional ones if you don't want to use VSCode or Github Desktop
Install Chocolatey GUI as will if you want an easy way to work with Chocolatey Package manager
choco install chocolateygui
Install West using PIP
Get the HeadTracker source + required submodules
Get the Zephyr source & update
Install the extra required packages using PIP
Download the Zephyr SDK
Download the Zephyr SDK Bundle - https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.5-1 This is all the build tools for ARM,RISC,xtensa, etc.
After download completes, move the file to c:\HT\firmware
Extract SDK, Rename, Register cmake package
Open PowerShell as a regular user
Test Compiling the code
Open a PowerShell as a regular user. The environment variable ZEPHYR_BASE must be set so west knows where to look for the zephyr source code. If you do this in VScode the variable is set on the terminal from the headtrackercode.workspace file so you can skip it if using the vscode terminal
Open Visual Studio Code
From File Choose open Workspace From File and open C:\ht\firmware\src\headtracker.code-workspace file. This will load all the settings which will make building quicker.
From VScode close any terminals that are open and start new ones. This is to be sure the ZEPHYR_BASE environment variable gets set properly. It's set in the workspace file for you.
You can now build for various boards using the commands they are listed in the GitPod documentation here,
Flashing the board
You can flash directly form the command line. Do this after you successfully compile the code for whatever board your working on. The flash utility will change depending on the selected board.
For the Arduino boards it's also helpful to specify the com port. e.g. COM4. If you have multiple ports on your system west flash may not properly find it.
To see all the flashing runner options for the supported boards run,
Debugging with a J-Link
**Be sure to delete the build folder before switching from a release to a debug modes.
There is an example using OpenOCD for a ESP. Next time I go to use this I'll update the docs. Your on your own for this one.
Common Issues
Issues with building can often be resolved by deleting the build folder under c:\ht\firmware\src\build and trying again. Build with the -p flag to start with a clean build. Required which switching between various boards.
ERROR: source directory "." does not contain a CMakeLists.txt; You tried to build from the incorrect folder. You must build from c:\ht\firmware\src
Others questions and issues please ask on Discord in the #dev channel. Link Below
Last updated