Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51fd4a868a | |||
| eb9cbd985f | |||
| 0a76cd8c0e |
@@ -223,7 +223,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
|
||||
### Tunables (gauge calibration, alert thresholds)
|
||||
|
||||
`src/modules/tunables.cpp` owns `link_config_t`: tach pulses/rev + trim + clamps, coolant PWM frequency + duty law + min temp, per-output enables, a bench override (force rpm / duty), and the alert thresholds. Stored as an NVS blob (namespace `tunables`). Edited over the USB serial console: `cfg show`, `cfg set <name> <value>`, `cfg override rpm <n> | duty <n> | both <rpm> <duty> | off`, `cfg reset`. Every change bumps `cfg_version`, which makes the UART task push a CONFIG frame. Overrides are pushed but never saved. The **Gauge Tuning screen** (`src/modules/tuning_screen.cpp`, hand-coded like the driveline screen so SquareLine exports cannot clobber it; Home → swipe right → Driveline → swipe right → Tuning) edits the same values with −/+ buttons, enable switches, and an override panel with RPM and duty sliders. Overrides are never written to NVS (`save()` strips them).
|
||||
`src/modules/tunables.cpp` owns `link_config_t`: tach pulses/rev + trim + clamps, coolant PWM frequency + duty law + min temp, per-output enables, a bench override (force rpm / duty), and the alert thresholds. Stored as an NVS blob (namespace `tunables`), written 3 s after the last change or on leaving the Tuning screen (`Tunables::flush()`) - every flash write flickers the RGB panel, so no write per tap. Edited over the USB serial console: `cfg show`, `cfg set <name> <value>`, `cfg override rpm <n> | duty <n> | both <rpm> <duty> | off`, `cfg reset`. Every change bumps `cfg_version`, which makes the UART task push a CONFIG frame. Overrides are pushed but never saved. The **Gauge Tuning screen** (`src/modules/tuning_screen.cpp`, hand-coded like the driveline screen so SquareLine exports cannot clobber it; Home → swipe right → Driveline → swipe right → Tuning) edits the same values with −/+ buttons, enable switches, and an override panel with RPM and duty sliders. Overrides are never written to NVS (`save()` strips them).
|
||||
|
||||
### Diagnostic probe (`diag` console)
|
||||
|
||||
@@ -247,7 +247,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
- Syncs toggle switches with actual service states: `g_wifi_state`, `g_uart_state`, `g_debug_enabled`
|
||||
- Shows loading spinner during sync for smooth UX
|
||||
|
||||
**Screens**: Driveline (boot, hand-coded) ← swipe left → Settings (SquareLine); Driveline → swipe right → Gauge Tuning (hand-coded).
|
||||
**Screens**: Driveline (boot, hand-coded) ← swipe left → Settings (SquareLine); Driveline → swipe right → Gauge Tuning (hand-coded). Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`): full-screen fades are software-blended every frame and stutter at 1024x600. The firmware version is a label on `lv_layer_top()` (bottom-right, every screen, `DisplayInit`).
|
||||
|
||||
**Debug Mode**:
|
||||
- Toggle in Settings screen shows/hides `uic_Device_State_Container`
|
||||
|
||||
@@ -6,9 +6,32 @@
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include "ui/ui.h"
|
||||
#include "driveline_screen.h"
|
||||
#include "config/ota_config.h" // FW_VERSION
|
||||
|
||||
namespace DisplayInit {
|
||||
|
||||
static Backlight* g_backlight = nullptr;
|
||||
|
||||
/**
|
||||
* Firmware version, bottom-right on every screen. Lives on lv_layer_top(), which
|
||||
* sits above all screens and survives screen switches. Labels aren't
|
||||
* clickable, so it never steals touches or swipes from the screen below.
|
||||
* Call with the LVGL lock held.
|
||||
*/
|
||||
static void createVersionLabel() {
|
||||
lv_obj_t* lbl = lv_label_create(lv_layer_top());
|
||||
lv_label_set_text(lbl, "A " FW_VERSION);
|
||||
lv_obj_set_style_text_font(lbl, &lv_font_montserrat_14, 0);
|
||||
lv_obj_set_style_text_color(lbl, lv_color_hex(0x808080), 0);
|
||||
lv_obj_align(lbl, LV_ALIGN_BOTTOM_RIGHT, -8, -4);
|
||||
}
|
||||
|
||||
void setBacklight(bool on) {
|
||||
if (g_backlight == nullptr) return;
|
||||
if (on) g_backlight->on();
|
||||
else g_backlight->off();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PUBLIC API IMPLEMENTATION
|
||||
// ============================================================================
|
||||
@@ -76,6 +99,7 @@ DisplayObjects init() {
|
||||
// empty placeholder now (the SquareLine Home screen was removed 2026-09-21);
|
||||
// swap while the backlight is still off so there's no flash.
|
||||
DrivelineScreen::show();
|
||||
createVersionLabel();
|
||||
lvgl_port_unlock();
|
||||
Serial.println("[DisplayInit] Step 13: SquareLine UI loaded successfully!");
|
||||
|
||||
@@ -91,6 +115,7 @@ DisplayObjects init() {
|
||||
Serial.println("[DisplayInit] Display initialization complete!");
|
||||
|
||||
// Return board and backlight objects for later use
|
||||
g_backlight = backlight;
|
||||
return {board, backlight};
|
||||
}
|
||||
|
||||
|
||||
@@ -43,4 +43,7 @@ struct DisplayObjects {
|
||||
*/
|
||||
DisplayObjects init();
|
||||
|
||||
/** Backlight on/off after init() (e.g. dark during OTA flash writes, which flicker the panel). */
|
||||
void setBacklight(bool on);
|
||||
|
||||
} // namespace DisplayInit
|
||||
|
||||
@@ -145,7 +145,9 @@ static void onScreenGesture(lv_event_t* e) {
|
||||
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
||||
if (dir == LV_DIR_LEFT) {
|
||||
lv_indev_wait_release(lv_indev_get_act());
|
||||
_ui_screen_change(&ui_Settings_Screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 0,
|
||||
// No transition animation: a full-screen fade is re-rendered and blended
|
||||
// in software every frame and stutters on this 1024x600 panel.
|
||||
_ui_screen_change(&ui_Settings_Screen, LV_SCR_LOAD_ANIM_NONE, 0, 0,
|
||||
&ui_Settings_Screen_screen_init);
|
||||
} else if (dir == LV_DIR_RIGHT) {
|
||||
lv_indev_wait_release(lv_indev_get_act());
|
||||
@@ -257,7 +259,7 @@ static void build() {
|
||||
|
||||
void show() {
|
||||
build();
|
||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 0, false);
|
||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); // instant: fades stutter at 1024x600
|
||||
}
|
||||
|
||||
void tick() {
|
||||
|
||||
+100
-32
@@ -17,6 +17,10 @@
|
||||
#include "drivers/can_driver.h"
|
||||
#include "protocol/automotive_data.h"
|
||||
#include "config/ota_config.h"
|
||||
#include "modules/display_init.h"
|
||||
#include "modules/tunables.h"
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
@@ -277,45 +281,27 @@ static bool verifySignature(const manifest_t& m) {
|
||||
// Install
|
||||
// ============================================================================
|
||||
|
||||
static void install(bool force) {
|
||||
manifest_t m;
|
||||
if (!fetchManifest(m) || !verifySignature(m)) return;
|
||||
|
||||
if (!force && strcmp(m.version, FW_VERSION) == 0) {
|
||||
print("[ota] already running %s - nothing to do (`ota install force` to reinstall)", FW_VERSION);
|
||||
return;
|
||||
}
|
||||
|
||||
const esp_partition_t* part = esp_ota_get_next_update_partition(NULL);
|
||||
if (!part) { print("[ota] no idle OTA slot (partition table?)"); return; }
|
||||
if (m.size > part->size) {
|
||||
print("[ota] image %lu B does not fit slot %s (%lu B)",
|
||||
(unsigned long)m.size, part->label, (unsigned long)part->size);
|
||||
return;
|
||||
}
|
||||
|
||||
print("[ota] installing %s -> %s (%lu bytes). Screen may flicker while flash is written.",
|
||||
m.version, part->label, (unsigned long)m.size);
|
||||
|
||||
/** Download firmware.bin into the idle slot, hashing as it streams; true if it matches the signed manifest. */
|
||||
static bool writeImage(const manifest_t& m, const esp_partition_t* part) {
|
||||
String url = String(OTA_DOWNLOAD_BASE) + m.tag + "/firmware.bin";
|
||||
WiFiClientSecure client;
|
||||
client.setCACert(OTA_CA_PEM);
|
||||
HTTPClient http;
|
||||
http.setConnectTimeout(10000);
|
||||
http.setTimeout(15000);
|
||||
if (!http.begin(client, url)) { print("[ota] bad download URL"); return; }
|
||||
if (!http.begin(client, url)) { print("[ota] bad download URL"); return false; }
|
||||
http.setUserAgent("patrol-a-ota/" FW_VERSION);
|
||||
int code = http.GET();
|
||||
if (code != HTTP_CODE_OK) { print("[ota] download failed (HTTP %d)", code); http.end(); return; }
|
||||
if (code != HTTP_CODE_OK) { print("[ota] download failed (HTTP %d)", code); http.end(); return false; }
|
||||
if (http.getSize() != (int)m.size) {
|
||||
print("[ota] server size %d != manifest size %lu", http.getSize(), (unsigned long)m.size);
|
||||
http.end();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_ota_handle_t h = 0;
|
||||
esp_err_t err = esp_ota_begin(part, OTA_WITH_SEQUENTIAL_WRITES, &h);
|
||||
if (err != ESP_OK) { print("[ota] esp_ota_begin: %s", esp_err_to_name(err)); http.end(); return; }
|
||||
if (err != ESP_OK) { print("[ota] esp_ota_begin: %s", esp_err_to_name(err)); http.end(); return false; }
|
||||
|
||||
uint8_t* buf = (uint8_t*)malloc(CHUNK);
|
||||
mbedtls_sha256_context sc;
|
||||
@@ -329,7 +315,11 @@ static void install(bool force) {
|
||||
while (ok && got < m.size) {
|
||||
size_t avail = stream->available();
|
||||
if (avail == 0) {
|
||||
if (!http.connected() || millis() - last_rx > STALL_TIMEOUT_MS) {
|
||||
// connected() can read false for a moment between TLS records, so a
|
||||
// drop only counts after 2 s of silence (it aborted a download at
|
||||
// 570 B once, 2026-09-26; the retry went through).
|
||||
uint32_t idle = millis() - last_rx;
|
||||
if ((!http.connected() && idle > 2000) || idle > STALL_TIMEOUT_MS) {
|
||||
print("[ota] download stalled at %lu/%lu bytes", (unsigned long)got, (unsigned long)m.size);
|
||||
ok = false;
|
||||
break;
|
||||
@@ -361,19 +351,95 @@ static void install(bool force) {
|
||||
print("[ota] SHA-256 MISMATCH - image does not match the signed manifest");
|
||||
ok = false;
|
||||
}
|
||||
if (!ok) { esp_ota_abort(h); print("[ota] aborted; still running %s", FW_VERSION); return; }
|
||||
if (!ok) { esp_ota_abort(h); print("[ota] aborted; still running %s", FW_VERSION); return false; }
|
||||
|
||||
err = esp_ota_end(h); // validates the image structure + its embedded hash
|
||||
if (err != ESP_OK) { print("[ota] image check failed: %s", esp_err_to_name(err)); return; }
|
||||
if (err != ESP_OK) { print("[ota] image check failed: %s", esp_err_to_name(err)); return false; }
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// ---- Full-screen notice on lv_layer_top() (above every screen) ----------------
|
||||
static lv_obj_t* g_notice = NULL;
|
||||
static lv_obj_t* g_notice_lbl = NULL;
|
||||
|
||||
static void showNotice(const char* text) {
|
||||
lvgl_port_lock(-1);
|
||||
if (g_notice == NULL) {
|
||||
g_notice = lv_obj_create(lv_layer_top());
|
||||
lv_obj_remove_style_all(g_notice);
|
||||
lv_obj_set_size(g_notice, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_bg_color(g_notice, lv_color_black(), 0);
|
||||
lv_obj_set_style_bg_opa(g_notice, LV_OPA_COVER, 0);
|
||||
lv_obj_add_flag(g_notice, LV_OBJ_FLAG_CLICKABLE); // swallow touches while shown
|
||||
g_notice_lbl = lv_label_create(g_notice);
|
||||
lv_obj_set_style_text_font(g_notice_lbl, &lv_font_montserrat_30, 0);
|
||||
lv_obj_set_style_text_color(g_notice_lbl, lv_color_white(), 0);
|
||||
lv_obj_set_style_text_align(g_notice_lbl, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_center(g_notice_lbl);
|
||||
}
|
||||
lv_label_set_text(g_notice_lbl, text);
|
||||
lv_obj_clear_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
static void hideNotice() {
|
||||
lvgl_port_lock(-1);
|
||||
if (g_notice) lv_obj_add_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
static void install(bool force) {
|
||||
manifest_t m;
|
||||
if (!fetchManifest(m) || !verifySignature(m)) return;
|
||||
|
||||
if (!force && strcmp(m.version, FW_VERSION) == 0) {
|
||||
print("[ota] already running %s - nothing to do (`ota install force` to reinstall)", FW_VERSION);
|
||||
return;
|
||||
}
|
||||
|
||||
const esp_partition_t* part = esp_ota_get_next_update_partition(NULL);
|
||||
if (!part) { print("[ota] no idle OTA slot (partition table?)"); return; }
|
||||
if (m.size > part->size) {
|
||||
print("[ota] image %lu B does not fit slot %s (%lu B)",
|
||||
(unsigned long)m.size, part->label, (unsigned long)part->size);
|
||||
return;
|
||||
}
|
||||
|
||||
print("[ota] installing %s -> %s (%lu bytes)", m.version, part->label, (unsigned long)m.size);
|
||||
|
||||
// Flash writes stall the PSRAM-fed RGB panel (flicker), so the screen is
|
||||
// dark while the image is written, with a notice before and after.
|
||||
char msg[160];
|
||||
snprintf(msg, sizeof(msg), "Updating to %s\n\nThe screen goes dark for about a minute.\nDo not switch off.", m.version);
|
||||
showNotice(msg);
|
||||
delay(3000); // time to read it; LVGL renders on its own task
|
||||
DisplayInit::setBacklight(false);
|
||||
bool ok = writeImage(m, part);
|
||||
DisplayInit::setBacklight(true);
|
||||
|
||||
// The download took a while - the driver may have started the engine since.
|
||||
if (!gate(false)) { print("[ota] new image left inactive in %s; retry when parked", part->label); return; }
|
||||
|
||||
err = esp_ota_set_boot_partition(part);
|
||||
if (err != ESP_OK) { print("[ota] set boot slot: %s", esp_err_to_name(err)); return; }
|
||||
if (ok && !gate(false)) {
|
||||
print("[ota] new image left inactive in %s; retry when parked", part->label);
|
||||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
esp_err_t err = esp_ota_set_boot_partition(part);
|
||||
if (err != ESP_OK) { print("[ota] set boot slot: %s", esp_err_to_name(err)); ok = false; }
|
||||
}
|
||||
if (!ok) {
|
||||
snprintf(msg, sizeof(msg), "Update failed\n\nStill running %s", FW_VERSION);
|
||||
showNotice(msg);
|
||||
delay(5000);
|
||||
hideNotice();
|
||||
return;
|
||||
}
|
||||
|
||||
print("[ota] verified and installed %s. Rebooting in 3 s; it confirms itself after %lu s of uptime.",
|
||||
m.version, (unsigned long)(OTA_CONFIRM_MS / 1000));
|
||||
snprintf(msg, sizeof(msg), "Installed %s\n\nRestarting...", m.version);
|
||||
showNotice(msg);
|
||||
Tunables::flush();
|
||||
delay(3000);
|
||||
esp_restart();
|
||||
}
|
||||
@@ -451,6 +517,7 @@ static void rollback() {
|
||||
if (!gate(false)) return;
|
||||
if (g_pending_verify) {
|
||||
print("[ota] rejecting this unconfirmed image; rebooting into the previous one");
|
||||
Tunables::flush();
|
||||
delay(500);
|
||||
esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||
return;
|
||||
@@ -469,7 +536,8 @@ static void rollback() {
|
||||
}
|
||||
esp_err_t err = esp_ota_set_boot_partition(other);
|
||||
if (err != ESP_OK) { print("[ota] set boot slot: %s", esp_err_to_name(err)); return; }
|
||||
print("[ota] booting %s (built %s %s) in 2 s", other->label, d.date, d.time);
|
||||
print("[ota] booting %s in 2 s", other->label);
|
||||
Tunables::flush();
|
||||
delay(2000);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,18 @@ static void save() {
|
||||
prefs.end();
|
||||
}
|
||||
|
||||
// Every flash write briefly stalls the PSRAM-fed RGB panel (flicker), so edits
|
||||
// are applied + pushed to B at once but written to NVS only after the user
|
||||
// stops tapping (SAVE_IDLE_MS), on leaving the Tuning screen, or before reboot.
|
||||
static const uint32_t SAVE_IDLE_MS = 3000;
|
||||
static bool g_dirty = false;
|
||||
static uint32_t g_dirty_ms = 0;
|
||||
|
||||
static void markDirty() { // call with the mutex held
|
||||
g_dirty = true;
|
||||
g_dirty_ms = millis();
|
||||
}
|
||||
|
||||
static bool load() {
|
||||
Preferences prefs;
|
||||
prefs.begin(NVS_NAMESPACE, true);
|
||||
@@ -113,7 +125,7 @@ static bool setField(const char* name, long v) {
|
||||
if (ok) {
|
||||
g_cfg.cfg_version++;
|
||||
if (g_cfg.cfg_version == 0) g_cfg.cfg_version = 1;
|
||||
save();
|
||||
markDirty();
|
||||
}
|
||||
unlock();
|
||||
return ok;
|
||||
@@ -159,7 +171,7 @@ void set(const link_config_t& cfg) {
|
||||
uint8_t v = g_cfg.cfg_version + 1;
|
||||
g_cfg = cfg;
|
||||
g_cfg.cfg_version = v ? v : 1;
|
||||
save();
|
||||
markDirty();
|
||||
unlock();
|
||||
}
|
||||
|
||||
@@ -168,7 +180,7 @@ void resetDefaults() {
|
||||
uint8_t v = g_cfg.cfg_version + 1;
|
||||
link_config_defaults(&g_cfg);
|
||||
g_cfg.cfg_version = v ? v : 1;
|
||||
save();
|
||||
markDirty();
|
||||
unlock();
|
||||
}
|
||||
|
||||
@@ -203,7 +215,7 @@ bool handleCommand(const char* line) {
|
||||
if (!strcmp(argv[1], "set") && argc == 4) {
|
||||
long v = strtol(argv[3], NULL, 0);
|
||||
if (setField(argv[2], v)) {
|
||||
print("[cfg] %s = %ld (version %u, saved)", argv[2], v, version());
|
||||
print("[cfg] %s = %ld (version %u, saved to NVS in 3 s)", argv[2], v, version());
|
||||
} else {
|
||||
print("[cfg] unknown field '%s'", argv[2]);
|
||||
help();
|
||||
@@ -247,7 +259,18 @@ void setExtraCommandHandler(bool (*handler)(const char* line)) {
|
||||
g_extra_handler = handler;
|
||||
}
|
||||
|
||||
void flush() {
|
||||
lock();
|
||||
if (g_dirty) {
|
||||
save();
|
||||
g_dirty = false;
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
void pollSerial() {
|
||||
if (g_dirty && millis() - g_dirty_ms > SAVE_IDLE_MS) flush();
|
||||
|
||||
while (Serial.available()) {
|
||||
char c = (char)Serial.read();
|
||||
if (c == '\r' || c == '\n') {
|
||||
|
||||
@@ -58,6 +58,13 @@ bool handleCommand(const char* line);
|
||||
*/
|
||||
void pollSerial();
|
||||
|
||||
/**
|
||||
* Write pending edits to NVS now. Edits are otherwise saved SAVE_IDLE_MS after
|
||||
* the last change (each flash write flickers the RGB panel). Call before a
|
||||
* reboot or when leaving the Tuning screen.
|
||||
*/
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* Register a second console command handler (e.g. DiagProbe::handleCommand)
|
||||
* that gets lines `cfg` does not recognise. Returns true if it consumed the line.
|
||||
|
||||
@@ -334,6 +334,7 @@ namespace TuningScreen
|
||||
{
|
||||
if (lv_event_get_code(e) != LV_EVENT_CLICKED)
|
||||
return;
|
||||
Tunables::flush(); // write pending edits now rather than after the idle delay
|
||||
DrivelineScreen::show();
|
||||
}
|
||||
|
||||
@@ -584,7 +585,7 @@ namespace TuningScreen
|
||||
{
|
||||
build();
|
||||
refreshFromTunables();
|
||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 0, false);
|
||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); // instant: fades stutter at 1024x600
|
||||
}
|
||||
|
||||
void tick()
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
||||
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
|
||||
- [[dual-controller-architecture]] — Controller A → UART1 + ESP-NOW, protocol v2 → Controller B (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
||||
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
|
||||
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; dual-slot partition table (2026-09-26); plan for updating Controller B through A over ESP-NOW
|
||||
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end 2026-09-26 (dev → v0.1.1)**; dual-slot partition table; plan for updating Controller B through A over ESP-NOW
|
||||
|
||||
## Synthesis
|
||||
|
||||
|
||||
@@ -117,3 +117,11 @@ Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offse
|
||||
## [2026-09-26] build | OTA bring-up: Wi-Fi switch, ESP-NOW, memory
|
||||
|
||||
First CI runs green (main-latest built with version main-1ec93dc baked in; v0.1.0 signed release verified off-device: sha256 + signature + /releases/latest). Bring-up on the board found: (1) the Settings Wi-Fi switch has been LV_STATE_DISABLED since the first SquareLine export - re-enabled at runtime; (2) WiFi.disconnect(true) in the Wi-Fi task powered the radio off and killed ESP-NOW whenever Wi-Fi was used - fixed + ESP-NOW self-heal; (3) internal RAM has 15.9 KB free / 7.6 KB largest block with Wi-Fi up, so neither a TLS task stack nor mbedtls's internal-only buffers fit - OTA jobs now run in the loop task with mbedtls routed to PSRAM; `ota check` then worked on-device (signature verified on the board, 3.6 KB stack headroom). Added `wifi join|status|off` console. v0.1.0 must not be installed (pre-fix OTA can't run once installed). Updated pages/ota-updates.md, CLAUDE.md.
|
||||
|
||||
## [2026-09-26] verify | First OTA update end-to-end
|
||||
|
||||
Bench (home, both controllers on laptop USB, no car): A running USB-flashed `dev` ran `ota install` -> v0.1.1 from the signed CI release: 1.65 MB in ~60 s, verified, rebooted into app1, confirmed after 30 s (rollback cancelled). v0.1.1 then passed `ota check` ("up to date"), so OTA-from-OTA works. ota-updates.md marked VERIFIED.
|
||||
|
||||
## [2026-09-26] build | Display quick fixes (v0.1.2)
|
||||
|
||||
User reported heavy flicker during OTA and on Gauge Tuning taps, and laggy swipes. Diagnosis: flash and PSRAM share the MSPI cache; every flash write (OTA, or the NVS save on each Tuning tap) stalls the PSRAM framebuffer the RGB panel streams from, with no bounce buffer (ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0) - a known ESP32-S3 RGB issue. Swipes: every transition was LV_SCR_LOAD_ANIM_FADE_ON 100 ms - a full 1024x600 software re-render + alpha blend per frame. Also: the Debug "FPS" counts loop() passes (loop sleeps 100 ms), not rendering - real render FPS has never been measured. Quick fixes: instant screen switches; Tunables NVS writes deferred to 3 s idle / leaving Tuning; backlight off during OTA writes with before/after notices; firmware version label bottom-right on every screen. Real cure (bounce buffers + SPIRAM_XIP_FROM_PSRAM via custom_sdkconfig, needs internal RAM freed first) is planned as one measured bench session with open-questions #13.
|
||||
|
||||
@@ -70,4 +70,4 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
- ~~A worked generic-PID set for an M57 diesel~~ ✅ ingested → [[dwr-335d-torque-pids]] (2009 335d, DDE7.3; J1979 mode-01 scalings gauge-checked by the author)
|
||||
- DWR's **Testo parameter list** (e90post "Testo" thread, post 175, German→English names of the DDE's non-standard values) — the pointer for Route B identifiers if our own Launch capture is not enough
|
||||
|
||||
13. **Internal RAM is nearly exhausted (found 2026-09-26).** With display + Wi-Fi up: 15.9 KB internal free, largest block 7.6 KB (PSRAM 7.1 MB free). OTA works around it ([[ota-updates]]), but anything else that needs an internal allocation (another task, a TLS client, a bigger Wi-Fi burst) can fail. Biggest known consumer: the LVGL 60-line DMA draw buffer (~120 KB). Options: shrink it to ~30–40 lines, or measure what else lives in internal RAM first (`heap_caps_print_heap_info`). Not urgent, but it limits every future feature.
|
||||
13. **Internal RAM is nearly exhausted (found 2026-09-26).** With display + Wi-Fi up: 15.9 KB internal free, largest block 7.6 KB (PSRAM 7.1 MB free). OTA works around it ([[ota-updates]]), but anything else that needs an internal allocation (another task, a TLS client, a bigger Wi-Fi burst) can fail. Biggest known consumer: the LVGL 60-line DMA draw buffer (~120 KB). Options: shrink it to ~30–40 lines, or measure what else lives in internal RAM first (`heap_caps_print_heap_info`). Not urgent, but it limits every future feature. **Same project as the display flicker/lag (2026-09-26):** flash writes flicker the PSRAM-fed RGB panel (no bounce buffer) and full-screen transitions stutter. Espressif's cure is bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` (needs pioarduino `custom_sdkconfig`), and bounce buffers need internal RAM — so free RAM, add bounce buffers, and measure real render FPS (LVGL perf monitor; the Debug "FPS" counts `loop()` passes, not frames) in one bench session. Quick mitigations shipped in v0.1.2 (instant screen switches, deferred NVS saves, dark screen during OTA).
|
||||
|
||||
@@ -26,6 +26,14 @@ Controller A `ota install` ◄──────┘ (parked, Wi-Fi joined)
|
||||
|
||||
Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsigned, no manifest, for bench/USB testing. `/releases/latest` skips pre-releases, so the car is never offered it `(repo)`.
|
||||
|
||||
## Status: VERIFIED end-to-end `(verified 2026-09-26, bench, USB power, Wi-Fi Personal1)`
|
||||
|
||||
`dev` (USB-flashed) → `ota install` → **v0.1.1** from CI: 1.65 MB downloaded + written in ~60 s (~27 KB/s), sha256 + signature OK, rebooted into `app1` as PENDING_VERIFY, ESP-NOW up, **confirmed after 30 s**. The installed v0.1.1 then ran `ota check` itself ("up to date") — it can take the next update. Previous image kept in `app0` for `ota rollback`.
|
||||
|
||||
During the write the backlight is off (flash writes flicker the PSRAM-fed panel): a full-screen notice "Updating to vX … do not switch off" shows for 3 s first, then "Installed vX / Restarting" or "Update failed / still running vY" (v0.1.2+). The running version is always shown bottom-right on every screen.
|
||||
|
||||
Known quirk: `ota status` shows the *other* slot's "built" date from the framework's precompiled app descriptor (e.g. "Nov 4 2025"), not our build time — ignore it.
|
||||
|
||||
## Decisions and why
|
||||
|
||||
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Controller B's gauges; nothing checks or installs in the background. Today the trigger is the `ota` serial console; the intended home is the password-gated **Diagnostics screen** ([[open-questions]] #12), the same gate as active CAN polling.
|
||||
|
||||
Reference in New Issue
Block a user