Skip to content

MatveyMelnikov/Bootloader

Repository files navigation

Bootloader

Description

A bootloader that allows you to load a user program from a specified address. It supports a number of commands, which, in particular, provide the ability to load a user program via the UART interface.

Launch

  • make - building a production version of the code for target;
  • make -f MakefileTest.mk - building a test version for development system.

Structure

Since the bootloader is inextricably linked to the hardware, its functionality was separated. The most important part, responsible for loading the user application (start_application_code function) is located in the main. A separate bootloader_cmd module contains the code responsible for processing the command (this operating mode is enabled if pin PB12 pin is connected to power when the microcontroller is started). Tests using the Unity library are implemented here.

Commands

  1. Help - lists all available bootloader commands;
  2. Get id - displays microcontroller ID;
  3. Get bootloader version - displays the current version of the bootloader (current - 0.1);
  4. Write to flash - Starts cyclic writing to flash memory (The first page into which data can be written is the 10th). The cycle can be described as follows (from the STM32 side): send ACK; read address / end sequence (32 bit); read data (16 bits); program flash; send ACK. If any of the transmissions is late or an error occurs, the cycle is interrupted. Wherein: ACK = 0x55, NACK = 0xAA, end sequence = 0xCC33;
  5. Erase flash - clears specified pages. Before writing to flash memory, it must be cleared. How the erasing process occurs (from the STM32 side): send ACK; first erase page address (32 bit); num of pages (8 bits); erase flash; send ACK;
  6. Read - displays the contents of a flash memory page.

Running user code is only allowed from the 'app start address' (APP_START_ADDRESS). To load it you need to change the addresses in the linker script:

...
/* Specify the memory areas */
MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 20K
FLASH (rx)      : ORIGIN = 0x8002800, LENGTH = 64K - 10K
}
...

sheme_bootloader

License

Licensed via CC BY-NC-ND 4.0

About

For STM32

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages