STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers
bootloader.h
Go to the documentation of this file.
1 
16 #ifndef BOOTLOADER_H
17 #define BOOTLOADER_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
30 /* Includes ------------------------------------------------------------------*/
31 #include <stdbool.h>
32 #include <stdint.h>
33 
35 #define USE_WRITE_PROTECTION 0
36 
43 #define CLEAR_RESET_FLAGS 1
44 
46 #define APP_FILE_NAME "app-demo.bin"
47 
49 #define CRC_FILE_NAME "app-demo.crc"
50 
51 /* External variables --------------------------------------------------------*/
53 extern const uint32_t LINKER_APP_AREA_ORIGIN;
54 
56 extern const uint32_t LINKER_APP_AREA_LENGTH;
57 
58 /* Defines -------------------------------------------------------------------*/
60 // Message: A conversion should not be performed between a pointer to object
61 // and an integer type [misra-c2012-11.4]
62 // Reason: The address of the application area in the microcontroller flash
63 // memory is provided by the linker in a form of a pointer. This
64 // physical address value needs to be converted into an integer.
65 // Risk: Conversion of a pointer to object into an integer may produce a
66 // value that cannot be represented in the chosen integer type
67 // resulting in undefined behavior.
68 // Prevention: Code reviews.
69 // cppcheck-suppress-macro [misra-c2012-11.4]
70 #define APP_ADDRESS ((uint32_t)&LINKER_APP_AREA_ORIGIN)
71 
73 // Message: A conversion should not be performed between a pointer to object
74 // and an integer type [misra-c2012-11.4]
75 // Reason: The size of the application area in the microcontroller flash
76 // memory is provided by the linker in a form of a pointer. This
77 // physical address value needs to be converted into an integer.
78 // Risk: Conversion of a pointer to object into an integer may produce a
79 // value that cannot be represented in the chosen integer type
80 // resulting in undefined behavior.
81 // Prevention: Code reviews.
82 // cppcheck-suppress-macro [misra-c2012-11.4]
83 #define APP_SIZE ((uint32_t)&LINKER_APP_AREA_LENGTH)
84 
85 /* Functions -----------------------------------------------------------------*/
95 bool BootloaderUpdateFirmware(void);
96 
109 
118 void BootloaderJumpToApplication(void);
119 
128 void BootloaderJumpToSysMem(void);
129 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif
bool BootloaderUpdateFirmware(void)
This function performs the complete application update procedure.
Definition: bootloader.c:110
bool BootloaderCheckForApplication(void)
This function checks whether a valid application exists in flash.
Definition: bootloader.c:123
const uint32_t LINKER_APP_AREA_ORIGIN
const uint32_t LINKER_APP_AREA_LENGTH
void BootloaderJumpToApplication(void)
This function performs the jump to the user application in flash.
Definition: bootloader.c:159
void BootloaderJumpToSysMem(void)
This function performs the jump to the microcontroller System Memory (ST built-in bootloader).
Definition: bootloader.c:201