STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers

Macros

#define BOOTLOADER_VERSION_MAJOR   1U
 
#define BOOTLOADER_VERSION_MINOR   1U
 
#define BOOTLOADER_VERSION_PATCH   3U
 

Enumerations

enum  BootloaderCommand {
  BL_CMD_LAUNCH_APPLICATION = 0U ,
  BL_CMD_ENTER_SYSMEM_BOOT ,
  BL_CMD_UPDATE_FIRMWARE
}
 

Functions

static BootloaderCommand WaitForUserCommand (void)
 Wait for a user command by monitoring the button press duration. More...
 
static bool WaitForSingleButtonPress (void)
 Wait for a single button press within a timeout period. More...
 
int main (void)
 The main function. More...
 

Detailed Description

Macro Definition Documentation

◆ BOOTLOADER_VERSION_MAJOR

#define BOOTLOADER_VERSION_MAJOR   1U

Major version

Definition at line 31 of file main.h.

◆ BOOTLOADER_VERSION_MINOR

#define BOOTLOADER_VERSION_MINOR   1U

Minor version

Definition at line 32 of file main.h.

◆ BOOTLOADER_VERSION_PATCH

#define BOOTLOADER_VERSION_PATCH   3U

Patch version

Definition at line 33 of file main.h.

Enumeration Type Documentation

◆ BootloaderCommand

Enum for bootloader command determined by the user actions.

Enumerator
BL_CMD_LAUNCH_APPLICATION 

Launch the user application.

BL_CMD_ENTER_SYSMEM_BOOT 

Enter ST built-in system memory boot.

BL_CMD_UPDATE_FIRMWARE 

Perform firmware update from SD card.

Definition at line 44 of file main.c.

Function Documentation

◆ main()

int main ( void  )

The main function.

Returns
This function shall never return.

Definition at line 80 of file main.c.

◆ WaitForSingleButtonPress()

static bool WaitForSingleButtonPress ( void  )
static

Wait for a single button press within a timeout period.

Toggles LEDs while waiting for up to 5 seconds. Returns as soon as the button is pressed or the timeout expires.

Returns
True if the button was pressed within the timeout; otherwise false.

Definition at line 278 of file main.c.

◆ WaitForUserCommand()

static BootloaderCommand WaitForUserCommand ( void  )
static

Wait for a user command by monitoring the button press duration.

The button press duration determines the bootloader action:

  • Pressed >= 1 second: firmware update.
  • Pressed >= 4 seconds: enter ST system memory boot mode.
  • Pressed >= 9 seconds: do nothing, launch application.
Returns
The BootloaderCommand corresponding to the button press duration.

Definition at line 199 of file main.c.