0% found this document useful (0 votes)
31 views4 pages

Bootloader

This document describes a bootloader system that checks for a condition to enter bootloader mode or continue normal application execution. If the condition is met, it initializes peripherals, receives a firmware update over communication, erases the old firmware, writes the new firmware, and jumps to the application. If not, it continues the application code. The bootloader supports dual application flashing, firmware updates over UART, and uses CRC to validate new firmware integrity.

Uploaded by

pradeep bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Bootloader

This document describes a bootloader system that checks for a condition to enter bootloader mode or continue normal application execution. If the condition is met, it initializes peripherals, receives a firmware update over communication, erases the old firmware, writes the new firmware, and jumps to the application. If not, it continues the application code. The bootloader supports dual application flashing, firmware updates over UART, and uses CRC to validate new firmware integrity.

Uploaded by

pradeep bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#define 

APP_START_ADDRESS 0x08008000 // Start address of the application in flash memory

typedef void (*FunctionPointer)(void);

void jump_to_application(void)
{
FunctionPointer application = (FunctionPointer)APP_START_ADDRESS;

// Disable interrupts
__disable_irq();

// Set the vector table offset to the application start address


SCB->VTOR = (uint32_t)APP_START_ADDRESS;

// Set the stack pointer to the value at the application start address
__set_MSP(*(volatile uint32_t*)APP_START_ADDRESS);

// Jump to the application


application();
}

int main(void)
{
// Check if a button or condition is pressed to trigger the bootloader
if (/* condition to enter bootloader */) {
// Enter bootloader mode

// Perform necessary initialization, such as configuring peripherals, communication interfaces, etc.

// Wait for a firmware image to be received via a communication interface

// Erase the application flash memory area

// Write the received firmware image to the flash memory

// If the firmware image is valid, jump to the application


jump_to_application();
}
// Continue with normal application code if the bootloader condition is not met

// Rest of the application code

while (1) {
// Application-specific code
}
}

In this example, the code checks a specific condition (such as a button press or a flag) to determine
whether to enter the bootloader mode or continue with the normal application execution.

If the condition to enter the bootloader is met, the code performs the necessary initialization, such as
configuring peripherals and communication interfaces. It waits for a firmware image to be received
via a communication interface (e.g., UART, USB, Ethernet).

Once the firmware image is received, the bootloader erases the application flash memory area and
writes the received firmware image to the flash memory. Verification or checksum calculation can be
performed on the firmware image to ensure its integrity.

If the firmware image is valid, the `jump_to_application()` function is called. This function prepares
the microcontroller to execute the application code stored in flash memory. It disables interrupts,
sets the vector table offset to the application start address, and sets the stack pointer to the value
stored at the application start address. Finally, it jumps to the application code using a function
pointer.

If the condition to enter the bootloader is not met, the code continues with the normal application
execution. The rest of the application-specific code can be implemented in the main loop or other
functions, depending on the application's requirements.
🚀 Excited to share my latest project: "Design and Implementation of a Bootloader for Firmware
Update with Dual Application Flashing and CRC Data Integrity Checking" (STM32F1)!

🔧 In this project, I developed a custom bootloader system for updating firmware on the STM32F1
microcontroller using uart via FTDI . It offers dual application flashing capabilities, with a CRC32
calculation ; the bootloader communicate with the host and wait if there is a firmware update
request , if there is a request , bootloader receive the firmware and flash it and then check the
CRC ... , if there is no request bootloader jump directly to old application

💡 Key features of the bootloader:


*Dual Application Flashing: The bootloader supports two independent firmware applications
*Firmware Update: the bootloader allows hassle-free firmware updates over communication interface
: UART
*CRC Data Integrity Checking: To ensure reliable data transmission, the bootloader implements CRC
(Cyclic Redundancy Check) algorithms for validating the integrity of the received firmware image.
*working for a bootloader that parse firstly the application header to extract it's flash base

You might also like