# armink/sfud architecture

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

- Interactive diagram: https://gitdiagram.com/armink/sfud
- Repository: https://github.com/armink/sfud

## Overview

SFUD is a portable C library for detecting and operating multiple serial SPI/QSPI flash devices. The principal workflow initializes a configured flash device, identifies its capabilities from SFDP or a fallback parameter table, then exposes read, erase, write, status, and addressing operations through a platform-supplied bus interface. The graph follows documented and excerpted relationships; port-specific wiring and some operation internals are not fully shown, so those links are omitted rather than inferred.

Main entry points: [`sfud/src/sfud.c`](https://github.com/armink/sfud/blob/master/sfud/src/sfud.c) (Device Core), [`sfud/inc/sfud.h`](https://github.com/armink/sfud/blob/master/sfud/inc/sfud.h) (SFUD API), [`sfud/src/sfud_sfdp.c`](https://github.com/armink/sfud/blob/master/sfud/src/sfud_sfdp.c) (SFDP Parser), [`sfud/port/sfud_port.c`](https://github.com/armink/sfud/blob/master/sfud/port/sfud_port.c) (SPI/QSPI Port)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api["SFUD API<br/>[sfud.h]"]
  node_types["Device Model<br/>[sfud_def.h]"]
end

subgraph group_detect["Device Detection"]
  node_config["Device Configuration<br/>[sfud_cfg.h]"]
  node_sfdp["SFDP Parser<br/>[sfud_sfdp.c]"]
  node_chiptable["Flash Parameter Tables<br/>[sfud_flash_def.h]"]
end

subgraph group_operations["Flash Operations"]
  node_device["Device Core<br/>[sfud.c]"]
end

subgraph group_platform["Platform Interface"]
  node_port["SPI/QSPI Port<br/>[sfud_port.c]"]
end

node_user(("Library User"))
node_flash[("Serial Flash")]

node_user -->|"calls"| node_api
node_api -->|"exposes"| node_device
node_api -->|"includes"| node_types
node_device -.->|"uses device table"| node_config
node_device -->|"reads parameters"| node_sfdp
node_device -->|"falls back to"| node_chiptable
node_sfdp -->|"reads SFDP"| node_flash
node_device -.->|"uses bus callbacks"| node_port
node_port -.->|"communicates"| node_flash
node_device -.->|"reads, erases, writes"| node_flash

click node_api "https://github.com/armink/sfud/blob/master/sfud/inc/sfud.h"
click node_device "https://github.com/armink/sfud/blob/master/sfud/src/sfud.c"
click node_types "https://github.com/armink/sfud/blob/master/sfud/inc/sfud_def.h"
click node_config "https://github.com/armink/sfud/blob/master/sfud/inc/sfud_cfg.h"
click node_sfdp "https://github.com/armink/sfud/blob/master/sfud/src/sfud_sfdp.c"
click node_chiptable "https://github.com/armink/sfud/blob/master/sfud/inc/sfud_flash_def.h"
click node_port "https://github.com/armink/sfud/blob/master/sfud/port/sfud_port.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_api,node_types,node_user toneBlue
class node_config,node_sfdp,node_chiptable,node_flash toneAmber
class node_device toneMint
class node_port toneRose
```

## Components

### Public API

- [SFUD API](https://github.com/armink/sfud/blob/master/sfud/inc/sfud.h): `sfud/inc/sfud.h`
- [Device Model](https://github.com/armink/sfud/blob/master/sfud/inc/sfud_def.h): `sfud/inc/sfud_def.h`

### Device Detection

- [Device Configuration](https://github.com/armink/sfud/blob/master/sfud/inc/sfud_cfg.h): `sfud/inc/sfud_cfg.h`
- [SFDP Parser](https://github.com/armink/sfud/blob/master/sfud/src/sfud_sfdp.c): `sfud/src/sfud_sfdp.c`
- [Flash Parameter Tables](https://github.com/armink/sfud/blob/master/sfud/inc/sfud_flash_def.h): `sfud/inc/sfud_flash_def.h`

### Flash Operations

- [Device Core](https://github.com/armink/sfud/blob/master/sfud/src/sfud.c): `sfud/src/sfud.c`

### Platform Interface

- [SPI/QSPI Port](https://github.com/armink/sfud/blob/master/sfud/port/sfud_port.c): `sfud/port/sfud_port.c`

### Other components

- **Library User**
- **Serial Flash**

## Connections

- Library User → SFUD API: calls (evidence: `sfud/inc/sfud.h`)
- SFUD API → Device Core: exposes (evidence: `sfud/inc/sfud.h`)
- SFUD API → Device Model: includes (evidence: `sfud/inc/sfud.h`)
- Device Core → Device Configuration: uses device table
- Device Core → SFDP Parser: reads parameters (evidence: `sfud/src/sfud.c`)
- Device Core → Flash Parameter Tables: falls back to (evidence: `sfud/src/sfud.c`)
- SFDP Parser → Serial Flash: reads SFDP (evidence: `sfud/src/sfud_sfdp.c`)
- Device Core → SPI/QSPI Port: uses bus callbacks
- SPI/QSPI Port → Serial Flash: communicates
- Device Core → Serial Flash: reads, erases, writes
