FwUpdate: admin-pushed OTA without a bootloader change (bench stage)

This commit is contained in:
tth committed 2026-11-12 14:24:24 +01:00
1 parent ad4f53016c
commit daaf0c2267
6 files changed
+939 -83

No files matched your search

+18 -14
View File
@@ -11,6 +11,7 @@
// line per hook, and the upstream files it touches stay one added line each.
//
// dfu [uf2|serial|ota] reboot into the bootloader (local console only)
// fw ... admin-pushed firmware update, see helpers/FwUpdate.h
// set radio.silence <min> radio silence watchdog, 0/off = disabled (#6)
// get radio.silence threshold, backoff, quiet time, stage
// get radio.reboots reboots done by the watchdog, survives power loss
@@ -25,45 +26,48 @@
#include <Arduino.h>
#include <Mesh.h>
#include <helpers/CommonCLI.h>
#include <helpers/FwUpdate.h>
#include <helpers/RadioSilenceWatchdog.h>
#include <helpers/radiolib/RadioLibWrappers.h>
class NodeMaintenance {
public:
NodeMaintenance(mesh::MainBoard& board, RadioLibWrapper& radio) : _board(board), _radio(radio) { }
NodeMaintenance(mesh::MainBoard &board, RadioLibWrapper &radio)
: _board(board), _radio(radio), _fw(board) {}
// Prints (and latches for `get boot`) the reset reason and the hardfault record.
// The record is cleared once read, so call it once, as early as Serial is up.
void printBootDiag();
void begin(FILESYSTEM* fs, NodePrefs* prefs, CommonCLICallbacks* callbacks);
void begin(FILESYSTEM *fs, NodePrefs *prefs, CommonCLICallbacks *callbacks);
void loop();
// sender_timestamp == 0 means the local console (the same test CommonCLI uses
// for `erase`); `dfu` refuses anything else.
bool handleCommand(uint32_t sender_timestamp, const char* command, char* reply);
bool handleCommand(uint32_t sender_timestamp, const char *command, char *reply);
private:
uint32_t radioActivity() const { return _radio.getPacketsRecv() + _radio.getPacketsRecvErrors(); }
void silenceLoad(uint8_t* backoff);
void silenceLoad(uint8_t *backoff);
void silenceSave(uint8_t backoff);
bool dfuCommand(uint32_t sender_timestamp, const char* command, char* reply);
bool silenceCommand(const char* command, char* reply);
bool dfuCommand(uint32_t sender_timestamp, const char *command, char *reply);
bool silenceCommand(const char *command, char *reply);
void dfuTick();
mesh::MainBoard& _board;
RadioLibWrapper& _radio;
FILESYSTEM* _fs = NULL;
NodePrefs* _prefs = NULL;
CommonCLICallbacks* _callbacks = NULL;
mesh::MainBoard &_board;
RadioLibWrapper &_radio;
FILESYSTEM *_fs = NULL;
NodePrefs *_prefs = NULL;
CommonCLICallbacks *_callbacks = NULL;
FwUpdate _fw;
RadioSilenceWatchdog _silence;
uint32_t _silence_reboots = 0;
unsigned long _dfu_at = 0; // 0 = nothing armed
uint8_t _dfu_mode = 0; // 0=uf2 1=serial 2=ota
unsigned long _dfu_at = 0; // 0 = nothing armed
uint8_t _dfu_mode = 0; // 0=uf2 1=serial 2=ota
uint32_t _reset_reason = 0;
uint32_t _hardfault[3] = {0, 0, 0}; // pc, lr, psr; pc 0 = none
uint32_t _hardfault[3] = { 0, 0, 0 }; // pc, lr, psr; pc 0 = none
bool _hardfault_seen = false;
};