# alkamotors/am32_bootloader_f051 architecture

> Architecture diagram of the GitHub repository alkamotors/am32_bootloader_f051, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alkamotors/am32_bootloader_f051
- Repository: https://github.com/alkamotors/am32_bootloader_f051

## Overview

This repository implements an STM32F0 serial bootloader. Its main firmware initializes the MCU, receives and decodes commands, checks CRCs, and serves acknowledgements or flash data; flash helpers provide the read/write operations, while a jump routine can transfer control to the application. The excerpts show command decoding, timer use, and flash-read calls, but omit much of the serial and flash implementation, so those links are limited to relationships evidenced by the index or excerpts.

Main entry points: [`Core/Src/main.c`](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/main.c) (Bootloader control), [`Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f051x8.h`](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f051x8.h) (STM32F0 device layer), [`Core/Src/system_stm32f0xx.c`](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/system_stm32f0xx.c) (System setup), [`Core/Src/bootloader.c`](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/bootloader.c) (Flash operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Bootloader firmware"]
  node_main["Bootloader control<br/>[main.c]"]
  node_flash_ops["Flash operations<br/>[bootloader.c]"]
  node_interrupts["Interrupt handlers<br/>[stm32f0xx_it.c]"]
end

subgraph group_hardware["MCU support"]
  node_system["System setup<br/>[system_stm32f0xx.c]"]
  node_device["STM32F0 device layer<br/>[stm32f051x8.h]"]
  node_compiler["CMSIS compiler layer<br/>[cmsis_compiler.h]"]
end

subgraph group_drivers["Peripheral drivers"]
  node_hal["HAL services<br/>[stm32f0xx_hal.c]"]
  node_timer["Timer driver"]
  node_ll_timer["Low-level timer<br/>[stm32f0xx_ll_tim.h]"]
  node_ll_dma["Low-level DMA<br/>[stm32f0xx_ll_dma.h]"]
  node_ll_rcc["Low-level clocks<br/>[stm32f0xx_ll_rcc.h]"]
end

node_host(("Serial host"))

node_host -.->|"sends commands"| node_main
node_main -->|"reads flash"| node_flash_ops
node_main -.->|"uses timer"| node_timer
node_main -->|"configures timer"| node_ll_timer
node_main -->|"includes support"| node_ll_dma
node_main -->|"configures clocks"| node_ll_rcc
node_system -->|"uses device definitions"| node_device
node_device -.->|"uses compiler layer"| node_compiler

click node_main "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/main.c"
click node_flash_ops "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/bootloader.c"
click node_interrupts "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/stm32f0xx_it.c"
click node_system "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/system_stm32f0xx.c"
click node_device "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f051x8.h"
click node_hal "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c"
click node_timer "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c"
click node_ll_timer "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_tim.h"
click node_ll_dma "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_dma.h"
click node_ll_rcc "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_rcc.h"
click node_compiler "https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/CMSIS/Include/cmsis_compiler.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_flash_ops,node_interrupts toneBlue
class node_system,node_device,node_compiler toneAmber
class node_hal,node_timer,node_ll_timer,node_ll_dma,node_ll_rcc toneMint
class node_host toneIndigo
```

## Components

### Bootloader firmware

- [Bootloader control](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Flash operations](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/bootloader.c): `Core/Src/bootloader.c`
- [Interrupt handlers](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/stm32f0xx_it.c): `Core/Src/stm32f0xx_it.c`

### MCU support

- [System setup](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Core/Src/system_stm32f0xx.c): `Core/Src/system_stm32f0xx.c`
- [STM32F0 device layer](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f051x8.h): `Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f051x8.h`
- [CMSIS compiler layer](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/CMSIS/Include/cmsis_compiler.h): `Drivers/CMSIS/Include/cmsis_compiler.h`

### Peripheral drivers

- [HAL services](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c): `Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c`
- [Timer driver](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c): `Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c`
- [Low-level timer](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_tim.h): `Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_tim.h`
- [Low-level DMA](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_dma.h): `Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_dma.h`
- [Low-level clocks](https://github.com/alkamotors/am32_bootloader_f051/blob/main/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_rcc.h): `Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_rcc.h`

### Other components

- **Serial host**

## Connections

- Serial host → Bootloader control: sends commands
- Bootloader control → Flash operations: reads flash (evidence: `Core/Src/main.c`)
- Bootloader control → Timer driver: uses timer
- Bootloader control → Low-level timer: configures timer
- Bootloader control → Low-level DMA: includes support
- Bootloader control → Low-level clocks: configures clocks
- System setup → STM32F0 device layer: uses device definitions (evidence: `Core/Src/system_stm32f0xx.c`)
- STM32F0 device layer → CMSIS compiler layer: uses compiler layer
