# elecskku/stm32v3.1 architecture

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

- Interactive diagram: https://gitdiagram.com/elecskku/stm32v3.1
- Repository: https://github.com/elecskku/stm32v3.1

## Overview

This repository implements a Windows host tool and STM32 firmware for transferring files to external flash and reading or verifying stored data. The main workflow is host-to-board UART transfer, flash storage, then optional readback and verification; the firmware also converts stored BMP data to grayscale. The excerpts show key protocol and processing functions, but not the full command dispatch or all flash interactions, so uncertain links are omitted.

Main entry points: [`main3.cpp`](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp) (Serial I/O), [`main3.c`](https://github.com/elecskku/stm32v3.1/blob/main/main3.c) (Firmware command loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Windows host"]
  node_cli["CLI and demo<br/>[main3.cpp]"]
  node_serial_io["Serial I/O<br/>[main3.cpp]"]
  node_host_write["File upload<br/>[main3.cpp]"]
  node_host_read["File restore<br/>[main3.cpp]"]
  node_host_verify["Flash verification<br/>[main3.cpp]"]
  node_host_gray["Gray comparison<br/>[main3.cpp]"]
end

subgraph group_firmware["STM32 firmware"]
  node_mcu_main["Firmware command loop<br/>[main3.c]"]
  node_uart_rx["UART frame receive<br/>[main3.c]"]
  node_flash_ops["Flash operations<br/>[main3.c]"]
  node_bmp_gray["BMP grayscale<br/>[main3.c]"]
  node_mcu_verify["Flash CRC verify<br/>[main3.c]"]
end

subgraph group_hardware["Hardware interface"]
  node_uart_link["UART connection"]
  node_flash_chip[("External flash")]
end

node_user(("Operator"))

node_user -->|"runs commands"| node_cli
node_cli -->|"runs upload"| node_host_write
node_cli -->|"runs restore"| node_host_read
node_host_write -->|"writes packets"| node_serial_io
node_host_read -->|"reads response"| node_serial_io
node_host_verify -->|"sends request"| node_serial_io
node_host_gray -.->|"command option"| node_cli
node_serial_io -->|"transfers bytes"| node_uart_link
node_uart_link -.->|"delivers frames"| node_uart_rx
node_mcu_main -->|"arms reception"| node_uart_rx
node_mcu_main -->|"writes data"| node_flash_ops
node_flash_ops -->|"reads and writes"| node_flash_chip
node_mcu_main -->|"converts rows"| node_bmp_gray
node_bmp_gray -->|"reads source rows"| node_flash_ops
node_mcu_main -->|"handles verify"| node_mcu_verify
node_uart_link -.->|"returns responses"| node_serial_io

click node_cli "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_serial_io "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_host_write "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_host_read "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_host_verify "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_host_gray "https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp"
click node_mcu_main "https://github.com/elecskku/stm32v3.1/blob/main/main3.c"
click node_uart_rx "https://github.com/elecskku/stm32v3.1/blob/main/main3.c"
click node_flash_ops "https://github.com/elecskku/stm32v3.1/blob/main/main3.c"
click node_bmp_gray "https://github.com/elecskku/stm32v3.1/blob/main/main3.c"
click node_mcu_verify "https://github.com/elecskku/stm32v3.1/blob/main/main3.c"

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_cli,node_serial_io,node_host_write,node_host_read,node_host_verify,node_host_gray toneBlue
class node_mcu_main,node_uart_rx,node_flash_ops,node_bmp_gray,node_mcu_verify toneAmber
class node_uart_link,node_flash_chip toneMint
class node_user toneIndigo
```

## Components

### Windows host

- [CLI and demo](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`
- [Serial I/O](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`
- [File upload](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`
- [File restore](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`
- [Flash verification](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`
- [Gray comparison](https://github.com/elecskku/stm32v3.1/blob/main/main3.cpp): `main3.cpp`

### STM32 firmware

- [Firmware command loop](https://github.com/elecskku/stm32v3.1/blob/main/main3.c): `main3.c`
- [UART frame receive](https://github.com/elecskku/stm32v3.1/blob/main/main3.c): `main3.c`
- [Flash operations](https://github.com/elecskku/stm32v3.1/blob/main/main3.c): `main3.c`
- [BMP grayscale](https://github.com/elecskku/stm32v3.1/blob/main/main3.c): `main3.c`
- [Flash CRC verify](https://github.com/elecskku/stm32v3.1/blob/main/main3.c): `main3.c`

### Hardware interface

- **UART connection**
- **External flash**

### Other components

- **Operator**

## Connections

- Operator → CLI and demo: runs commands (evidence: `main3.cpp`)
- CLI and demo → File upload: runs upload (evidence: `main3.cpp`)
- CLI and demo → File restore: runs restore (evidence: `main3.cpp`)
- File upload → Serial I/O: writes packets (evidence: `main3.cpp`)
- File restore → Serial I/O: reads response (evidence: `main3.cpp`)
- Flash verification → Serial I/O: sends request (evidence: `main3.cpp`)
- Gray comparison → CLI and demo: command option (evidence: `main3.cpp`)
- Serial I/O → UART connection: transfers bytes (evidence: `main3.cpp`)
- UART connection → UART frame receive: delivers frames
- Firmware command loop → UART frame receive: arms reception (evidence: `main3.c`)
- Firmware command loop → Flash operations: writes data (evidence: `main3.c`)
- Flash operations → External flash: reads and writes (evidence: `main3.c`)
- Firmware command loop → BMP grayscale: converts rows (evidence: `main3.c`)
- BMP grayscale → Flash operations: reads source rows (evidence: `main3.c`)
- Firmware command loop → Flash CRC verify: handles verify (evidence: `main3.c`)
- UART connection → Serial I/O: returns responses
