Skip to content

A bootloader for STM32 microcontrollers using GCC, Make and STM32CubeHAL.

Notifications You must be signed in to change notification settings

mhomran/STM32_Bootloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

A bootloader for STM32F407VG MCU. It's based on STM32CubeHAL.

Bootloader features:

  • Flash, erase for a sector or an image (multiple sectors) and jump to the app.
  • It supports four images with their headers. The images are with diffrerent sizes.
  • CRC32 check for the programming records and for the entire image.
  • It supports UART communication.
  • Flasher python script.
  • The content of the image is independent position code (IPC) while the image header must be at the start of the image.
  • STM32CubeHAL is shared between the bootloader and the images.

Memory design

Bootloader design

Bootloader sequence

Software architecture

PDU design

  • Address: The least significant 16-bit of the address of the location of programming.
  • Type: The action to be performed (erase, flash, reset, etc.)
  • data (optional): the data for the specified action (flashing data, image number, etc.). Its maximum number of bytes is 16 in case of flashing.
  • CRC32: CRC32 computed for the entire PDU.

Tools used

How to build the bootloader

  • You should have GNU Make and GNU Arm Embedded Toolchain
  • cd to the repository directory and run make, you should have the build folder containing the binaries.
  • Flash the image using any STM32 MCU flashers (OpenOCD, STM32Cube programmer, etc.).

How to use the bootloader

  1. Include an image header in your application at the start of the image using linker script (you can use the one in the apps folder).
  2. Fill the image header CRC32 of the entire image which can be calculated from the .hex file using the CRC calculator in apps folder. e.g.:
    python app.py output.hex
    
  3. Use the flasher script to:
    1. Erase the image. e.g.
      python flasher.py COM8 -a1 -i0
      
    2. Flash the image.
      python flasher.py COM8 -f output.hex -a0 -i0
      
    3. Choose the active image.
      python flasher.py COM8 -a5 -i0
      
    4. Reset MCU to let the active image work.
      python flasher.py COM8 -a4
      
    • To know how to use the flasher script run:
      python flasher.py -h
      

Important notes

Looking forward to implementing:

  • CAN communication.
  • Transport layer ISO-TP (ISO 15765-2)
  • Delta file

References

English

Arabic

About

A bootloader for STM32 microcontrollers using GCC, Make and STM32CubeHAL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages