# alkamotors/am32-bootloader architecture

> Architecture diagram of the GitHub repository alkamotors/am32-bootloader, 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
- Repository: https://github.com/alkamotors/am32-bootloader

## Overview

AM32 Bootloader is embedded firmware for ESCs, with a separate image that can rewrite the bootloader itself. The principal runtime is the bootloader’s command-handling loop; the excerpt shows serial receive/transmit helpers and EEPROM address handling, while the README identifies the product but does not document its protocol. DroneCAN is a distinct integration referenced by the bootloader entry point. The repository also contains MCU-specific support libraries. Source excerpts are partial, so unshown programming and dispatch relationships are omitted rather than inferred.

Main entry points: [`bootloader/main.c`](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/main.c) (Bootloader), [`bootloader/DroneCAN/DroneCAN.c`](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/DroneCAN.c) (DroneCAN adapter), [`Mcu/f031/Src/eeprom.c`](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f031/Src/eeprom.c) (EEPROM support), [`bootloader/DroneCAN/dsdl_generated/dronecan_msgs.h`](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/dsdl_generated/dronecan_msgs.h) (Generated messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bootloader runtime"]
  node_boot["Bootloader<br/>[main.c]"]
  node_eeprom[("EEPROM support<br/>[eeprom.c]")]
end

subgraph group_can["DroneCAN integration"]
  node_drone["DroneCAN adapter<br/>[DroneCAN.c]"]
  node_canard["CAN transport<br/>[canard.c]"]
  node_messages["Generated messages<br/>[dronecan_msgs.h]"]
end

subgraph group_update["Bootloader updater"]
  node_updater["Bootloader updater<br/>[main.c]"]
end

subgraph group_platform["MCU support"]
  node_mcu_f031["STM32F031 support<br/>[stm32f0xx_ll_adc.h]"]
  node_mcu_g071["STM32G071 support<br/>[stm32g0xx_ll_adc.h]"]
  node_mcu_g431["STM32G431 support<br/>[stm32g4xx_ll_adc.h]"]
  node_mcu_a153["MCXA153 support<br/>[MCXA153.h]"]
  node_mcu_e230["GD32E230 support<br/>[gd32e23x.h]"]
  node_mcu_f415["AT32F415 support<br/>[at32f415.h]"]
  node_mcu_f421["AT32F421 support<br/>[at32f421.h]"]
  node_mcu_v203["CH32V203 support<br/>[ch32v20x.h]"]
end

node_client(("ESC client"))

node_client -->|"sends commands"| node_boot
node_boot -->|"includes support"| node_eeprom
node_boot -->|"references integration"| node_drone
node_drone -->|"uses definitions"| node_messages

click node_boot "https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/main.c"
click node_eeprom "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f031/Src/eeprom.c"
click node_drone "https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/DroneCAN.c"
click node_canard "https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/libcanard/canard.c"
click node_messages "https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/dsdl_generated/dronecan_msgs.h"
click node_updater "https://github.com/alkamotors/am32-bootloader/blob/master/bl_update/main.c"
click node_mcu_f031 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f031/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_adc.h"
click node_mcu_g071 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/g071/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h"
click node_mcu_g431 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/g431/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_adc.h"
click node_mcu_a153 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/a153/Drivers/inc/MCXA153.h"
click node_mcu_e230 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/e230/Drivers/CMSIS/Include/gd32e23x.h"
click node_mcu_f415 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f415/Drivers/CMSIS/cm4/device_support/at32f415.h"
click node_mcu_f421 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f421/Drivers/CMSIS/cm4/device_support/at32f421.h"
click node_mcu_v203 "https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/v203/Drivers/Peripheral/inc/ch32v20x.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_boot,node_eeprom,node_client toneBlue
class node_drone,node_canard,node_messages toneAmber
class node_updater toneMint
class node_mcu_f031,node_mcu_g071,node_mcu_g431,node_mcu_a153,node_mcu_e230,node_mcu_f415,node_mcu_f421,node_mcu_v203 toneRose
```

## Components

### Bootloader runtime

- [Bootloader](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/main.c): `bootloader/main.c`
- [EEPROM support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f031/Src/eeprom.c): `Mcu/f031/Src/eeprom.c`

### DroneCAN integration

- [DroneCAN adapter](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/DroneCAN.c): `bootloader/DroneCAN/DroneCAN.c`
- [CAN transport](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/libcanard/canard.c): `bootloader/DroneCAN/libcanard/canard.c`
- [Generated messages](https://github.com/alkamotors/am32-bootloader/blob/master/bootloader/DroneCAN/dsdl_generated/dronecan_msgs.h): `bootloader/DroneCAN/dsdl_generated/dronecan_msgs.h`

### Bootloader updater

- [Bootloader updater](https://github.com/alkamotors/am32-bootloader/blob/master/bl_update/main.c): `bl_update/main.c`

### MCU support

- [STM32F031 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f031/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_adc.h): `Mcu/f031/Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_adc.h`
- [STM32G071 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/g071/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h): `Mcu/g071/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h`
- [STM32G431 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/g431/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_adc.h): `Mcu/g431/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_adc.h`
- [MCXA153 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/a153/Drivers/inc/MCXA153.h): `Mcu/a153/Drivers/inc/MCXA153.h`
- [GD32E230 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/e230/Drivers/CMSIS/Include/gd32e23x.h): `Mcu/e230/Drivers/CMSIS/Include/gd32e23x.h`
- [AT32F415 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f415/Drivers/CMSIS/cm4/device_support/at32f415.h): `Mcu/f415/Drivers/CMSIS/cm4/device_support/at32f415.h`
- [AT32F421 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/f421/Drivers/CMSIS/cm4/device_support/at32f421.h): `Mcu/f421/Drivers/CMSIS/cm4/device_support/at32f421.h`
- [CH32V203 support](https://github.com/alkamotors/am32-bootloader/blob/master/Mcu/v203/Drivers/Peripheral/inc/ch32v20x.h): `Mcu/v203/Drivers/Peripheral/inc/ch32v20x.h`

### Other components

- **ESC client**

## Connections

- ESC client → Bootloader: sends commands (evidence: `bootloader/main.c`)
- Bootloader → EEPROM support: includes support (evidence: `bootloader/main.c`)
- Bootloader → DroneCAN adapter: references integration (evidence: `bootloader/main.c`)
- DroneCAN adapter → Generated messages: uses definitions (evidence: `bootloader/DroneCAN/DroneCAN.c`)
