# shomykohai/penumbra architecture

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

- Interactive diagram: https://gitdiagram.com/shomykohai/penumbra
- Repository: https://github.com/shomykohai/penumbra

## Overview

Penumbra is a Rust crate and Antumbra app for interacting with MediaTek devices. Users invoke device operations through the CLI or TUI; the core library provides device, transport, download-protocol, storage, and exploit capabilities. The README documents flashing, readback, erase, scatter flashing, vulnerable-device unlocking/relocking, RPMB, and arbitrary memory access. Some implementation relationships are unverified because the relevant source was not excerpted; those links are dashed where useful.

Main entry points: [`core/src/device.rs`](https://github.com/shomykohai/penumbra/blob/main/core/src/device.rs) (Device API), [`core/src/da/protocol.rs`](https://github.com/shomykohai/penumbra/blob/main/core/src/da/protocol.rs) (Download protocol), [`app/src/cli/commands`](https://github.com/shomykohai/penumbra/tree/main/app/src/cli/commands) (CLI commands), [`app/src/app.rs`](https://github.com/shomykohai/penumbra/blob/main/app/src/app.rs) (TUI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI commands"]
  node_tui["TUI app<br/>[app.rs]"]
  node_device_pages["Device page"]
end

subgraph group_device_core["Device core"]
  node_device["Device API<br/>[device.rs]"]
  node_device_info["Device info<br/>[devinfo.rs]"]
  node_transport["Port transport<br/>[mod.rs]"]
  node_usb_backends["USB backends"]
end

subgraph group_protocols["Download protocols"]
  node_preloader["Preloader protocol<br/>[protocol.rs]"]
  node_da_protocol["Download protocol<br/>[protocol.rs]"]
  node_xflash["V5 XFlash<br/>[protocol.rs]"]
  node_xml["V6 XML<br/>[protocol.rs]"]
end

subgraph group_operations["Device operations"]
  node_flash_ops["Flash and readback"]
  node_scatter["Scatter flashing<br/>[scatter.rs]"]
  node_storage[("Storage and partitions")]
  node_rpmb["RPMB operations<br/>[rpmb.rs]"]
  node_memory_ops["Memory access"]
end

subgraph group_security["Security"]
  node_unlock["Bootloader unlock"]
  node_exploits["Device exploits<br/>[mod.rs]"]
  node_auth["Authentication"]
end

node_user(("Operator"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses interface"| node_tui
node_tui -->|"switches pages"| node_device_pages
node_cli -.->|"executes operations"| node_device
node_device_pages -.->|"dispatches actions"| node_device
node_device -.->|"uses transport"| node_transport
node_transport -->|"selects backend"| node_usb_backends
node_device -.->|"uses protocol"| node_preloader
node_device -.->|"enters download mode"| node_da_protocol
node_da_protocol -.->|"supports V5"| node_xflash
node_da_protocol -.->|"supports V6"| node_xml
node_device -.->|"exposes information"| node_device_info
node_device -.->|"performs flash operations"| node_flash_ops
node_device -.->|"supports scatter files"| node_scatter
node_device -.->|"accesses storage"| node_storage
node_device -.->|"supports RPMB"| node_rpmb
node_device -.->|"supports memory access"| node_memory_ops
node_device -.->|"supports unlocking"| node_unlock
node_exploits -.->|"enables exploits"| node_unlock
node_device -.->|"uses authentication"| node_auth

click node_cli "https://github.com/shomykohai/penumbra/tree/main/app/src/cli/commands"
click node_tui "https://github.com/shomykohai/penumbra/blob/main/app/src/app.rs"
click node_device_pages "https://github.com/shomykohai/penumbra/tree/main/app/src/pages/device"
click node_device "https://github.com/shomykohai/penumbra/blob/main/core/src/device.rs"
click node_device_info "https://github.com/shomykohai/penumbra/blob/main/core/src/devinfo.rs"
click node_transport "https://github.com/shomykohai/penumbra/blob/main/core/src/port/mod.rs"
click node_usb_backends "https://github.com/shomykohai/penumbra/tree/main/core/src/port/backend"
click node_preloader "https://github.com/shomykohai/penumbra/blob/main/core/src/preloader/protocol.rs"
click node_da_protocol "https://github.com/shomykohai/penumbra/blob/main/core/src/da/protocol.rs"
click node_xflash "https://github.com/shomykohai/penumbra/blob/main/core/src/da/xflash/protocol.rs"
click node_xml "https://github.com/shomykohai/penumbra/blob/main/core/src/da/xml/protocol.rs"
click node_flash_ops "https://github.com/shomykohai/penumbra/tree/main/core/src/da"
click node_scatter "https://github.com/shomykohai/penumbra/blob/main/core/src/da/scatter.rs"
click node_storage "https://github.com/shomykohai/penumbra/tree/main/core/src/storage"
click node_rpmb "https://github.com/shomykohai/penumbra/blob/main/app/src/cli/commands/device/rpmb.rs"
click node_memory_ops "https://github.com/shomykohai/penumbra/tree/main/app/src/cli/commands/device"
click node_unlock "https://github.com/shomykohai/penumbra/tree/main/core/src/exploit"
click node_exploits "https://github.com/shomykohai/penumbra/blob/main/core/src/exploit/mod.rs"
click node_auth "https://github.com/shomykohai/penumbra/tree/main/core/src/auth"

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_tui,node_device_pages toneBlue
class node_device,node_device_info,node_transport,node_usb_backends toneAmber
class node_preloader,node_da_protocol,node_xflash,node_xml toneMint
class node_flash_ops,node_scatter,node_storage,node_rpmb,node_memory_ops toneRose
class node_unlock,node_exploits,node_auth,node_user toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/shomykohai/penumbra/tree/main/app/src/cli/commands): `app/src/cli/commands`
- [TUI app](https://github.com/shomykohai/penumbra/blob/main/app/src/app.rs): `app/src/app.rs`
- [Device page](https://github.com/shomykohai/penumbra/tree/main/app/src/pages/device): `app/src/pages/device`

### Device core

- [Device API](https://github.com/shomykohai/penumbra/blob/main/core/src/device.rs): `core/src/device.rs`
- [Device info](https://github.com/shomykohai/penumbra/blob/main/core/src/devinfo.rs): `core/src/devinfo.rs`
- [Port transport](https://github.com/shomykohai/penumbra/blob/main/core/src/port/mod.rs): `core/src/port/mod.rs`
- [USB backends](https://github.com/shomykohai/penumbra/tree/main/core/src/port/backend): `core/src/port/backend`

### Download protocols

- [Preloader protocol](https://github.com/shomykohai/penumbra/blob/main/core/src/preloader/protocol.rs): `core/src/preloader/protocol.rs`
- [Download protocol](https://github.com/shomykohai/penumbra/blob/main/core/src/da/protocol.rs): `core/src/da/protocol.rs`
- [V5 XFlash](https://github.com/shomykohai/penumbra/blob/main/core/src/da/xflash/protocol.rs): `core/src/da/xflash/protocol.rs`
- [V6 XML](https://github.com/shomykohai/penumbra/blob/main/core/src/da/xml/protocol.rs): `core/src/da/xml/protocol.rs`

### Device operations

- [Flash and readback](https://github.com/shomykohai/penumbra/tree/main/core/src/da): `core/src/da`
- [Scatter flashing](https://github.com/shomykohai/penumbra/blob/main/core/src/da/scatter.rs): `core/src/da/scatter.rs`
- [Storage and partitions](https://github.com/shomykohai/penumbra/tree/main/core/src/storage): `core/src/storage`
- [RPMB operations](https://github.com/shomykohai/penumbra/blob/main/app/src/cli/commands/device/rpmb.rs): `app/src/cli/commands/device/rpmb.rs`
- [Memory access](https://github.com/shomykohai/penumbra/tree/main/app/src/cli/commands/device): `app/src/cli/commands/device`

### Security

- [Bootloader unlock](https://github.com/shomykohai/penumbra/tree/main/core/src/exploit): `core/src/exploit`
- [Device exploits](https://github.com/shomykohai/penumbra/blob/main/core/src/exploit/mod.rs): `core/src/exploit/mod.rs`
- [Authentication](https://github.com/shomykohai/penumbra/tree/main/core/src/auth): `core/src/auth`

### Other components

- **Operator**

## Connections

- Operator → CLI commands: runs commands (evidence: `README.md`)
- Operator → TUI app: uses interface (evidence: `README.md`)
- TUI app → Device page: switches pages (evidence: `app/src/app.rs`)
- CLI commands → Device API: executes operations
- Device page → Device API: dispatches actions
- Device API → Port transport: uses transport
- Port transport → USB backends: selects backend (evidence: `core/src/port/mod.rs`)
- Device API → Preloader protocol: uses protocol
- Device API → Download protocol: enters download mode
- Download protocol → V5 XFlash: supports V5
- Download protocol → V6 XML: supports V6
- Device API → Device info: exposes information
- Device API → Flash and readback: performs flash operations
- Device API → Scatter flashing: supports scatter files
- Device API → Storage and partitions: accesses storage
- Device API → RPMB operations: supports RPMB (evidence: `README.md`)
- Device API → Memory access: supports memory access (evidence: `README.md`)
- Device API → Bootloader unlock: supports unlocking (evidence: `README.md`)
- Device exploits → Bootloader unlock: enables exploits (evidence: `core/src/exploit/mod.rs`)
- Device API → Authentication: uses authentication
