PER Firmware
Loading...
Searching...
No Matches
bootloader_common.h File Reference
#include <stdint.h>
Include dependency graph for bootloader_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BOOTLOADER_PROTOCOL_VERSION   1U
 
#define BOOTLOADER_INFO_PERIOD_MS   5000U
 
#define BOOTLOADER_INFO_FLAG_BOOTLOADABLE   (1U << 0U)
 
#define BOOTLOADER_INFO_FLAG_READY   (1U << 1U)
 
#define BOOTLOADER_METADATA_MAGIC   0x50455242U
 
#define BOOTLOADER_METADATA_FORMAT_VERSION   2U
 
#define BOOTLOADER_METADATA_FLAG_INSTALLED_BY_BOOTLOADER   (1U << 0U)
 
#define BL_METADATA_SIZE   32U
 STM32G474RE flash layout shared with the linker scripts.
 
#define BL_WORD_SIZE   4U
 
#define BL_FLASH_WRITE_SIZE   8U
 

Enumerations

enum  BLError_t {
  BLERROR_NONE = 0x00 , BLERROR_LOCKED = 0x01 , BLERROR_SEQUENCE = 0x02 , BLERROR_FLASH = 0x03 ,
  BLERROR_SIZE = 0x04 , BLERROR_ADDRESS = 0x05
}
 Detail values accompanying BOOTLOADER_STATUS_ERROR. More...
 

Functions

struct __attribute__ ((aligned(BL_FLASH_WRITE_SIZE)))
 Metadata describing the only application the bootloader may launch.
 
uint32_t BL_getGitHash (void)
 

Variables

 BootloaderMetadata_t
 

Macro Definition Documentation

◆ BL_FLASH_WRITE_SIZE

#define BL_FLASH_WRITE_SIZE   8U

STM32G4 flash programming granularity.

◆ BL_METADATA_SIZE

#define BL_METADATA_SIZE   32U

STM32G474RE flash layout shared with the linker scripts.

Applications occupy the full 480 KiB remaining after the resident image and metadata at BL_APP_ADDRESS. The metadata region and application slot begin on flash erase-page boundaries; PHAL_FLASH_erase() erases complete pages even when passed the metadata record. Programming addresses are 8-byte aligned.

Images and CRC input are 32-bit-word aligned. The package builder pads a partial final word with erased bytes before recording size_bytes and crc32. An odd number of image words is then padded with one erased 32-bit word for the final 8-byte flash write; that physical padding is outside size_bytes. The metadata record is written last and acts as the commit marker. Size of the committed metadata record.

◆ BL_WORD_SIZE

#define BL_WORD_SIZE   4U

Wire and CRC payload granularity.

◆ BOOTLOADER_INFO_FLAG_BOOTLOADABLE

#define BOOTLOADER_INFO_FLAG_BOOTLOADABLE   (1U << 0U)

Information-frame flag indicating that the bootloader accepts updates.

◆ BOOTLOADER_INFO_FLAG_READY

#define BOOTLOADER_INFO_FLAG_READY   (1U << 1U)

Information-frame flag indicating that the resident image is ready.

◆ BOOTLOADER_INFO_PERIOD_MS

#define BOOTLOADER_INFO_PERIOD_MS   5000U

Period between resident bootloader information frames.

◆ BOOTLOADER_METADATA_FLAG_INSTALLED_BY_BOOTLOADER

#define BOOTLOADER_METADATA_FLAG_INSTALLED_BY_BOOTLOADER   (1U << 0U)

Metadata flag set only by the final installation write.

◆ BOOTLOADER_METADATA_FORMAT_VERSION

#define BOOTLOADER_METADATA_FORMAT_VERSION   2U

Metadata layout version accepted by resident bootloaders.

◆ BOOTLOADER_METADATA_MAGIC

#define BOOTLOADER_METADATA_MAGIC   0x50455242U

Magic identifying a BootloaderMetadata_t record (ASCII "PERB").

◆ BOOTLOADER_PROTOCOL_VERSION

#define BOOTLOADER_PROTOCOL_VERSION   1U

Bootloader wire-protocol version reported with BOOTLOADER_STATUS_READY.

Enumeration Type Documentation

◆ BLError_t

enum BLError_t

Detail values accompanying BOOTLOADER_STATUS_ERROR.

Enumerator
BLERROR_NONE 
BLERROR_LOCKED 

Data arrived before START.

BLERROR_SEQUENCE 

A word was skipped or commit was premature.

BLERROR_FLASH 

Flash erase, programming, or verify failed.

BLERROR_SIZE 

Image size is empty, unaligned, or too large.

BLERROR_ADDRESS 

Image, vector, or metadata address is invalid.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (aligned(BL_FLASH_WRITE_SIZE)) )

Metadata describing the only application the bootloader may launch.

This record is written after the image at BL_APP_ADDRESS has passed sequence, CRC, and vector validation. A missing or inconsistent record prevents application launch.

< Must equal BOOTLOADER_METADATA_MAGIC.

< Must equal BOOTLOADER_METADATA_FORMAT_VERSION.

< Must include INSTALLED_BY_BOOTLOADER.

< CRC-32/MPEG-2 over the application words.

< Must equal BL_APP_ADDRESS.

< Non-zero, word-aligned application length.

< Resident bootloader build advertised by the app.

< Reserved for a future metadata format.

◆ BL_getGitHash()

uint32_t BL_getGitHash ( void )

Return the installed resident bootloader hash, or zero when unavailable.

Here is the caller graph for this function:

Variable Documentation

◆ BootloaderMetadata_t

BootloaderMetadata_t