Skip to content

File syn_boot.c

FileList > src > syntropic > system > syn_boot.c

Go to the source code of this file

Boot manager implementation.

  • #include "../system/syn_errlog.h"
  • #include "../util/syn_assert.h"
  • #include "syn_boot.h"
  • #include <string.h>

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.

Macros

Type Name
define SYN_BOOT_ERR_CRASH_LOOP 0x0300
define SYN_BOOT_ERR_SAFE_MODE 0x0301

Public Functions Documentation

function syn_boot_clear_safe_mode

Force clear safe mode and reset fail counter.

SYN_Status syn_boot_clear_safe_mode (
    SYN_Boot * boot
) 

Use from CLI to recover from safe mode.

Parameters:

  • boot Boot manager.

Returns:

SYN_OK on success.


function syn_boot_init

Initialize the boot manager.

SYN_Status syn_boot_init (
    SYN_Boot * boot,
    SYN_ParamStore * store,
    uint16_t safe_threshold
) 

Loads boot data from flash, increments boot counter, checks for crash loops. Call this very early in boot.

Parameters:

  • boot Boot manager instance.
  • store Initialized parameter store for boot data.
  • safe_threshold Number 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.

void syn_boot_log_events (
    SYN_Boot * boot
) 

Records crash-loop (non-healthy previous boot) and safe-mode entry events. Call after syn_boot_set_errlog().

Parameters:

  • boot Boot manager.

function syn_boot_mark_healthy

Mark this boot as healthy.

SYN_Status syn_boot_mark_healthy (
    SYN_Boot * boot
) 

Call after your application has started successfully (e.g., after all peripherals initialized, comms established). Resets the fail counter.

Parameters:

  • boot Boot manager.

Returns:

SYN_OK on success.


function syn_boot_set_errlog

Set the errlog instance for boot event recording.

void syn_boot_set_errlog (
    SYN_Boot * boot,
    SYN_ErrLog * errlog
) 

Call after both boot and errlog are initialized, then call syn_boot_log_events() to retroactively log boot-related events.

Parameters:

  • boot Boot manager.
  • errlog Initialized error log instance.

function syn_boot_set_reset_reason

Set the reset reason for the current boot.

void syn_boot_set_reset_reason (
    SYN_Boot * boot,
    uint8_t reason
) 

Call before saving (or it gets saved on next boot_init).

Parameters:

  • boot Boot manager.
  • reason Reset reason code (SYN_ResetReason or custom).

Macro Definition Documentation

define SYN_BOOT_ERR_CRASH_LOOP

#define SYN_BOOT_ERR_CRASH_LOOP `0x0300`

Repeated crash detected.


define SYN_BOOT_ERR_SAFE_MODE

#define SYN_BOOT_ERR_SAFE_MODE `0x0301`

Entered safe mode.



The documentation for this class was generated from the following file src/syntropic/system/syn_boot.c