Skip to content

Building the OpenDeck firmware

paradajz edited this page Jun 2, 2022 · 38 revisions

This document will explain how to build the OpenDeck firmware. Building the firmware is needed only when creating own board variants since compiled binaries are the part of OpenDeck releases.

Getting the packages

The commands listed below are used to install necessary packages for the build process of OpenDeck firmware.

Ubuntu/WSL

It is assumed here Ubuntu 20.04 is used, or alternatively, same version using Windows subsystem for Linux on Windows 10. Earlier versions are not supported, and newer versions aren't tested.

Run the following commands from terminal to download the necessary packages (select the entire block and paste in into terminal):

cd && \
sudo apt-get update && \
sudo apt-get install -y make srecord git git-lfs curl wget gcc g++ gdb imagemagick dfu-util ccache && \
curl -s https://api.github.com/repos/tomwright/dasel/releases/latest | grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | wget -qi - && \
chmod +x dasel_linux_amd64 && \
sudo mv $(pwd)/dasel_linux_amd64 /usr/local/bin/dasel && \
wget https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz -O arduino.tar.xz && \
tar -xf arduino.tar.xz && \
rm arduino.tar.xz && \
wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 && \
tar -xf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 && \
rm gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 && \
echo 'export PATH=~/arduino-1.8.19/hardware/tools/avr/bin:~/gcc-arm-none-eabi-10.3-2021.10/bin:${PATH}' >> ~/.bashrc && \
sudo cp $(pwd)/arduino-1.8.19/hardware/tools/avr/etc/avrdude.conf /etc/avrdude.conf && \
source ~/.bashrc

macOS

Note: Instructions are valid both for Intel and Apple Silicon

It is assumed here macOS Catalina or higher is used. Earlier versions are not supported. Run the following commands from terminal to download the necessary packages (assuming Homebrew is installed).

Run the following commands from terminal to download the necessary packages (select the entire block and paste in into terminal):

cd && \
brew install bash srecord git git-lfs dasel gdb imagemagick binutils findutils coreutils unzip wget dfu-util ccache || \
git lfs install && \
wget https://downloads.arduino.cc/arduino-1.8.19-macosx.zip -O arduino.zip && \
unzip arduino.zip && \
rm arduino.zip && \
mv Arduino.app arduino-1.8.19 && \
wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2 && \
tar -xf gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2 && \
rm gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2 && \
echo 'export PATH=~/arduino-1.8.19/Contents/Java/hardware/tools/avr/bin:~/gcc-arm-none-eabi-10.3-2021.10/bin:/usr/local/opt/binutils/bin:/opt/homebrew/opt/binutils/bin:${PATH}' >> ~/.profile && \
sudo cp $(pwd)/arduino-1.8.19/Contents/Java/hardware/tools/avr/etc/avrdude.conf /etc/avrdude.conf && \
source ~/.profile

Cloning OpenDeck repository

OpenDeck repository uses several Git sub-modules. Therefore, running git clone url won't work since those sub-modules won't be cloned. Use the following command to clone an entire repository with sub-modules:

cd && \
GIT_LFS_SKIP_SMUDGE=1 git clone --recursive https://github.com/shanteacontrols/OpenDeck.git && \
cd OpenDeck/src

Several binaries are stored with Git LFS, but are not needed for the build, hence the GIT_LFS_SKIP_SMUDGE part.

Building the firmware

OpenDeck build process uses Makefile. Using that file, firmware can be compiled for several targets. To see which targets are available, open config/target directory in root directory of repository.

The following syntax must be used:

make TARGET=<target>

To compile the firmare for Arduino Mega2560 as an example, make sure the current directory is OpenDeck/src. Next, run the following command:

make TARGET=mega2560

If the command run was successful, output should look like the following:

