STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers
bootloader.c File Reference

This file contains the bootloader implementation including firmware verification, flash programming, checksum validation, and application launch functions. More...

#include "bootloader.h"
#include "board.h"
#include "crc.h"
#include "ff.h"
#include "flash.h"
#include "led.h"
#include "log.h"
#include "mcu_hal.h"
#include "sd_diskio.h"
#include "sd_fatfs.h"
#include "sdmmc.h"
#include "systick.h"
#include <errno.h>
#include <stdlib.h>

Go to the source code of this file.

Typedefs

typedef void(* Function) (void)
 

Functions

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...
 
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...
 

Variables

static uint8_t readBuffer [FLASH_PAGE_SIZE] = {0}
 

Detailed Description

This file contains the bootloader implementation including firmware verification, flash programming, checksum validation, and application launch functions.

STM32 Bootloader

Author
Akos Pasztor

Definition in file bootloader.c.