CycloneBOOT 2.6.6
Secure Bootloader for ARM Cortex-M MCU
Loading...
Searching...
No Matches
mailbox.c File Reference

Boot Mailbox mangement functions. More...

#include "mailbox.h"

Macros

#define TRACE_LEVEL   CBOOT_TRACE_LEVEL
 

Functions

cboot_error_t mailBoxInit (void)
 Initializes the shared bootloader mailbox if signature is not valid. The NVM flag storage is initialized on every call when BOOT_MAILBOX_NVM_SUPPORT is enabled.
 
bool_t mailBoxIsUpdateRequested (void)
 Checks whether UPDATE_REQUESTED message is present in the mailbox.
 
void mailBoxSetUpdateRequested (bool_t state)
 Posts UPDATE_REQUESTED message to the mailbox.
 
bool_t mailBoxIsUpdatePerformed (void)
 Checks whether UPDATE_PERFORMED message is present in the mailbox.
 
void mailBoxSetUpdatePerformed (bool_t state)
 Posts UPDATE_PERFORMED message to the mailbox.
 
bool_t mailBoxIsUpdateConfirmed (void)
 Checks whether UPDATE_CONFIRMED message is present in the mailbox.
 
void mailBoxSetUpdateConfirmed (bool_t state)
 Posts UPDATE_REQUESTED message to the mailbox.
 
bool_t mailBoxIsFallbackRequested (void)
 Checks whether FALLBACK_REQUESTED message is present in the mailbox.
 
void mailBoxSetFallbackRequested (bool_t state)
 Posts FALLBACK_REQUESTED message to the mailbox.
 
bool_t mailBoxIsFallbackPerformed (void)
 Checks whether FALLBACK_PERFORMED message is present in the mailbox.
 
void mailBoxSetFallbackPerformed (bool_t state)
 Posts FALLBACK_PERFORMED message to the mailbox.
 
bool_t mailBoxIsFallbackAvailable (void)
 Checks whether a fall back to a previous firmware is possible.
 
void mailBoxSetFallbackAvailable (bool_t state)
 Posts FALLBACK_AVAILABLE message to the mailbox.
 
bool_t mailBoxIsRepairPerformed (void)
 Tells whether the bootloader already reinstalled a candidate to repair the application.
 
void mailBoxSetRepairPerformed (bool_t state)
 Posts REPAIR_PERFORMED message to the mailbox.
 
void mailBoxSetFirstStageVersion (const ImageVersion *version)
 Publish the first-stage version for later stages (HDP/HDPL-safe).
 
const ImageVersion * mailBoxGetFirstStageVersion (void)
 Get the first-stage version published in the mailbox.
 
void mailBoxSetSecondStageVersion (const ImageVersion *version)
 Publish the second-stage version for the application to read.
 
const ImageVersion * mailBoxGetSecondStageVersion (void)
 Get the second-stage version published in the mailbox.
 
void mailBoxIncrementBootCounter (void)
 Increments the boot counter in the mailbox.
 
uint32_t mailBoxGetBootCounter (void)
 Returns the current value of the boot counter in the mailbox.
 
void mailBoxClearBootCounter (void)
 Clears the current value of the boot counter in the mailbox.
 
void mailBoxSetPsk (const uint8_t *psk, size_t pskSize)
 Set Pre-Shared Key value of the mailbox.
 
void mailBoxGetPsk (uint8_t *psk, size_t *pskSize)
 Returns a copy of Pre-Shared Key value of the mailbox.
 
void mailBoxClearPsk (void)
 Clear the Pre-Shared Key from the mailbox.
 

Detailed Description

Boot Mailbox mangement functions.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2021-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneBOOT Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.6

Function Documentation

◆ mailBoxGetFirstStageVersion()

const ImageVersion * mailBoxGetFirstStageVersion ( void  )

Get the first-stage version published in the mailbox.

Returns
First-stage image version

◆ mailBoxGetPsk()

void mailBoxGetPsk ( uint8_t *  psk,
size_t *  pskSize 
)

Returns a copy of Pre-Shared Key value of the mailbox.

Parameters
[in]pskpointer to a buffer where pre-shared key will be copied
[in]pskSizepointer to a variable where the length of the pre-shared key will be copied