paradajz@desktop ~/dev/git/OpenDeck/src
> make TARGET=mega2560
Building application...
Generating target definitions...
Generating HW test config...
Generating MCU definitions...
Building: board/gen/target/mega2560/mega2560.cpp
Building: board/common/Common.cpp
Building: board/arch/avr/variants/avr8/atmega2560/Common.cpp
Building: board/common/io/Stubs.cpp
Building: board/arch/avr/common/ISR.cpp
Building: board/arch/avr/common/Flash.cpp
Building: board/arch/avr/common/ShiftRegistersWait.cpp
Building: board/arch/avr/common/Bootloader.cpp
Building: board/arch/avr/common/Init.cpp
Building: board/arch/avr/common/NVM.cpp
Building: board/arch/avr/common/Multiplexer.cpp
Building: board/common/comm/USBOverSerial/USBOverSerial.cpp
Building: board/arch/avr/comm/uart/UART.cpp
Building: board/common/comm/uart/UART.cpp
Building: application/main.cpp
Building: application/database/CustomInit.cpp
Building: application/database/Database.cpp
Building: application/system/Set.cpp
Building: application/system/System.cpp
Building: application/system/hwa/io/Buttons.cpp
Building: application/system/hwa/io/Display.cpp
Building: application/system/hwa/io/CDCPassthrough.cpp
Building: application/system/hwa/io/Encoders.cpp
Building: application/system/hwa/io/Touchscreen.cpp
Building: application/system/hwa/io/Analog.cpp
Building: application/system/hwa/io/LEDs.cpp
Building: application/system/hwa/protocol/DMX.cpp
Building: application/system/hwa/protocol/MIDI.cpp
Building: application/system/Helpers.cpp
Building: application/system/Get.cpp
Building: application/midi/MIDI.cpp
Building: application/util/messaging/Messaging.cpp
Building: application/util/scheduler/Scheduler.cpp
Building: application/util/cinfo/CInfo.cpp
Building: application/io/common/Common.cpp
Building: ../modules/sysex/src/SysExConf.cpp
Building: ../modules/midi/src/MIDI.cpp
Building: ../modules/dbms/src/LESSDB.cpp
Building: ../modules/dmxusb/src/DMXUSBWidget.cpp
Building: application/io/analog/Analog.cpp
Building: board/common/io/Analog.cpp
Building: application/io/leds/LEDs.cpp
Building: board/common/io/Output.cpp
Building: application/io/buttons/Buttons.cpp
Building: application/io/encoders/Encoders.cpp
Building: board/common/io/Input.cpp
Building: application/io/touchscreen/Touchscreen.cpp
Building: application/io/touchscreen/model/viewtech/Viewtech.cpp
Building: application/io/touchscreen/model/nextion/Nextion.cpp
Building: application/io/display/U8X8/U8X8.cpp
Building: application/io/display/Display.cpp
Building: application/io/display/strings/Strings.cpp
Building: board/arch/avr/comm/i2c/I2C.cpp
Building: ../modules/u8g2/csrc/u8x8_string.c
Building: ../modules/u8g2/csrc/u8x8_setup.c
Building: ../modules/u8g2/csrc/u8x8_u8toa.c
Building: ../modules/u8g2/csrc/u8x8_8x8.c
Building: ../modules/u8g2/csrc/u8x8_u16toa.c
Building: ../modules/u8g2/csrc/u8x8_display.c
Building: ../modules/u8g2/csrc/u8x8_fonts.c
Building: ../modules/u8g2/csrc/u8x8_byte.c
Building: ../modules/u8g2/csrc/u8x8_cad.c
Building: ../modules/u8g2/csrc/u8x8_gpio.c
Building: ../modules/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c
Building: ../modules/u8g2/csrc/u8x8_d_ssd1306_128x32.c
Creating executable: build/app/mega2560/release/mega2560.elf
AVR Memory Usage
----------------
Device: atmega2560

Program:   75600 bytes (28.8% Full)
(.text + .data + .bootloader)

Data:       6515 bytes (79.5% Full)
(.data + .bss + .noinit)


Building bootloader...
Building: board/gen/target/mega2560/mega2560.cpp
Building: board/common/Common.cpp
Building: board/arch/avr/variants/avr8/atmega2560/Common.cpp
Building: board/common/io/Stubs.cpp
Building: board/common/bootloader/Bootloader.cpp
Building: board/common/io/Indicators.cpp
Building: board/arch/avr/common/Bootloader.cpp
Building: board/arch/avr/common/Init.cpp
Building: board/arch/avr/common/ShiftRegistersWait.cpp
Building: board/arch/avr/common/ISR.cpp
Building: board/arch/avr/common/Flash.cpp
Building: bootloader/FwSelector/FwSelector.cpp
Building: bootloader/updater/Updater.cpp
Building: bootloader/main.cpp
Building: bootloader/SysExParser/SysExParser.cpp
Building: board/arch/avr/comm/uart/UART.cpp
Building: board/common/comm/uart/UART.cpp
Building: board/common/comm/USBOverSerial/USBOverSerial.cpp
Creating executable: build/boot/mega2560/release/mega2560.elf
AVR Memory Usage
----------------
Device: atmega2560

Program:    7818 bytes (3.0% Full)
(.text + .data + .bootloader)

Data:       1771 bytes (21.6% Full)
(.data + .bss + .noinit)


Building sysexgen...
Building: sysexgen/main.cpp
Creating executable: build/sysexgen/mega2560/release/mega2560.elf
   text	   data	    bss	    dec	    hex	filename
   8542	    824	    280	   9646	   25ae	./build/sysexgen/mega2560/release/mega2560.elf
Building flashgen...
make[1]: Nothing to be done for 'binary'.
Merged binary created: ./build/merged/mega2560/release/mega2560.hex
Creating SysEx file...
Firmware size is 75602 bytes. Generating SysEx file, please wait...
SysEx file created: ./build/merged/mega2560/release/mega2560.sysex


Build process creates binaries in src/build directory. Binaries in TARGET/release/merged (where TARGET is the target for which the firmware is compiled) directory are the ones which are flashed on boards, all other directories are intermediate. For instructions on how to flash compiled binary to the board, follow this page.

Clone this wiki locally