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:

1
2
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 submodules, you can fetch the submodules seperately using:

1
git submodule update --init --recursive

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

1
2
3
4
git clone --recursive https://github.com/HASwitchPlate/openHASP
cd openHASP
git checkout 0.6.1
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 esp32and esp8266:

1
2
3
4
5
6
[platformio]
extra_configs =
    ; Uncomment or edit the lines to show more User Setups in the PIO sidebar
    user_setups/esp32/*.ini
    user_setups/esp8266/*.ini
    ; user_setups/stm32f4xx/*.ini

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

1
2
3
4
5
[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:

1
2
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