◆ mailBoxGetSecondStageVersion()

const ImageVersion * mailBoxGetSecondStageVersion ( void  )

Get the second-stage version published in the mailbox.

Returns
Second-stage image version

◆ mailBoxIncrementBootCounter()

void mailBoxIncrementBootCounter ( void  )

Increments the boot counter in the mailbox.

Note
The boot counter is RAM-only; it is not persisted to NVM even when BOOT_MAILBOX_NVM_SUPPORT is enabled (unlike the event flags).

◆ mailBoxInit()

cboot_error_t mailBoxInit ( void  )

Initializes the shared bootloader mailbox if signature is not valid. The NVM flag storage is initialized on every call when BOOT_MAILBOX_NVM_SUPPORT is enabled.

Returns
Status code, the NVM initialization result when it is enabled

◆ mailBoxIsFallbackAvailable()

bool_t mailBoxIsFallbackAvailable ( void  )

Checks whether a fall back to a previous firmware is possible.

Note
Published by the bootloader each boot; read by the application to decide whether to offer a fall back.
Returns
TRUE or FALSE

◆ mailBoxIsFallbackPerformed()

bool_t mailBoxIsFallbackPerformed ( void  )

Checks whether FALLBACK_PERFORMED message is present in the mailbox.

Returns
TRUE or FALSE

◆ mailBoxIsFallbackRequested()

bool_t mailBoxIsFallbackRequested ( void  )

Checks whether FALLBACK_REQUESTED message is present in the mailbox.

Returns
TRUE or FALSE

◆ mailBoxIsRepairPerformed()

bool_t mailBoxIsRepairPerformed ( void  )

Tells whether the bootloader already reinstalled a candidate to repair the application.

Returns
TRUE or FALSE

◆ mailBoxIsUpdateConfirmed()

bool_t mailBoxIsUpdateConfirmed ( void  )

Checks whether UPDATE_CONFIRMED message is present in the mailbox.

Returns
TRUE or FALSE

◆ mailBoxIsUpdatePerformed()

bool_t mailBoxIsUpdatePerformed ( void  )

Checks whether UPDATE_PERFORMED message is present in the mailbox.

Returns
TRUE or FALSE

◆ mailBoxIsUpdateRequested()

bool_t mailBoxIsUpdateRequested ( void  )

Checks whether UPDATE_REQUESTED message is present in the mailbox.

Returns
TRUE or FALSE

◆ mailBoxSetFallbackAvailable()

void mailBoxSetFallbackAvailable ( bool_t  state)

Posts FALLBACK_AVAILABLE message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetFallbackPerformed()

void mailBoxSetFallbackPerformed ( bool_t  state)

Posts FALLBACK_PERFORMED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetFallbackRequested()

void mailBoxSetFallbackRequested ( bool_t  state)

Posts FALLBACK_REQUESTED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetFirstStageVersion()

void mailBoxSetFirstStageVersion ( const ImageVersion *  version)

Publish the first-stage version for later stages (HDP/HDPL-safe).

Parameters
[in]versionFirst-stage image version

◆ mailBoxSetPsk()

void mailBoxSetPsk ( const uint8_t *  psk,
size_t  pskSize 
)

Set Pre-Shared Key value of the mailbox.

Parameters
[in]pskpointer to the pre-shared key
[in]pskSizelength of the pre-shared key

◆ mailBoxSetRepairPerformed()

void mailBoxSetRepairPerformed ( bool_t  state)

Posts REPAIR_PERFORMED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetSecondStageVersion()

void mailBoxSetSecondStageVersion ( const ImageVersion *  version)

Publish the second-stage version for the application to read.

Parameters
[in]versionSecond-stage image version

◆ mailBoxSetUpdateConfirmed()

void mailBoxSetUpdateConfirmed ( bool_t  state)

Posts UPDATE_REQUESTED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetUpdatePerformed()

void mailBoxSetUpdatePerformed ( bool_t  state)

Posts UPDATE_PERFORMED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE

◆ mailBoxSetUpdateRequested()

void mailBoxSetUpdateRequested ( bool_t  state)

Posts UPDATE_REQUESTED message to the mailbox.

Parameters
[in]statestate of the flag, TRUE or FALSE