Downloads balance-firmware.bin from Gitea release URL to inactive OTA partition, streams SHA256 verification via mbedTLS, sets boot partition and reboots. Auto-rollback via CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE if ota_self_health_check() not called within 30 s of boot. Progress 0-100% in g_ota_self_progress for display task. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
#pragma once
|
|
/* ota_self.h — Balance self-OTA (bd-18nb)
|
|
*
|
|
* Downloads balance-firmware.bin from Gitea release URL to the inactive
|
|
* OTA partition, verifies SHA256, sets boot partition, reboots.
|
|
* Auto-rollback if health check not called within ROLLBACK_WINDOW_S seconds.
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#define OTA_ROLLBACK_WINDOW_S 30
|
|
|
|
typedef enum {
|
|
OTA_SELF_IDLE = 0,
|
|
OTA_SELF_CHECKING, /* (unused — gitea_ota handles this) */
|
|
OTA_SELF_DOWNLOADING,
|
|
OTA_SELF_VERIFYING,
|
|
OTA_SELF_APPLYING,
|
|
OTA_SELF_REBOOTING,
|
|
OTA_SELF_FAILED,
|
|
} ota_self_state_t;
|
|
|
|
extern volatile ota_self_state_t g_ota_self_state;
|
|
extern volatile uint8_t g_ota_self_progress; /* 0-100 % */
|
|
|
|
/* Trigger a Balance self-update.
|
|
* Uses g_balance_update (from gitea_ota). Non-blocking: starts in a task.
|
|
* Returns false if no update available or OTA already in progress. */
|
|
bool ota_self_trigger(void);
|
|
|
|
/* Called from app_main after boot to mark the running image as valid.
|
|
* Must be called within OTA_ROLLBACK_WINDOW_S after boot or rollback fires. */
|
|
void ota_self_health_check(void);
|