# elecskku/stm32 architecture

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

## Overview

This repository demonstrates reliable BMP transfer between a PC and an STM32, with a W25Q32 SPI flash as persistent storage. The main workflow is to prepare a BMP, send it in CRC-protected chunks, store and verify it on the board, then read it back and compare the restored file. The README also documents ID, erase, verify, and visual-comparison capabilities. The firmware implementation files are absent from the tree: the firmware node is represented by its available API header, so its internal protocol behavior is based on README documentation.

Main entry points: [`PC/flash_tool.py`](https://github.com/elecskku/stm32/blob/main/PC/flash_tool.py) (Python Transfer Tool), [`Inc/app.h`](https://github.com/elecskku/stm32/blob/main/Inc/app.h) (UART App API), [`main_clean.cpp`](https://github.com/elecskku/stm32/blob/main/main_clean.cpp) (Windows Serial Client), [`Inc/w25q32.h`](https://github.com/elecskku/stm32/blob/main/Inc/w25q32.h) (W25Q32 Driver API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pc["PC Tools"]
  node_python["Python Transfer Tool<br/>[flash_tool.py]"]
  node_cpp["Windows Serial Client<br/>[main_clean.cpp]"]
end

subgraph group_mcu["STM32 Firmware"]
  node_app["UART App API<br/>[app.h]"]
  node_driver["W25Q32 Driver API<br/>[w25q32.h]"]
end

subgraph group_storage["Flash Storage"]
  node_flash[("W25Q32 Flash")]
end

node_user(("Operator"))
node_sourcefile["Input BMP"]
node_restored["Restored BMP"]
node_uart["UART Link"]
node_spi["SPI Link"]

node_user -->|"runs commands"| node_python
node_user -->|"runs client"| node_cpp
node_sourcefile -->|"supplies BMP"| node_python
node_python -->|"sends protocol"| node_uart
node_cpp -->|"sends protocol"| node_uart
node_uart -->|"carries commands"| node_app
node_app -->|"uses flash operations"| node_driver
node_driver -->|"controls flash"| node_spi
node_spi -->|"reads and writes"| node_flash
node_app -->|"returns data and status"| node_uart
node_python -->|"saves readback"| node_restored
node_user -->|"requests ID, erase, verify"| node_python
node_python -->|"generates or converts BMP"| node_sourcefile
node_python -->|"compares images"| node_restored

click node_python "https://github.com/elecskku/stm32/blob/main/PC/flash_tool.py"
click node_cpp "https://github.com/elecskku/stm32/blob/main/main_clean.cpp"
click node_app "https://github.com/elecskku/stm32/blob/main/Inc/app.h"
click node_driver "https://github.com/elecskku/stm32/blob/main/Inc/w25q32.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_python,node_cpp toneBlue
class node_app,node_driver toneAmber
class node_flash toneMint
class node_user,node_sourcefile,node_restored,node_uart,node_spi toneIndigo
```

## Components

### PC Tools

- [Python Transfer Tool](https://github.com/elecskku/stm32/blob/main/PC/flash_tool.py): `PC/flash_tool.py`
- [Windows Serial Client](https://github.com/elecskku/stm32/blob/main/main_clean.cpp): `main_clean.cpp`

### STM32 Firmware

- [UART App API](https://github.com/elecskku/stm32/blob/main/Inc/app.h): `Inc/app.h`
- [W25Q32 Driver API](https://github.com/elecskku/stm32/blob/main/Inc/w25q32.h): `Inc/w25q32.h`

### Flash Storage

- **W25Q32 Flash**

### Other components

- **Operator**
- **Input BMP**
- **Restored BMP**
- **UART Link**
- **SPI Link**

## Connections

- Operator → Python Transfer Tool: runs commands (evidence: `PC/flash_tool.py`)
- Operator → Windows Serial Client: runs client (evidence: `main_clean.cpp`)
- Input BMP → Python Transfer Tool: supplies BMP (evidence: `PC/flash_tool.py`)
- Python Transfer Tool → UART Link: sends protocol (evidence: `README.md`)
- Windows Serial Client → UART Link: sends protocol (evidence: `main_clean.cpp`)
- UART Link → UART App API: carries commands (evidence: `README.md`)
- UART App API → W25Q32 Driver API: uses flash operations (evidence: `README.md`)
- W25Q32 Driver API → SPI Link: controls flash (evidence: `Inc/w25q32.h`)
- SPI Link → W25Q32 Flash: reads and writes (evidence: `README.md`)
- UART App API → UART Link: returns data and status (evidence: `README.md`)
- Python Transfer Tool → Restored BMP: saves readback (evidence: `PC/flash_tool.py`)
- Operator → Python Transfer Tool: requests ID, erase, verify (evidence: `PC/flash_tool.py`)
- Python Transfer Tool → Input BMP: generates or converts BMP (evidence: `PC/flash_tool.py`)
- Python Transfer Tool → Restored BMP: compares images (evidence: `PC/flash_tool.py`)
