Skip to content

Firmware Development

Arduino Framework

FQBN

Find the FQBN (fully qualified board name) for your board:

arduino-cli board listall | grep --ignore-case "rev"

Example output:

Adafruit Feather ESP32-S2 Reverse TFT              esp32:esp32:adafruit_feather_esp32s2_reversetft
Adafruit Feather ESP32-S3 Reverse TFT              esp32:esp32:adafruit_feather_esp32s3_reversetft  <-- I was looking for this one
Amken Revelop                                      rp2040:rp2040:amken_revelop
Amken Revelop Plus                                 rp2040:rp2040:amken_revelop_plus
Amken Revelop eS                                   rp2040:rp2040:amken_revelop_es

Libraries in Use

To get the compilation profile, including the used libraries, use:

# Note the "fqbn" option.
arduino-cli compile --dump-profile --fqbn esp32:esp32:adafruit_feather_esp32s3_reversetft .

This might output:

profiles:
  adafruit_feather_esp32s3_reversetft:
    fqbn: esp32:esp32:adafruit_feather_esp32s3_reversetft
    platforms:
      - platform: esp32:esp32 (3.0.7)
        platform_index_url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
      libraries:
        - Sensirion I2C SCD4x (1.0.0)
        - Sensirion Core (0.7.1)
        - Adafruit MAX1704X (1.0.3)
        - Adafruit BusIO (1.17.4)
        - Adafruit ST7735 and ST7789 Library (1.11.0)
        - Adafruit GFX Library (1.12.2)
        - OneButton (2.6.1)
        - ArduinoJson (7.3.1)
        - ESP Async WebServer (3.7.0)
        - AsyncTCP (1.1.4)

Sketch Profiles

Save the output of the command above to a sketch.yaml for the Arduino tools to reuse. This is similar to how platformio.ini works for PlatformIO. It might be a good idea to track it with a VCS like git.

For example, since the profile generated above is named adafruit_feather_esp32s3_reversetft, we can use it like this:

arduino-cli compile --profile adafruit_feather_esp32s3_reversetft

If the YAML file has a default_profile set to a board, you can compile for it without specifying a profile.

For example if default_profile: adafruit_feather_esp32s3_reversetft were set, you would simply run:

arduino-cli compile

PlatformIO

Example Config

The configuration for a project I was working on: https://gitlab.com/open-la/pjon-time

It has two targets, sets build flags normally set by the Arduino IDE, and uses custom library locations.

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
lib_archive = no
lib_extra_dirs = ./contrib/
lib_ldf_mode = deep+

[env:uno]
platform = atmelavr
board = uno
framework = arduino
upload_port = /dev/ttyUSB0
monitor_port = /dev/ttyUSB0
monitor_speed = 9600
lib_deps = 
    bblanchon/ArduinoJson@^6.21.5
    ; paulstoffregen/AltSoftSerial@^1.4
    simple_foc
    pjon
    logging
build_flags = 
    ; -DMY_FOC
    ; -DPJON_TXRX
    ; -DALTSERIAL_TXRX
    ; -DPJON_SKIP_CRC
    -DSIMPLEFOC_DISABLE_DEBUG
    -DDISABLE_FOC_CURRENT_CONTROL
    -DARDUINO_JSON_DISABLE
    -DSIMPLE_STEP
    ; -DSIMPLE_STEP_DEBUG
    -DSIMPLE_STEP_DEBUG_TEST

[env:d1mini]
platform = espressif8266
board_build.f_cpu = 160000000L ; 160 MHz
board = d1_mini
framework = arduino
upload_port = /dev/ttyUSB0
monitor_port = /dev/ttyUSB0
monitor_speed = 9600
upload_speed = 921600
lib_deps = 
    bblanchon/ArduinoJson@^7.4.2
    ; paulstoffregen/AltSoftSerial@^1.4
    simple_foc
    pjon
    logging
build_flags = 
    -DMY_FOC
    -DPJON_TXRX
    ; -DALTSERIAL_TXRX
    ; -DPJON_SKIP_CRC
    -DSIMPLEFOC_DISABLE_DEBUG
    ; -DDISABLE_FOC_CURRENT_CONTROL
    -DUSE_ASERIAL
    ; -DARDUINO_JSON_DISABLE