Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
if: needs.pre_job.outputs.concurrent_workflows == 'false' || (needs.pre_job.outputs.concurrent_workflows == 'true' && github.ref_type == 'tag')
strategy:
matrix:
platform: [esp32dev, spa-control-pcb]
platform: [esp32dev, espa-v1, espa-v2]
uses: ./.github/workflows/build_firmware.yml
with:
platform: ${{ matrix.platform }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
python-version: "3.x"
- name: Install PlatformIO
run: pip install platformio
- name: Update PlatformIO
run: pio update
- name: Build file system image for ${{ inputs.platform }}
run: pio run --target buildfs -e ${{ inputs.platform }}
- name: Build for ${{ inputs.platform }}
Expand Down
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"pioarduino.pioarduino-ide",
"platformio.platformio-ide"
],
"unwantedRecommendations": [
Expand Down
7 changes: 6 additions & 1 deletion lib/MultiBlinker/MultiBlinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
extern RemoteDebug Debug;

// These are the four LEDs on the PCB
#ifdef SPACTRLPCB
#if defined(ESPA_V1)
const int PCB_LED1 = 14;
const int PCB_LED2 = 41;
const int PCB_LED3 = 42;
const int PCB_LED4 = 43;
#elif defined(ESPA_V2)
const int PCB_LED1 = 18;
const int PCB_LED2 = 21;
const int PCB_LED3 = 22;
const int PCB_LED4 = 23;
#endif

// Define error state constants
Expand Down
23 changes: 17 additions & 6 deletions merge-bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,23 @@ def merge_bin_action(source, target, env):
print("fs_image_name: ", fs_image_name)

if partition_csv and fs_image_name:
with open(partition_csv, "r") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
if row["# Name"] == fs_image_name:
offset = row[" Offset"]
break
# Use skipinitialspace to tolerate fields with leading spaces.
# Be defensive about header names: some CSVs use '# Name' while
# others use 'Name' (and offsets may be 'Offset' or ' Offset').
try:
with open(partition_csv, "r") as csvfile:
reader = csv.DictReader(csvfile, skipinitialspace=True)
for row in reader:
# Try several possible header names to avoid KeyError
name = (row.get("# Name") or row.get("Name") or row.get("name"))
if name == fs_image_name:
offset = (row.get("Offset") or row.get(" Offset") or row.get("offset") or 0)
if isinstance(offset, str):
offset = offset.strip()
break
except Exception as e:
print("Warning: failed to parse partition CSV:", e)
offset = 0

if offset:
flash_images.append(offset)
Expand Down
82 changes: 82 additions & 0 deletions partitions/espa_v2_partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ===================================================================
# ESP32-C6-MINI-1 Partition Table Explanation (4 MB flash)
# ===================================================================
#
# Partition Layout Overview:
# --------------------------
# The flash is organized into several partitions. Each partition has:
# - Name: logical name used by the system or your application
# - Type: 'app' or 'data'
# - SubType: specifies role (e.g., ota_0, ota_1, spiffs, nvs)
# - Offset: starting flash address (must be 0x10000-aligned for app partitions)
# - Size: size of the partition in bytes (hex)
# - Flags: optional, can usually be left blank
#
# Partition Definitions:
# ----------------------
# 1. nvs
# Type: data
# SubType: nvs
# Offset: 0x9000
# Size: 0x7000 (28 KB)
# Purpose: Non-volatile key-value storage used for:
# - Wi-Fi credentials
# - Preferences API data
# - PHY calibration and system parameters
#
# 2. otadata
# Type: data
# SubType: ota
# Offset: 0x10000
# Size: 0x2000 (8 KB)
# Purpose: OTA metadata used by the bootloader to track which app partition
# should be booted. Must be present if OTA updates are used.
#
# 3. app0
# Type: app
# SubType: ota_0
# Offset: 0x20000
# Size: 0x180000 (1.5 MB)
# Purpose: Primary firmware slot for OTA updates. This is where the current
# running firmware is stored.
#
# 4. app1
# Type: app
# SubType: ota_1
# Offset: 0x1A0000
# Size: 0x180000 (1.5 MB)
# Purpose: Secondary firmware slot for OTA updates. When performing OTA,
# new firmware is written here, then the bootloader switches to it.
#
# 5. spiffs
# Type: data
# SubType: spiffs
# Offset: 0x340000
# Size: 0x20000 (128 KB)
# Purpose: SPI Flash File System for storing:
# - Web UI assets (HTML/CSS/JS)
# - Configuration files
# - Other persistent application data
#
# Alignment Notes:
# ----------------
# - App partitions (app0 and app1) must start at multiples of 0x10000 (64 KB) for proper flash alignment.
# - SPIFFS and data partitions can be less strictly aligned, but staying on 0x10000 boundaries is recommended.
# - NVS must end before the first 0x10000 boundary so that app0 can start properly.
#
# Total Flash Usage:
# ------------------
# 4 MB total flash:
# - nvs + otadata: 36 KB
# - app0 + app1: 3 MB
# - spiffs: 128 KB
# - Remaining space: bootloader, alignment padding
#
# ===================================================================
#
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x7000,
otadata, data, ota, 0x10000, 0x2000,
app0, app, ota_0, 0x20000, 0x180000,
app1, app, ota_1, 0x1A0000, 0x180000,
spiffs, data, spiffs, 0x340000, 0x20000
32 changes: 23 additions & 9 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = esp32dev, spa-control-pcb
default_envs = esp32dev, espa-v1, espa-v2
; data_dir = {$PROJECT_DIR}/data

[env:spa-base]
platform = espressif32
framework = arduino
monitor_speed = 115200
lib_ldf_mode = deep
Expand All @@ -21,18 +22,16 @@ lib_deps =
https://github.com/ktos/RemoteDebug.git@^3.0.7
tzapu/WiFiManager@^2.0.17
knolleary/PubSubClient@^2.8
bblanchon/ArduinoJson@^7.1.0
links2004/WebSockets@^2.3.6
bblanchon/ArduinoJson@^7.4.2
;links2004/WebSockets@^2.7.1
paulstoffregen/Time@^1.6.1
https://github.com/me-no-dev/ESPAsyncWebServer.git
extra_scripts =
pre:get_version.py
post:merge-bin.py


[env:esp32dev]
extends = env:spa-base
platform = espressif32
board = esp32dev
build_flags =
-D RX_PIN=16
Expand All @@ -41,15 +40,30 @@ build_flags =
-D LED_PIN=2
-D SPA_SERIAL=Serial2

[env:spa-control-pcb]
[env:espa-v1]
extends = env:spa-base
platform = espressif32
board = esp32-s3-devkitc-1
build_flags =
-D ARDUINO_USB_CDC_ON_BOOT=1
-D SPACTRLPCB=1
-D ESPA_V1=1
-D RX_PIN=16
-D TX_PIN=15
-D EN_PIN=0
;-D LED_PIN=14
-D SPA_SERIAL=Serial2

[env:espa-v2]
extends = env:spa-base
# Use the pioarduino fork of the espressif32 platform to enable Arduino framework support
# for the ESP32-C6, which is not fully supported in the official PlatformIO 6.12.0 release.
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino
board = esp32-c6-devkitc-1
board_build.flash_size = 4MB
board_build.partitions = partitions/espa_v2_partitions.csv
build_flags =
; -D ARDUINO_USB_CDC_ON_BOOT=1
-D ESPA_V2=1
-D RX_PIN=19
-D TX_PIN=20
-D EN_PIN=9
-D SPA_SERIAL=Serial2
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RemoteDebug Debug;
SpaInterface si;
Config config;

#if defined(SPACTRLPCB)
#if defined(ESPA_V1) || defined(ESPA_V2)
MultiBlinker blinker(PCB_LED1, PCB_LED2, PCB_LED3, PCB_LED4);
#elif defined(LED_PIN)
MultiBlinker blinker(LED_PIN);
Expand Down