From 414e5dcc3fc7e0236b7a7e2af294a121fddf1190 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Mon, 16 Feb 2026 12:38:14 -0800 Subject: [PATCH] build: multi-target mise.toml with BOARD_TARGET env var Usage: mise run compile # default (e32r35t) BOARD_TARGET=waveshare_s3 mise run compile # Waveshare 4.3" BOARD_TARGET=e32r35t mise run all # build + upload + monitor BOARD_TARGET=waveshare_s3 mise run install-libs # install target-specific libs Each target gets its own FQBN, build flags, library set, and port detection. --- sketches/doorbell-touch-esp32-32e/mise.toml | 96 +++++++++++++++++++-- 1 file changed, 90 insertions(+), 6 deletions(-) diff --git a/sketches/doorbell-touch-esp32-32e/mise.toml b/sketches/doorbell-touch-esp32-32e/mise.toml index 8bceb1d..7795781 100644 --- a/sketches/doorbell-touch-esp32-32e/mise.toml +++ b/sketches/doorbell-touch-esp32-32e/mise.toml @@ -4,29 +4,113 @@ lazygit = "latest" python = "latest" ruby = "latest" +# ═══════════════════════════════════════════════════════════════════ +# Default target — override with: BOARD_TARGET=waveshare_s3 mise run compile +# ═══════════════════════════════════════════════════════════════════ [env] -FQBN = "esp32:esp32:esp32:UploadSpeed=921600,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=info,EraseFlash=none" +BOARD_TARGET = "e32r35t" [tasks.install-core] run = "arduino-cli core update-index && arduino-cli core install esp32:esp32" [tasks.install-libs] run = """ -arduino-cli lib install "GFX Library for Arduino" +#!/usr/bin/env bash +set -euo pipefail arduino-cli lib install "ArduinoJson" arduino-cli lib install "NTPClient" -arduino-cli lib install "TFT_eSPI" +case "${BOARD_TARGET:-e32r35t}" in + e32r35t) + arduino-cli lib install "TFT_eSPI" + ;; + waveshare_s3) + arduino-cli lib install "GFX Library for Arduino" + # Uncomment when enabling GT911 touch: + # arduino-cli lib install "TAMC_GT911" + ;; + *) + echo "ERROR: Unknown BOARD_TARGET: $BOARD_TARGET" + echo "Valid targets: e32r35t, waveshare_s3" + exit 1 + ;; +esac +echo "Libraries installed for target: ${BOARD_TARGET:-e32r35t}" """ [tasks.compile] -run = "arduino-cli compile --fqbn $FQBN ." +run = """ +#!/usr/bin/env bash +set -euo pipefail +case "${BOARD_TARGET:-e32r35t}" in + e32r35t) + FQBN="esp32:esp32:esp32:UploadSpeed=921600,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=info,EraseFlash=none" + BUILD_FLAGS="-DTARGET_E32R35T" + ;; + waveshare_s3) + FQBN="esp32:esp32:waveshare_esp32_s3_touch_lcd_43:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=cdc,CPUFreq=240,FlashMode=qio,FlashSize=16M,PartitionScheme=app3M_fat9M_16MB,DebugLevel=info,PSRAM=enabled,LoopCore=1,EventsCore=1,EraseFlash=none" + BUILD_FLAGS="-DTARGET_WAVESHARE_S3_43" + ;; + *) + echo "ERROR: Unknown BOARD_TARGET: $BOARD_TARGET" + echo "Valid targets: e32r35t, waveshare_s3" + exit 1 + ;; +esac +echo "╔══════════════════════════════════════════════════╗" +echo "║ Building: ${BOARD_TARGET:-e32r35t}" +echo "║ FQBN: $FQBN" +echo "║ Flags: $BUILD_FLAGS" +echo "╚══════════════════════════════════════════════════╝" +arduino-cli compile --fqbn "$FQBN" \ + --build-property "build.extra_flags=$BUILD_FLAGS" . +""" [tasks.upload] depends = ["compile"] -run = "arduino-cli upload --fqbn $FQBN -p $(arduino-cli board list | grep -i 'esp32\\|usb\\|ttyUSB\\|CP210\\|CH340' | head -1 | awk '{print $1}') ." +run = """ +#!/usr/bin/env bash +set -euo pipefail +case "${BOARD_TARGET:-e32r35t}" in + e32r35t) + FQBN="esp32:esp32:esp32:UploadSpeed=921600,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=info,EraseFlash=none" + PORT_PATTERN='ttyUSB|CP210|CH340' + ;; + waveshare_s3) + FQBN="esp32:esp32:waveshare_esp32_s3_touch_lcd_43:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=cdc,CPUFreq=240,FlashMode=qio,FlashSize=16M,PartitionScheme=app3M_fat9M_16MB,DebugLevel=info,PSRAM=enabled,LoopCore=1,EventsCore=1,EraseFlash=none" + PORT_PATTERN='ttyACM' + ;; + *) + echo "ERROR: Unknown BOARD_TARGET: $BOARD_TARGET"; exit 1 + ;; +esac +PORT=$(arduino-cli board list | grep -iE "$PORT_PATTERN" | head -1 | awk '{print $1}') +if [ -z "$PORT" ]; then + echo "No matching port for pattern: $PORT_PATTERN" + echo "Available boards:" + arduino-cli board list + exit 1 +fi +echo "Uploading to $PORT ..." +arduino-cli upload --fqbn "$FQBN" -p "$PORT" . +""" [tasks.monitor] -run = "arduino-cli monitor --port /dev/ttyUSB0 -c 115200" +run = """ +#!/usr/bin/env bash +set -euo pipefail +case "${BOARD_TARGET:-e32r35t}" in + e32r35t) PORT_PATTERN='ttyUSB|CP210|CH340' ;; + waveshare_s3) PORT_PATTERN='ttyACM' ;; + *) echo "Unknown BOARD_TARGET"; exit 1 ;; +esac +PORT=$(arduino-cli board list | grep -iE "$PORT_PATTERN" | head -1 | awk '{print $1}') +if [ -z "$PORT" ]; then + echo "No matching port for pattern: $PORT_PATTERN" + arduino-cli board list + exit 1 +fi +arduino-cli monitor -p "$PORT" -c baudrate=115200 +""" [tasks.all] depends = ["upload"]