# havenoverflow/cr50 architecture

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

- Interactive diagram: https://gitdiagram.com/havenoverflow/cr50
- Repository: https://github.com/havenoverflow/cr50

## Overview

This repository is Cr50 security-chip firmware, forked to include custom firmware and reverse-engineered support for other Google security chips. The product spans ROM startup, a signed-image loader, firmware runtime, cryptography, TPM services, and board-level interfaces. The sampled loader and ROM sources establish their image-verification and setup dependencies; the index also identifies major firmware subsystems, but does not expose their runtime wiring. Consequently, several important capabilities are shown as components without speculative call edges.

Main entry points: [`chip/haven/loader/main.c`](https://github.com/havenoverflow/cr50/blob/main/chip/haven/loader/main.c) (Image loader), [`chip/haven/signed_header.h`](https://github.com/havenoverflow/cr50/blob/main/chip/haven/signed_header.h) (Signed headers), [`chip/haven/rom/main.c`](https://github.com/havenoverflow/cr50/blob/main/chip/haven/rom/main.c) (ROM startup), [`common/main.c`](https://github.com/havenoverflow/cr50/blob/main/common/main.c) (Firmware startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot and images"]
  node_rom["ROM startup<br/>[main.c]"]
  node_loader["Image loader<br/>[main.c]"]
  node_signed["Signed headers<br/>[signed_header.h]"]
end

subgraph group_runtime["Firmware runtime"]
  node_runtime_entry["Firmware startup<br/>[main.c]"]
  node_boot_params["Boot parameters<br/>[boot_param.c]"]
end

subgraph group_security["Security services"]
  node_dcrypto["Hardware crypto"]
  node_tpm["TPM 2 services"]
  node_nvmem[("TPM NVM<br/>[tpm_nvmem_ops.c]")]
  node_u2f["U2F support<br/>[u2f.c]"]
  node_rma["RMA authorization<br/>[rma_auth.c]"]
  node_pinweaver["Pinweaver integration"]
end

subgraph group_hardware["Board interfaces"]
  node_board["Smiko board<br/>[board.c]"]
  node_spi["SPI controller<br/>[spi_controller.c]"]
  node_i2c["I2C controller<br/>[i2c_controller.c]"]
  node_usb_spi["USB SPI bridge<br/>[usb_spi.c]"]
  node_usb_i2c["USB I2C bridge<br/>[usb_i2c.c]"]
end

node_actor(("Chip startup"))

node_rom -->|"reads header"| node_signed
node_loader -->|"verifies image"| node_signed
node_loader -.->|"starts from"| node_actor
node_runtime_entry -.->|"initializes firmware"| node_actor

click node_rom "https://github.com/havenoverflow/cr50/blob/main/chip/haven/rom/main.c"
click node_loader "https://github.com/havenoverflow/cr50/blob/main/chip/haven/loader/main.c"
click node_signed "https://github.com/havenoverflow/cr50/blob/main/chip/haven/signed_header.h"
click node_runtime_entry "https://github.com/havenoverflow/cr50/blob/main/common/main.c"
click node_boot_params "https://github.com/havenoverflow/cr50/blob/main/boot_param/boot_param.c"
click node_board "https://github.com/havenoverflow/cr50/blob/main/board/smiko/board.c"
click node_spi "https://github.com/havenoverflow/cr50/blob/main/chip/smiko/spi_controller.c"
click node_i2c "https://github.com/havenoverflow/cr50/blob/main/common/i2c_controller.c"
click node_usb_spi "https://github.com/havenoverflow/cr50/blob/main/board/smiko/usb_spi.c"
click node_usb_i2c "https://github.com/havenoverflow/cr50/blob/main/board/smiko/usb_i2c.c"
click node_dcrypto "https://github.com/havenoverflow/cr50/tree/main/board/smiko/dcrypto"
click node_tpm "https://github.com/havenoverflow/cr50/tree/main/board/smiko/tpm2"
click node_nvmem "https://github.com/havenoverflow/cr50/blob/main/board/smiko/tpm_nvmem_ops.c"
click node_u2f "https://github.com/havenoverflow/cr50/blob/main/board/smiko/dcrypto/u2f.c"
click node_rma "https://github.com/havenoverflow/cr50/blob/main/common/rma_auth.c"
click node_pinweaver "https://github.com/havenoverflow/cr50/blob/main/board/smiko/pinweaver_tpm_imports.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_rom,node_loader,node_signed toneBlue
class node_runtime_entry,node_boot_params toneAmber
class node_dcrypto,node_tpm,node_nvmem,node_u2f,node_rma,node_pinweaver toneMint
class node_board,node_spi,node_i2c,node_usb_spi,node_usb_i2c toneRose
class node_actor toneIndigo
```

## Components

### Boot and images

- [ROM startup](https://github.com/havenoverflow/cr50/blob/main/chip/haven/rom/main.c): `chip/haven/rom/main.c`
- [Image loader](https://github.com/havenoverflow/cr50/blob/main/chip/haven/loader/main.c): `chip/haven/loader/main.c`
- [Signed headers](https://github.com/havenoverflow/cr50/blob/main/chip/haven/signed_header.h): `chip/haven/signed_header.h`

### Firmware runtime

- [Firmware startup](https://github.com/havenoverflow/cr50/blob/main/common/main.c): `common/main.c`
- [Boot parameters](https://github.com/havenoverflow/cr50/blob/main/boot_param/boot_param.c): `boot_param/boot_param.c`

### Security services

- [Hardware crypto](https://github.com/havenoverflow/cr50/tree/main/board/smiko/dcrypto): `board/smiko/dcrypto`
- [TPM 2 services](https://github.com/havenoverflow/cr50/tree/main/board/smiko/tpm2): `board/smiko/tpm2`
- [TPM NVM](https://github.com/havenoverflow/cr50/blob/main/board/smiko/tpm_nvmem_ops.c): `board/smiko/tpm_nvmem_ops.c`
- [U2F support](https://github.com/havenoverflow/cr50/blob/main/board/smiko/dcrypto/u2f.c): `board/smiko/dcrypto/u2f.c`
- [RMA authorization](https://github.com/havenoverflow/cr50/blob/main/common/rma_auth.c): `common/rma_auth.c`
- [Pinweaver integration](https://github.com/havenoverflow/cr50/blob/main/board/smiko/pinweaver_tpm_imports.c): `board/smiko/pinweaver_tpm_imports.c`

### Board interfaces

- [Smiko board](https://github.com/havenoverflow/cr50/blob/main/board/smiko/board.c): `board/smiko/board.c`
- [SPI controller](https://github.com/havenoverflow/cr50/blob/main/chip/smiko/spi_controller.c): `chip/smiko/spi_controller.c`
- [I2C controller](https://github.com/havenoverflow/cr50/blob/main/common/i2c_controller.c): `common/i2c_controller.c`
- [USB SPI bridge](https://github.com/havenoverflow/cr50/blob/main/board/smiko/usb_spi.c): `board/smiko/usb_spi.c`
- [USB I2C bridge](https://github.com/havenoverflow/cr50/blob/main/board/smiko/usb_i2c.c): `board/smiko/usb_i2c.c`

### Other components

- **Chip startup**

## Connections

- ROM startup → Signed headers: reads header (evidence: `chip/haven/rom/main.c`)
- Image loader → Signed headers: verifies image (evidence: `chip/haven/loader/main.c`)
- Image loader → Chip startup: starts from
- Firmware startup → Chip startup: initializes firmware
