rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
fw_ota.h File Reference

The application slots, as the installer and the start-up need them. More...

#include <stdbool.h>
#include <stdint.h>
#include "fw_boot.h"
#include "fw_image.h"
#include "fw_install.h"

Go to the source code of this file.

Functions

uint32_t fw_ota_slot_bytes (void)
 The slot an update writes.
bool fw_ota_running (fw_image_info_t *out)
 The running build: version and ELF (executable and linkable format) SHA-256, as fw_offer() compares them.
const fw_flash_t * fw_ota_flash (void)
 The slot that is not running, for fw_install_begin().
void fw_ota_note_restart (const char *version)
 Before the restart into a written slot: what the next start reports when that build does not stay. Kept in memory a software restart keeps and a power cut clears.
bool fw_ota_trial_pending (void)
 Whether the running build is on its first start after an update (pending verify), and fw_ota_boot_check() still settles it.
fw_boot_t fw_ota_boot_check (bool ui_up, char *other, uint32_t other_cap)
 Once per start: with ui_up false at the display or touch failing, or with ui_up true once the start is known to work (fw_trial.h).

Detailed Description

The application slots, as the installer and the start-up need them.

The flash holds two application slots, ota_0 and ota_1, and otadata, which names the one the bootloader starts. An update writes the slot that is not running (fw_ota_flash()), checks it and names it in otadata. The bootloader is built with rollback (CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE): a new build's first start is a trial, and a start that resets before fw_ota_boot_check() keeps it goes back to the build before it. When the panel calls it to keep the build is shared/fwupdate/fw_trial.h's rule (firmware/panel/main/panel_trial.c).

SPDX-License-Identifier: MIT

Function Documentation

◆ fw_ota_boot_check()

fw_boot_t fw_ota_boot_check ( bool ui_up,
char * other,
uint32_t other_cap )

Once per start: with ui_up false at the display or touch failing, or with ui_up true once the start is known to work (fw_trial.h).

On a build's first start after an update: ui_up keeps it (FW_BOOT_UPDATED, or FW_BOOT_UNCONFIRMED when otadata could not be written), otherwise the panel restarts into the build before it and this does not return (fw_boot_decide()). After a start that went back: FW_BOOT_ROLLED_BACK with the written build's version in other, when fw_ota_note_restart() was called before it and no power cut came between.

Parameters
ui_upWhether the start is kept (true) or goes back (false).
otherWhere the written build's version goes; may be NULL with other_cap 0.
other_capBytes at other.
Returns
What the check found.

◆ fw_ota_flash()

const fw_flash_t * fw_ota_flash ( void )

The slot that is not running, for fw_install_begin().

Returns
Its writer.

◆ fw_ota_note_restart()

void fw_ota_note_restart ( const char * version)

Before the restart into a written slot: what the next start reports when that build does not stay. Kept in memory a software restart keeps and a power cut clears.

Parameters
versionThe written build's version.

◆ fw_ota_running()

bool fw_ota_running ( fw_image_info_t * out)

The running build: version and ELF (executable and linkable format) SHA-256, as fw_offer() compares them.

Parameters
outWhere they go.
Returns
False when its version does not parse.

◆ fw_ota_slot_bytes()

uint32_t fw_ota_slot_bytes ( void )

The slot an update writes.

Returns
Its bytes; 0 when the table has no second slot.

◆ fw_ota_trial_pending()

bool fw_ota_trial_pending ( void )

Whether the running build is on its first start after an update (pending verify), and fw_ota_boot_check() still settles it.

Returns
True on a trial start.