File syn_boot.h¶
FileList > src > syntropic > system > syn_boot.h
Go to the source code of this file
Boot manager — reset reason, boot counter, safe-mode detection. More...
#include "../common/syn_defs.h"#include "../storage/syn_param.h"#include "../system/syn_errlog.h"#include <stdbool.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_Boot Boot manager — crash-loop detection and safe-mode state. |
| struct | SYN_BootData Boot data persisted to flash across resets. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_ResetReason Reset reason codes — application can extend from SYN_RESET_USER. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_boot_clear_safe_mode (SYN_Boot * boot) Force clear safe mode and reset fail counter. |
| SYN_Status | syn_boot_init (SYN_Boot * boot, SYN_ParamStore * store, uint16_t safe_threshold) Initialize the boot manager. |
| void | syn_boot_log_events (SYN_Boot * boot) Log boot events to errlog. |
| SYN_Status | syn_boot_mark_healthy (SYN_Boot * boot) Mark this boot as healthy. |
| void | syn_boot_set_errlog (SYN_Boot * boot, SYN_ErrLog * errlog) Set the errlog instance for boot event recording. |
| void | syn_boot_set_reset_reason (SYN_Boot * boot, uint8_t reason) Set the reset reason for the current boot. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint32_t | syn_boot_count (const SYN_Boot * boot) Get total boot count. |
| uint16_t | syn_boot_fail_count (const SYN_Boot * boot) Get consecutive fail count. |
| bool | syn_boot_is_safe_mode (const SYN_Boot * boot) Check if we're in safe mode. |
| uint8_t | syn_boot_reset_reason (const SYN_Boot * boot) Get last reset reason. |
Detailed Description¶
Uses the parameter store to persist boot state across resets. Detects crash loops (too many resets without a successful "mark healthy") and can trigger safe-mode behavior.
** **
static SYN_Boot boot;
static SYN_ParamStore boot_store;
// In early init:
syn_param_init(&boot_store, BOOT_FLASH_ADDR, 2, sizeof(SYN_BootData));
syn_boot_init(&boot, &boot_store, 3); // safe mode after 3 failures
if (syn_boot_is_safe_mode(&boot)) {
// Load minimal config, disable risky features
}
// After successful startup:
syn_boot_mark_healthy(&boot);
Public Types Documentation¶
enum SYN_ResetReason¶
Reset reason codes — application can extend from SYN_RESET_USER.
enum SYN_ResetReason {
SYN_RESET_UNKNOWN = 0,
SYN_RESET_POWER_ON = 1,
SYN_RESET_WATCHDOG = 2,
SYN_RESET_SOFTWARE = 3,
SYN_RESET_EXTERNAL = 4,
SYN_RESET_BROWNOUT = 5,
SYN_RESET_ASSERT = 6,
SYN_RESET_USER = 0x80
};
Public Functions Documentation¶
function syn_boot_clear_safe_mode¶
Force clear safe mode and reset fail counter.
Use from CLI to recover from safe mode.
Parameters:
bootBoot manager.
Returns:
SYN_OK on success.
function syn_boot_init¶
Initialize the boot manager.
Loads boot data from flash, increments boot counter, checks for crash loops. Call this very early in boot.
Parameters:
bootBoot manager instance.storeInitialized parameter store for boot data.safe_thresholdNumber of consecutive failed boots before safe mode. Set to 0 to disable safe mode detection.
Returns:
SYN_OK on normal boot, SYN_ERROR on first-ever boot (no data).
function syn_boot_log_events¶
Log boot events to errlog.
Records crash-loop (non-healthy previous boot) and safe-mode entry events. Call after syn_boot_set_errlog().
Parameters:
bootBoot manager.
function syn_boot_mark_healthy¶
Mark this boot as healthy.
Call after your application has started successfully (e.g., after all peripherals initialized, comms established). Resets the fail counter.
Parameters:
bootBoot manager.
Returns:
SYN_OK on success.
function syn_boot_set_errlog¶
Set the errlog instance for boot event recording.
Call after both boot and errlog are initialized, then call syn_boot_log_events() to retroactively log boot-related events.
Parameters:
bootBoot manager.errlogInitialized error log instance.
function syn_boot_set_reset_reason¶
Set the reset reason for the current boot.
Call before saving (or it gets saved on next boot_init).
Parameters:
bootBoot manager.reasonReset reason code (SYN_ResetReason or custom).
Public Static Functions Documentation¶
function syn_boot_count¶
Get total boot count.
Parameters:
bootBoot manager.
Returns:
Monotonic boot count.
function syn_boot_fail_count¶
Get consecutive fail count.
Parameters:
bootBoot manager.
Returns:
Number of boots without a healthy mark.
function syn_boot_is_safe_mode¶
Check if we're in safe mode.
Parameters:
bootBoot manager.
Returns:
true if in safe mode.
function syn_boot_reset_reason¶
Get last reset reason.
Parameters:
bootBoot manager.
Returns:
SYN_ResetReason or custom code.
The documentation for this class was generated from the following file src/syntropic/system/syn_boot.h