|
STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers
|
Macros | |
| #define | USE_WRITE_PROTECTION 0 |
| #define | CLEAR_RESET_FLAGS 1 |
| #define | APP_FILE_NAME "app-demo.bin" |
| #define | CRC_FILE_NAME "app-demo.crc" |
| #define | APP_ADDRESS ((uint32_t)&LINKER_APP_AREA_ORIGIN) |
| #define | APP_SIZE ((uint32_t)&LINKER_APP_AREA_LENGTH) |
Typedefs | |
| typedef void(* | Function) (void) |
Functions | |
| bool | BootloaderUpdateFirmware (void) |
| This function performs the complete application update procedure. More... | |
| bool | BootloaderCheckForApplication (void) |
| This function checks whether a valid application exists in flash. More... | |
| void | BootloaderJumpToApplication (void) |
| This function performs the jump to the user application in flash. More... | |
| void | BootloaderJumpToSysMem (void) |
| This function performs the jump to the microcontroller System Memory (ST built-in bootloader). More... | |
| static bool | CheckApplicationSize (void) |
| Check whether the application binary on the SD card fits into the available flash memory region designated for the application. More... | |
| static bool | CheckApplicationCrc (void) |
| Validate the integrity of the application binary by comparing a CRC-32 value calculated over the file contents against the reference CRC value read from a separate file on the SD card. More... | |
| static bool | UpdateApplication (void) |
| Erase the application flash region and program it with the contents of the application binary file from the SD card, page by page. More... | |
| static bool | VerifyApplication (void) |
| Verify the programmed flash contents against the original application binary file on the SD card by performing a word-by-word comparison. More... | |
| static bool | CalculateCrcOfFile (uint32_t *const crc) |
| Calculate the CRC-32 checksum of the application binary file on the SD card using the hardware CRC peripheral. More... | |
| static bool | ReadCrcFromFile (uint32_t *const crc) |
| Read the expected CRC-32 value from a dedicated CRC file on the SD card and convert the hexadecimal string representation to an integer. More... | |
Variables | |
| const uint32_t | LINKER_APP_AREA_ORIGIN |
| const uint32_t | LINKER_APP_AREA_LENGTH |
| static uint8_t | readBuffer [FLASH_PAGE_SIZE] = {0} |
| #define APP_ADDRESS ((uint32_t)&LINKER_APP_AREA_ORIGIN) |
Helper define for the application area start address
Definition at line 70 of file bootloader.h.
| #define APP_FILE_NAME "app-demo.bin" |
File name of application image located on SD card
Definition at line 46 of file bootloader.h.
| #define APP_SIZE ((uint32_t)&LINKER_APP_AREA_LENGTH) |
Helper define for the application area size
Definition at line 83 of file bootloader.h.
| #define CLEAR_RESET_FLAGS 1 |
Clear reset flags
Definition at line 43 of file bootloader.h.
| #define CRC_FILE_NAME "app-demo.crc" |
File name that contains the application CRC located on SD card
Definition at line 49 of file bootloader.h.
| #define USE_WRITE_PROTECTION 0 |
Enable write protection after performing in-app-programming
Definition at line 35 of file bootloader.h.
| typedef void(* Function) (void) |
Function pointer type definition
Definition at line 43 of file bootloader.c.
| bool BootloaderCheckForApplication | ( | void | ) |
This function checks whether a valid application exists in flash.
The check is performed by checking the very first DWORD (4 bytes) of the application firmware. In case of a valid application, this DWORD must represent the initialization location of stack pointer - which must be within the boundaries of RAM.
Definition at line 123 of file bootloader.c.
| void BootloaderJumpToApplication | ( | void | ) |
This function performs the jump to the user application in flash.
The function carries out the following operations:
Definition at line 159 of file bootloader.c.
| void BootloaderJumpToSysMem | ( | void | ) |
This function performs the jump to the microcontroller System Memory (ST built-in bootloader).
The function carries out the following operations:
Definition at line 201 of file bootloader.c.
| bool BootloaderUpdateFirmware | ( | void | ) |
This function performs the complete application update procedure.
The function checks the application size, the application CRC; then carries out the actual firmware update process and finally verifies if the update was successful.
Definition at line 110 of file bootloader.c.
|
static |
Calculate the CRC-32 checksum of the application binary file on the SD card using the hardware CRC peripheral.
| crc | Pointer to store the calculated CRC-32 value. |
Definition at line 451 of file bootloader.c.
|
static |
Validate the integrity of the application binary by comparing a CRC-32 value calculated over the file contents against the reference CRC value read from a separate file on the SD card.
Definition at line 269 of file bootloader.c.
|
static |
Check whether the application binary on the SD card fits into the available flash memory region designated for the application.
Definition at line 243 of file bootloader.c.
|
static |
Read the expected CRC-32 value from a dedicated CRC file on the SD card and convert the hexadecimal string representation to an integer.
| crc | Pointer to store the parsed CRC-32 value. |
Definition at line 493 of file bootloader.c.
|
static |
Erase the application flash region and program it with the contents of the application binary file from the SD card, page by page.
Definition at line 297 of file bootloader.c.
|
static |
Verify the programmed flash contents against the original application binary file on the SD card by performing a word-by-word comparison.
Definition at line 376 of file bootloader.c.
|
extern |
Application area size address defined in the linker file
|
extern |
Application area start address defined in the linker file
|
static |
Read buffer for reading data from a file on the SD card
Definition at line 47 of file bootloader.c.