Skip to content

Compiling locally~

Even though openHASP is available in several pre-compiled firmware variants, sometimes the ready-to-flash binaries aren't enough. If you need to customize some features, or simply change some parameters, then you need to compile a firmware binary yourself.
The guide below will describe how to make your own build from source on your local PC.

Install Visual Studio Code~

Additional packages on Linux:

sudo apt update
sudo apt install git python3-venv

Clone openHASP~

Make sure to add the --recursive parameter when cloning the project from GitHub. Otherwise git will not download the required submodules in the /lib subdirectory. To clone the current development version (main branch):

1
git clone --recursive https://github.com/HASwitchPlate/openHASP

If you already cloned openHASP without the --recursive parameter, you can fetch the submodules separately using:

1
git submodule update --init --recursive

To switch to a different branch (for example 0.6.3 release) use:

1
2
3
4
git clone --recursive https://github.com/HASwitchPlate/openHASP
cd openHASP
git checkout 0.6.3
git submodule update --init --recursive

Open in PlatformIO~

Install PIO

Open the project folder in Visual Studio Code. You will receive a popup to install PlatformIO IDE if it is not already installed. This will automatically install all PlatformIO dependencies and the MCU compiler frameworks needed.

PIO Installed

Restart Visual Studio Code when the PIO installation completes.

Create a configuration~

Copy platformio_override-template.ini to platformio_override.ini and uncomment the platforms for esp32or esp32s2:

[platformio]
extra_configs =
    ; Uncomment or edit the lines to show more User Setups in the PIO sidebar
    ; user_setups/darwin_sdl/*.ini
    user_setups/esp32/*.ini
    user_setups/esp32s2/*.ini
    ; user_setups/linux_sdl/*.ini
    ; user_setups/stm32f4xx/*.ini
    ; user_setups/win32/*.ini

If you use customization, remove the comment from the line -DUSE_CONFIG_OVERRIDE:

[override]
; -- Hasp config options --------------------------------------
build_flags =
; -- Uncomment the next line to use the file include/user_config_override.h settings
    -DUSE_CONFIG_OVERRIDE

Then Click on the "Refresh Project tasks" icon in PlatformIO to list all the configured environments.

Compiling~

MCU Environments~

Build All

You can now run "Build" or "Build All" in PlatformIO to compile (all) the firmware.

Native Linux build~

For native linux_sdl builds, you also need:

sudo apt update
sudo apt install build-essential libsdl2-dev

Native MacOS build~

For native darwin_sdl builds, you also need Homebrew:

1
brew install gcc sdl2

Native Windows build~

For native windows_sdl builds, you also need MingW:

Use MSYS2

1
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2

Add the path to your Mingw-w64 bin folder to the Windows PATH environment variable (usually C:\msys64\mingw64\bin). See instruction, 4.


Last update: 2023-12-09