# emard/esp32ecp5 architecture

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

## Overview

This repository provides MicroPython tools for configuring an ESP32-based JTAG interface and programming or flashing FPGA boards, especially Lattice ECP5. The main workflow is booting the device, bringing up Wi-Fi and FTP access, selecting a bitstream, then streaming it over JTAG; flash operations use JTAG-mediated SPI commands. It also includes SD-card access, a PTP-related module, CircuitPython variants, and programmers for other FPGA families. Edges reflect README statements and shown imports/calls; unsampled implementations are represented by their exact tree paths, with uncertain wiring omitted.

Main entry points: [`rbp/parts/jtag.py`](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/jtag.py) (Shared JTAG engine), [`ecp5.py`](https://github.com/emard/esp32ecp5/blob/master/ecp5.py) (ECP5 programmer), [`uftpd.py`](https://github.com/emard/esp32ecp5/blob/master/uftpd.py) (FTP server), [`main.py`](https://github.com/emard/esp32ecp5/blob/master/main.py) (Boot startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["ESP32 Runtime"]
  node_main["Boot startup<br/>[main.py]"]
  node_wifi["Wi-Fi manager<br/>[wifiman.py]"]
  node_setup["Board setup<br/>[ecp5setup.py]"]
end

subgraph group_ecp5["ECP5 Programming"]
  node_pins["JTAG pin map<br/>[jtagpin.py]"]
  node_ecp5prog["ECP5 programmer<br/>[ecp5.py]"]
  node_ecp5web["Web programming<br/>[ecp5wp.py]"]
  node_ptp["PTP module<br/>[ptp.py]"]
end

subgraph group_transport["File and Network"]
  node_ftp["FTP server<br/>[uftpd.py]"]
  node_sdrawing["SD drawing access<br/>[sdraw.py]"]
  node_sdpins["SD pin map<br/>[sdpin.py]"]
end

subgraph group_platforms["FPGA Variants"]
  node_rbp_artix["Artix-7 programmer<br/>[artix7.py]"]
  node_rbp_cyclone["Cyclone V programmer<br/>[cyclone5.py]"]
  node_rbp_ecp5["RBP ECP5 programmer<br/>[ecp5.py]"]
  node_rbp_jtag["Shared JTAG engine<br/>[jtag.py]"]
  node_rbp_prog["Shared stream logic<br/>[proglib.py]"]
  node_rbp_cyclib["Cyclone V operations<br/>[cyclone5lib.py]"]
  node_rbp_ecp5lib["RBP ECP5 operations<br/>[ecp5lib.py]"]
  node_rbp_retidle["Ret2idle ECP5<br/>[ecp5lib.py]"]
end

subgraph group_circuitpython["CircuitPython Variant"]
  node_cp_jtag["CircuitPython JTAG<br/>[jtag.py]"]
  node_cp_flash["CircuitPython ECP5 flash<br/>[ecp5f.py]"]
  node_cp_prog["CircuitPython ECP5 programmer<br/>[ecp5p.py]"]
  node_cp_sd["CircuitPython SD mount<br/>[sdmount.py]"]
  node_cp_wifi["CircuitPython Wi-Fi manager<br/>[wifiman.py]"]
end

node_operator(("Device operator"))
node_fpga{{"FPGA board"}}

node_operator -->|"runs setup"| node_setup
node_operator -->|"reboots device"| node_main
node_main -->|"imports"| node_wifi
node_main -->|"starts service"| node_ftp
node_operator -->|"uploads bitstream"| node_ftp
node_ftp -->|"uses programmer"| node_ecp5prog
node_ftp -->|"imports SD access"| node_sdrawing
node_sdrawing -->|"imports pin map"| node_sdpins
node_ecp5prog -->|"reads pin map"| node_pins
node_ecp5prog -->|"programs or flashes"| node_fpga
node_ecp5web -->|"reads pin map"| node_pins
node_ptp -->|"imports programmer"| node_ecp5prog
node_rbp_artix -->|"uses JTAG engine"| node_rbp_jtag
node_rbp_cyclone -->|"imports stream logic"| node_rbp_prog
node_rbp_cyclone -.->|"uses FPGA operations"| node_rbp_cyclib
node_rbp_prog -->|"imports JTAG engine"| node_rbp_jtag
node_rbp_cyclib -->|"imports JTAG engine"| node_rbp_jtag
node_rbp_ecp5 -.->|"uses FPGA operations"| node_rbp_ecp5lib
node_rbp_ecp5lib -->|"imports JTAG engine"| node_rbp_jtag
node_rbp_retidle -->|"imports JTAG engine"| node_rbp_jtag
node_cp_flash -->|"imports JTAG"| node_cp_jtag
node_cp_prog -->|"imports JTAG"| node_cp_jtag
node_cp_flash -.->|"flashes FPGA"| node_fpga
node_cp_prog -.->|"programs FPGA"| node_fpga

click node_main "https://github.com/emard/esp32ecp5/blob/master/main.py"
click node_wifi "https://github.com/emard/esp32ecp5/blob/master/wifiman.py"
click node_setup "https://github.com/emard/esp32ecp5/blob/master/ecp5setup.py"
click node_pins "https://github.com/emard/esp32ecp5/blob/master/jtagpin.py"
click node_ecp5prog "https://github.com/emard/esp32ecp5/blob/master/ecp5.py"
click node_ecp5web "https://github.com/emard/esp32ecp5/blob/master/ecp5wp.py"
click node_ptp "https://github.com/emard/esp32ecp5/blob/master/ptp.py"
click node_ftp "https://github.com/emard/esp32ecp5/blob/master/uftpd.py"
click node_sdrawing "https://github.com/emard/esp32ecp5/blob/master/sdraw.py"
click node_sdpins "https://github.com/emard/esp32ecp5/blob/master/sdpin.py"
click node_rbp_artix "https://github.com/emard/esp32ecp5/blob/master/rbp/artix7.py"
click node_rbp_cyclone "https://github.com/emard/esp32ecp5/blob/master/rbp/cyclone5.py"
click node_rbp_ecp5 "https://github.com/emard/esp32ecp5/blob/master/rbp/ecp5.py"
click node_rbp_jtag "https://github.com/emard/esp32ecp5/blob/master/rbp/parts/jtag.py"
click node_rbp_prog "https://github.com/emard/esp32ecp5/blob/master/rbp/parts/proglib.py"
click node_rbp_cyclib "https://github.com/emard/esp32ecp5/blob/master/rbp/parts/cyclone5lib.py"
click node_rbp_ecp5lib "https://github.com/emard/esp32ecp5/blob/master/rbp/parts/ecp5lib.py"
click node_rbp_retidle "https://github.com/emard/esp32ecp5/blob/master/rbp/parts/ret2idle/ecp5lib.py"
click node_cp_jtag "https://github.com/emard/esp32ecp5/blob/master/circuitpython/jtag.py"
click node_cp_flash "https://github.com/emard/esp32ecp5/blob/master/circuitpython/ecp5f.py"
click node_cp_prog "https://github.com/emard/esp32ecp5/blob/master/circuitpython/ecp5p.py"
click node_cp_sd "https://github.com/emard/esp32ecp5/blob/master/circuitpython/sdmount.py"
click node_cp_wifi "https://github.com/emard/esp32ecp5/blob/master/circuitpython/wifiman.py"

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_main,node_wifi,node_setup toneBlue
class node_pins,node_ecp5prog,node_ecp5web,node_ptp toneAmber
class node_ftp,node_sdrawing,node_sdpins toneMint
class node_rbp_artix,node_rbp_cyclone,node_rbp_ecp5,node_rbp_jtag,node_rbp_prog,node_rbp_cyclib,node_rbp_ecp5lib,node_rbp_retidle toneRose
class node_cp_jtag,node_cp_flash,node_cp_prog,node_cp_sd,node_cp_wifi,node_operator,node_fpga toneIndigo
```

## Components

### ESP32 Runtime

- [Boot startup](https://github.com/emard/esp32ecp5/blob/master/main.py): `main.py`
- [Wi-Fi manager](https://github.com/emard/esp32ecp5/blob/master/wifiman.py): `wifiman.py`
- [Board setup](https://github.com/emard/esp32ecp5/blob/master/ecp5setup.py): `ecp5setup.py`

### ECP5 Programming

- [JTAG pin map](https://github.com/emard/esp32ecp5/blob/master/jtagpin.py): `jtagpin.py`
- [ECP5 programmer](https://github.com/emard/esp32ecp5/blob/master/ecp5.py): `ecp5.py`
- [Web programming](https://github.com/emard/esp32ecp5/blob/master/ecp5wp.py): `ecp5wp.py`
- [PTP module](https://github.com/emard/esp32ecp5/blob/master/ptp.py): `ptp.py`

### File and Network

- [FTP server](https://github.com/emard/esp32ecp5/blob/master/uftpd.py): `uftpd.py`
- [SD drawing access](https://github.com/emard/esp32ecp5/blob/master/sdraw.py): `sdraw.py`
- [SD pin map](https://github.com/emard/esp32ecp5/blob/master/sdpin.py): `sdpin.py`

### FPGA Variants

- [Artix-7 programmer](https://github.com/emard/esp32ecp5/blob/master/rbp/artix7.py): `rbp/artix7.py`
- [Cyclone V programmer](https://github.com/emard/esp32ecp5/blob/master/rbp/cyclone5.py): `rbp/cyclone5.py`
- [RBP ECP5 programmer](https://github.com/emard/esp32ecp5/blob/master/rbp/ecp5.py): `rbp/ecp5.py`
- [Shared JTAG engine](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/jtag.py): `rbp/parts/jtag.py`
- [Shared stream logic](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/proglib.py): `rbp/parts/proglib.py`
- [Cyclone V operations](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/cyclone5lib.py): `rbp/parts/cyclone5lib.py`
- [RBP ECP5 operations](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/ecp5lib.py): `rbp/parts/ecp5lib.py`
- [Ret2idle ECP5](https://github.com/emard/esp32ecp5/blob/master/rbp/parts/ret2idle/ecp5lib.py): `rbp/parts/ret2idle/ecp5lib.py`

### CircuitPython Variant

- [CircuitPython JTAG](https://github.com/emard/esp32ecp5/blob/master/circuitpython/jtag.py): `circuitpython/jtag.py`
- [CircuitPython ECP5 flash](https://github.com/emard/esp32ecp5/blob/master/circuitpython/ecp5f.py): `circuitpython/ecp5f.py`
- [CircuitPython ECP5 programmer](https://github.com/emard/esp32ecp5/blob/master/circuitpython/ecp5p.py): `circuitpython/ecp5p.py`
- [CircuitPython SD mount](https://github.com/emard/esp32ecp5/blob/master/circuitpython/sdmount.py): `circuitpython/sdmount.py`
- [CircuitPython Wi-Fi manager](https://github.com/emard/esp32ecp5/blob/master/circuitpython/wifiman.py): `circuitpython/wifiman.py`

### Other components

- **Device operator**
- **FPGA board**

## Connections

- Device operator → Board setup: runs setup (evidence: `README.md`)
- Device operator → Boot startup: reboots device (evidence: `README.md`)
- Boot startup → Wi-Fi manager: imports (evidence: `main.py`)
- Boot startup → FTP server: starts service (evidence: `main.py`)
- Device operator → FTP server: uploads bitstream (evidence: `README.md`)
- FTP server → ECP5 programmer: uses programmer (evidence: `uftpd.py`)
- FTP server → SD drawing access: imports SD access (evidence: `uftpd.py`)
- SD drawing access → SD pin map: imports pin map (evidence: `sdraw.py`)
- ECP5 programmer → JTAG pin map: reads pin map (evidence: `ecp5.py`)
- ECP5 programmer → FPGA board: programs or flashes (evidence: `README.md`)
- Web programming → JTAG pin map: reads pin map (evidence: `ecp5wp.py`)
- PTP module → ECP5 programmer: imports programmer (evidence: `ptp.py`)
- Artix-7 programmer → Shared JTAG engine: uses JTAG engine (evidence: `rbp/artix7.py`)
- Cyclone V programmer → Shared stream logic: imports stream logic
- Cyclone V programmer → Cyclone V operations: uses FPGA operations
- Shared stream logic → Shared JTAG engine: imports JTAG engine (evidence: `rbp/parts/proglib.py`)
- Cyclone V operations → Shared JTAG engine: imports JTAG engine (evidence: `rbp/parts/cyclone5lib.py`)
- RBP ECP5 programmer → RBP ECP5 operations: uses FPGA operations
- RBP ECP5 operations → Shared JTAG engine: imports JTAG engine (evidence: `rbp/parts/ecp5lib.py`)
- Ret2idle ECP5 → Shared JTAG engine: imports JTAG engine (evidence: `rbp/parts/ret2idle/ecp5lib.py`)
- CircuitPython ECP5 flash → CircuitPython JTAG: imports JTAG (evidence: `circuitpython/ecp5f.py`)
- CircuitPython ECP5 programmer → CircuitPython JTAG: imports JTAG (evidence: `circuitpython/ecp5p.py`)
- CircuitPython ECP5 flash → FPGA board: flashes FPGA
- CircuitPython ECP5 programmer → FPGA board: programs FPGA
