STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers
|
This file contains the functions of the bootloader. The bootloader implementation uses the official HAL library of ST. More...
#include "bootloader.h"
Go to the source code of this file.
Macros | |
#define | BOOTLOADER_VERSION_MAJOR 1 |
#define | BOOTLOADER_VERSION_MINOR 1 |
#define | BOOTLOADER_VERSION_PATCH 3 |
#define | BOOTLOADER_VERSION_RC 0 |
Typedefs | |
typedef void(* | pFunction) (void) |
Functions | |
uint8_t | Bootloader_Init (void) |
This function initializes bootloader and flash. More... | |
uint8_t | Bootloader_Erase (void) |
This function erases the user application area in flash. More... | |
uint8_t | Bootloader_FlashBegin (void) |
Begin flash programming: this function unlocks the flash and sets the data pointer to the start of application flash area. More... | |
uint8_t | Bootloader_FlashNext (uint64_t data) |
Program 64bit data into flash: this function writes an 8byte (64bit) data chunk into the flash and increments the data pointer. More... | |
uint8_t | Bootloader_FlashEnd (void) |
Finish flash programming: this function finalizes the flash programming by locking the flash. More... | |
uint8_t | Bootloader_GetProtectionStatus (void) |
This function returns the protection status of flash. More... | |
uint8_t | Bootloader_ConfigProtection (uint32_t protection) |
This function configures the wirte protection of flash. More... | |
uint8_t | Bootloader_CheckSize (uint32_t appsize) |
This function checks whether the new application fits into flash. More... | |
uint8_t | Bootloader_VerifyChecksum (void) |
This function verifies the checksum of application located in flash. If USE_CHECKSUM configuration parameter is disabled then the function always returns an error code. More... | |
uint8_t | Bootloader_CheckForApplication (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. More... | |
void | Bootloader_JumpToApplication (void) |
This function performs the jump to the user application in flash. More... | |
void | Bootloader_JumpToSysMem (void) |
This function performs the jump to the MCU System Memory (ST Bootloader). More... | |
uint32_t | Bootloader_GetVersion (void) |
This function returns the version number of the bootloader library. Semantic versioning is used for numbering. More... | |
Variables | |
static uint32_t | flash_ptr = APP_ADDRESS |
This file contains the functions of the bootloader. The bootloader implementation uses the official HAL library of ST.
STM32 Bootloader Source
Definition in file bootloader.c.
#define BOOTLOADER_VERSION_MAJOR 1 |
Major version
Definition at line 20 of file bootloader.c.
#define BOOTLOADER_VERSION_MINOR 1 |
Minor version
Definition at line 21 of file bootloader.c.
#define BOOTLOADER_VERSION_PATCH 3 |
Patch version
Definition at line 22 of file bootloader.c.
#define BOOTLOADER_VERSION_RC 0 |
Release candidate version
Definition at line 23 of file bootloader.c.
typedef void(* pFunction) (void) |
Function pointer definition
Definition at line 26 of file bootloader.c.
uint8_t Bootloader_CheckForApplication | ( | 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.
BL_OK | if first DWORD represents a valid stack pointer location |
BL_NO_APP | first DWORD value is out of RAM boundaries |
Definition at line 395 of file bootloader.c.
uint8_t Bootloader_CheckSize | ( | uint32_t | appsize | ) |
This function checks whether the new application fits into flash.
appsize | size of application |
BL_OK | if application fits into flash |
BL_SIZE_ERROR | if application does not fit into flash |
Definition at line 338 of file bootloader.c.
uint8_t Bootloader_ConfigProtection | ( | uint32_t | protection | ) |
This function configures the wirte protection of flash.
protection | protection type eFlashProtectionTypes |
BL_OK | upon success |
BL_OBP_ERROR | upon failure |
Definition at line 263 of file bootloader.c.
uint8_t Bootloader_Erase | ( | void | ) |
This function erases the user application area in flash.
BL_OK | upon success |
BL_ERR | upon failure |
Definition at line 56 of file bootloader.c.
uint8_t Bootloader_FlashBegin | ( | void | ) |
Begin flash programming: this function unlocks the flash and sets the data pointer to the start of application flash area.
BL_OK | is returned in every case |
Definition at line 100 of file bootloader.c.
uint8_t Bootloader_FlashEnd | ( | void | ) |
Finish flash programming: this function finalizes the flash programming by locking the flash.
BL_OK | is returned in every case |
Definition at line 159 of file bootloader.c.
uint8_t Bootloader_FlashNext | ( | uint64_t | data | ) |
Program 64bit data into flash: this function writes an 8byte (64bit) data chunk into the flash and increments the data pointer.
data | 64bit data chunk to be written into flash |
BL_OK | upon success |
BL_WRITE_ERROR | upon failure |
Definition at line 120 of file bootloader.c.
uint8_t Bootloader_GetProtectionStatus | ( | void | ) |
This function returns the protection status of flash.
Definition at line 171 of file bootloader.c.
uint32_t Bootloader_GetVersion | ( | void | ) |
This function returns the version number of the bootloader library. Semantic versioning is used for numbering.
Definition at line 471 of file bootloader.c.
uint8_t Bootloader_Init | ( | void | ) |
This function initializes bootloader and flash.
BL_OK | is returned in every case |
Definition at line 37 of file bootloader.c.
void Bootloader_JumpToApplication | ( | void | ) |
This function performs the jump to the user application in flash.
The function carries out the following operations:
Definition at line 410 of file bootloader.c.
void Bootloader_JumpToSysMem | ( | void | ) |
This function performs the jump to the MCU System Memory (ST Bootloader).
The function carries out the following operations:
Definition at line 439 of file bootloader.c.
uint8_t Bootloader_VerifyChecksum | ( | void | ) |
This function verifies the checksum of application located in flash. If USE_CHECKSUM configuration parameter is disabled then the function always returns an error code.
BL_OK | if calculated checksum matches the application checksum |
BL_CHKS_ERROR | upon checksum mismatch or when USE_CHECKSUM is disabled |
Definition at line 353 of file bootloader.c.
|
static |
Private variable for tracking flashing progress
Definition at line 30 of file bootloader.c.