# kiko283/mbed-os-fota-bootloader architecture

> Architecture diagram of the GitHub repository kiko283/mbed-os-fota-bootloader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kiko283/mbed-os-fota-bootloader
- Repository: https://github.com/kiko283/mbed-os-fota-bootloader

## Overview

This is a minimal Mbed OS FOTA bootloader. The external actor is the separate main application: it downloads firmware and stages it in SPI flash, then restarts the device. On boot, main.cpp compares staged and current version metadata, copies an available image into MCU flash, records the new version, and starts the application. README documents the staging responsibility and hardware; sampled implementation is limited to main.cpp, so the graph omits the separate application's internal workflow.

Main entry points: [`main.cpp`](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp) (SPI flash)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Bootloader control"]
  node_boot_entry["Boot entry<br/>[main.cpp]"]
  node_update_check["Update check<br/>[main.cpp]"]
  node_flash_update["Flash update<br/>[main.cpp]"]
  node_app_start["Application start<br/>[main.cpp]"]
end

subgraph group_storage["Firmware storage"]
  node_staged_image["Staged firmware<br/>[main.cpp]"]
  node_version_metadata["Version metadata<br/>[main.cpp]"]
end

subgraph group_hardware["Flash hardware"]
  node_spif[("SPI flash<br/>[main.cpp]")]
  node_mcu_flash[("MCU flash<br/>[main.cpp]")]
end

node_main_app(("Main application"))

node_main_app -->|"stages image"| node_spif
node_main_app -->|"writes version"| node_version_metadata
node_boot_entry -->|"initializes"| node_spif
node_boot_entry -->|"calls"| node_update_check
node_boot_entry -->|"calls if needed"| node_flash_update
node_boot_entry -->|"starts"| node_app_start
node_update_check -->|"reads metadata"| node_spif
node_update_check -->|"compares"| node_version_metadata
node_flash_update -->|"reads image"| node_spif
node_spif -->|"stores"| node_staged_image
node_flash_update -->|"erases and writes"| node_mcu_flash
node_flash_update -->|"updates current version"| node_version_metadata
node_app_start -->|"jumps to application"| node_main_app

click node_boot_entry "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_update_check "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_flash_update "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_app_start "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_spif "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_mcu_flash "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_staged_image "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"
click node_version_metadata "https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp"

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_entry,node_update_check,node_flash_update,node_app_start toneBlue
class node_staged_image,node_version_metadata toneAmber
class node_spif,node_mcu_flash toneMint
class node_main_app toneIndigo
```

## Components

### Bootloader control

- [Boot entry](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`
- [Update check](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`
- [Flash update](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`
- [Application start](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`

### Firmware storage

- [Staged firmware](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`
- [Version metadata](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`

### Flash hardware

- [SPI flash](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`
- [MCU flash](https://github.com/kiko283/mbed-os-fota-bootloader/blob/main/main.cpp): `main.cpp`

### Other components

- **Main application**

## Connections

- Main application → SPI flash: stages image
- Main application → Version metadata: writes version
- Boot entry → SPI flash: initializes
- Boot entry → Update check: calls
- Boot entry → Flash update: calls if needed
- Boot entry → Application start: starts
- Update check → SPI flash: reads metadata
- Update check → Version metadata: compares
- Flash update → SPI flash: reads image
- SPI flash → Staged firmware: stores
- Flash update → MCU flash: erases and writes
- Flash update → Version metadata: updates current version
- Application start → Main application: jumps to application
