# adamberlinger/stm32f103_bluepill_dfu architecture

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

- Interactive diagram: https://gitdiagram.com/adamberlinger/stm32f103_bluepill_dfu
- Repository: https://github.com/adamberlinger/stm32f103_bluepill_dfu

## Overview

This is a minimalist STM32F103 USB DFU bootloader. After reset, board boot-pin selection activates the bootloader; it initializes the MCU and USB device, handles DFU requests from a host, and erases or programs application flash. The graph includes the documented reset and memory-layout behavior, plus USB descriptors, board support, timing, and interrupt handling. Several implementation files were not excerpted, so uncertain startup and interrupt wiring is omitted rather than inferred.

Main entry points: [`stm32x0_usb_dfu/usb_core.c`](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_core.c) (USB protocol core), [`src/main.c`](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/main.c) (Bootloader runtime), [`stm32x0_usb_dfu/usb_dfu.c`](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_dfu.c) (DFU request handling), [`src/stm32_common.h`](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/stm32_common.h) (STM32 platform definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and MCU"]
  node_reset_check["Reset activation check<br/>[initc.c]"]
  node_runtime["Bootloader runtime<br/>[main.c]"]
  node_device_regs["STM32F1 registers<br/>[stm32f1xx.h]"]
  node_interrupts["Interrupt handlers"]
end

subgraph group_usb["USB device"]
  node_usb_core["USB protocol core<br/>[usb_core.c]"]
  node_usb_desc["USB descriptors<br/>[usb_desc.c]"]
  node_usb_bsp["USB board support<br/>[usb_bsp.c]"]
end

subgraph group_dfu["DFU and flash"]
  node_dfu_protocol["DFU request handling<br/>[usb_dfu.c]"]
  node_flash_ops[("Application flash operations<br/>[usb_dfu.c]")]
end

subgraph group_support["Platform support"]
  node_systick["Millisecond timing<br/>[systick.c]"]
  node_usb_config["USB configuration<br/>[usb_conf.h]"]
  node_common["STM32 platform definitions<br/>[stm32_common.h]"]
end

node_boot_pins(("Boot pin jumpers"))
node_host(("DFU host tools"))

node_boot_pins -->|"selects boot"| node_reset_check
node_reset_check -.->|"activates"| node_runtime
node_runtime -->|"initializes"| node_usb_core
node_runtime -->|"runs loop"| node_dfu_protocol
node_runtime -->|"starts ticks"| node_systick
node_runtime -->|"configures MCU"| node_device_regs
node_usb_core -->|"dispatches requests"| node_dfu_protocol
node_usb_core -->|"uses descriptors"| node_usb_desc
node_usb_core -->|"uses board support"| node_usb_bsp
node_usb_core -->|"uses settings"| node_usb_config
node_usb_bsp -->|"uses settings"| node_usb_config
node_dfu_protocol -->|"sends responses"| node_usb_core
node_dfu_protocol -->|"erases and writes"| node_flash_ops
node_host -->|"exchanges DFU"| node_usb_core
node_common -->|"includes definitions"| node_device_regs
node_common -->|"includes timing API"| node_systick

click node_reset_check "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/initc.c"
click node_runtime "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/main.c"
click node_device_regs "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/lib/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h"
click node_interrupts "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/stm32f1_interrupts.c"
click node_usb_core "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_core.c"
click node_usb_desc "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_desc.c"
click node_usb_bsp "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_bsp.c"
click node_dfu_protocol "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_dfu.c"
click node_flash_ops "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_dfu.c"
click node_systick "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/systick.c"
click node_usb_config "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_conf.h"
click node_common "https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/stm32_common.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_reset_check,node_runtime,node_device_regs,node_interrupts toneBlue
class node_usb_core,node_usb_desc,node_usb_bsp toneAmber
class node_dfu_protocol,node_flash_ops toneMint
class node_systick,node_usb_config,node_common toneRose
class node_boot_pins,node_host toneIndigo
```

## Components

### Startup and MCU

- [Reset activation check](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/initc.c): `src/initc.c`
- [Bootloader runtime](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/main.c): `src/main.c`
- [STM32F1 registers](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/lib/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h): `lib/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h`
- [Interrupt handlers](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/stm32f1_interrupts.c): `src/stm32f1_interrupts.c`

### USB device

- [USB protocol core](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_core.c): `stm32x0_usb_dfu/usb_core.c`
- [USB descriptors](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_desc.c): `stm32x0_usb_dfu/usb_desc.c`
- [USB board support](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_bsp.c): `stm32x0_usb_dfu/usb_bsp.c`

### DFU and flash

- [DFU request handling](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_dfu.c): `stm32x0_usb_dfu/usb_dfu.c`
- [Application flash operations](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_dfu.c): `stm32x0_usb_dfu/usb_dfu.c`

### Platform support

- [Millisecond timing](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/systick.c): `src/systick.c`
- [USB configuration](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/stm32x0_usb_dfu/usb_conf.h): `stm32x0_usb_dfu/usb_conf.h`
- [STM32 platform definitions](https://github.com/adamberlinger/stm32f103_bluepill_dfu/blob/main/src/stm32_common.h): `src/stm32_common.h`

### Other components

- **Boot pin jumpers**
- **DFU host tools**

## Connections

- Boot pin jumpers → Reset activation check: selects boot
- Reset activation check → Bootloader runtime: activates
- Bootloader runtime → USB protocol core: initializes (evidence: `src/main.c`)
- Bootloader runtime → DFU request handling: runs loop (evidence: `src/main.c`)
- Bootloader runtime → Millisecond timing: starts ticks (evidence: `src/main.c`)
- Bootloader runtime → STM32F1 registers: configures MCU (evidence: `src/main.c`)
- USB protocol core → DFU request handling: dispatches requests (evidence: `stm32x0_usb_dfu/usb_core.c`)
- USB protocol core → USB descriptors: uses descriptors (evidence: `stm32x0_usb_dfu/usb_core.c`)
- USB protocol core → USB board support: uses board support (evidence: `stm32x0_usb_dfu/usb_core.c`)
- USB protocol core → USB configuration: uses settings (evidence: `stm32x0_usb_dfu/usb_core.c`)
- USB board support → USB configuration: uses settings
- DFU request handling → USB protocol core: sends responses (evidence: `stm32x0_usb_dfu/usb_dfu.c`)
- DFU request handling → Application flash operations: erases and writes (evidence: `stm32x0_usb_dfu/usb_dfu.c`)
- DFU host tools → USB protocol core: exchanges DFU
- STM32 platform definitions → STM32F1 registers: includes definitions (evidence: `src/stm32_common.h`)
- STM32 platform definitions → Millisecond timing: includes timing API (evidence: `src/stm32_common.h`)
