# faizwildanritonga/spreadtrum_flash architecture

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

- Interactive diagram: https://gitdiagram.com/faizwildanritonga/spreadtrum_flash
- Repository: https://github.com/faizwildanritonga/spreadtrum_flash

## Overview

This is a Spreadtrum firmware dumper: users issue command-line or interactive commands to connect to a device, load and execute download agents, then inspect, back up, modify, or erase device storage. The main command dispatcher is spd_dump.c; common.c contains protocol, device communication, partition, and image/NV routines. The README documents broader partition, security, RPMB, eFuse, and NV workflows than the sampled command excerpts show. Those less-visible links are omitted or marked unverified rather than inferred from names alone.

Main entry points: [`spd_dump.c`](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c) (Command dispatcher), [`common.c`](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c) (BSL protocol), [`Wrapper.cpp`](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/Wrapper.cpp) (Transport wrapper), [`spd_cmd.h`](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_cmd.h) (Command definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Command workflows"]
  node_dispatcher["Command dispatcher<br/>[spd_dump.c]"]
  node_boot["Boot-stage control<br/>[spd_dump.c]"]
  node_firmware["Firmware transfer<br/>[spd_dump.c]"]
  node_storage_commands["Storage commands<br/>[spd_dump.c]"]
  node_security_commands["Security and NV commands<br/>[spd_dump.c]"]
end

subgraph group_device["Device and protocol"]
  node_protocol["BSL protocol<br/>[common.c]"]
  node_device_io["Device I/O<br/>[common.c]"]
  node_command_defs["Command definitions<br/>[spd_cmd.h]"]
end

subgraph group_storage["Storage and images"]
  node_partition["Partition operations<br/>[common.c]"]
  node_image_nv["Image and NV processing<br/>[common.c]"]
  node_local_files[("Local files")]
end

subgraph group_platform["Platform transport"]
  node_usb_driver["USB or SPRD driver"]
  node_windows_channel["Windows COM channel<br/>[BMPlatform.cpp]"]
  node_c_api["Transport wrapper<br/>[Wrapper.cpp]"]
end

node_user(("CLI user"))

node_user -->|"issues commands"| node_dispatcher
node_dispatcher -->|"dispatches"| node_boot
node_dispatcher -->|"dispatches"| node_firmware
node_dispatcher -->|"dispatches"| node_storage_commands
node_dispatcher -->|"dispatches"| node_security_commands
node_boot -->|"sends commands"| node_protocol
node_firmware -.->|"sends data"| node_protocol
node_storage_commands -.->|"operates on"| node_partition
node_security_commands -.->|"uses routines"| node_image_nv
node_protocol -->|"transfers packets"| node_device_io
node_protocol -.->|"uses constants"| node_command_defs
node_partition -.->|"reads and writes"| node_device_io
node_partition -.->|"saves or loads"| node_local_files
node_image_nv -.->|"processes images"| node_local_files
node_device_io -.->|"connects through"| node_usb_driver
node_device_io -.->|"uses on Windows"| node_c_api
node_c_api -->|"delegates to"| node_windows_channel

click node_dispatcher "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c"
click node_boot "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c"
click node_firmware "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c"
click node_storage_commands "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c"
click node_security_commands "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c"
click node_protocol "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c"
click node_device_io "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c"
click node_command_defs "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_cmd.h"
click node_partition "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c"
click node_image_nv "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c"
click node_windows_channel "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/BMPlatform.cpp"
click node_c_api "https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/Wrapper.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_dispatcher,node_boot,node_firmware,node_storage_commands,node_security_commands,node_user toneBlue
class node_protocol,node_device_io,node_command_defs toneAmber
class node_partition,node_image_nv,node_local_files toneMint
class node_usb_driver,node_windows_channel,node_c_api toneRose
```

## Components

### Command workflows

- [Command dispatcher](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c): `spd_dump.c`
- [Boot-stage control](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c): `spd_dump.c`
- [Firmware transfer](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c): `spd_dump.c`
- [Storage commands](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c): `spd_dump.c`
- [Security and NV commands](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_dump.c): `spd_dump.c`

### Device and protocol

- [BSL protocol](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c): `common.c`
- [Device I/O](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c): `common.c`
- [Command definitions](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/spd_cmd.h): `spd_cmd.h`

### Storage and images

- [Partition operations](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c): `common.c`
- [Image and NV processing](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/common.c): `common.c`
- **Local files**

### Platform transport

- **USB or SPRD driver**
- [Windows COM channel](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/BMPlatform.cpp): `BMPlatform.cpp`
- [Transport wrapper](https://github.com/faizwildanritonga/spreadtrum_flash/blob/main/Wrapper.cpp): `Wrapper.cpp`

### Other components

- **CLI user**

## Connections

- CLI user → Command dispatcher: issues commands
- Command dispatcher → Boot-stage control: dispatches (evidence: `spd_dump.c`)
- Command dispatcher → Firmware transfer: dispatches (evidence: `spd_dump.c`)
- Command dispatcher → Storage commands: dispatches (evidence: `spd_dump.c`)
- Command dispatcher → Security and NV commands: dispatches (evidence: `spd_dump.c`)
- Boot-stage control → BSL protocol: sends commands (evidence: `spd_dump.c`)
- Firmware transfer → BSL protocol: sends data
- Storage commands → Partition operations: operates on
- Security and NV commands → Image and NV processing: uses routines
- BSL protocol → Device I/O: transfers packets (evidence: `common.c`)
- BSL protocol → Command definitions: uses constants
- Partition operations → Device I/O: reads and writes (evidence: `common.c`)
- Partition operations → Local files: saves or loads
- Image and NV processing → Local files: processes images
- Device I/O → USB or SPRD driver: connects through
- Device I/O → Transport wrapper: uses on Windows
- Transport wrapper → Windows COM channel: delegates to (evidence: `Wrapper.cpp`)
