Skip to content

On-device CAP file loading from SD card and serial #27

@Amperstrand

Description

@Amperstrand

Summary

Currently, DGP files must be pre-converted on a host PC and uploaded via mpremote cp. This issue tracks future work to allow the device itself to receive and process CAP files directly.

Background

DGP is a preprocessed format (CAP components concatenated in GP tag order, excluding Descriptor.cap and Java bytecode). It's ~5x smaller than the original CAP file. See tools/cap_to_dgp.py and applets.yaml for the current pipeline.

Proposed delivery methods

1. SD card loading

  • User puts CAP file on SD card
  • Device reads from /sd/gp/*.cap, converts to DGP in RAM, loads to card
  • Requires: minimal ZIP reader (STORE-only, ~50-80 lines Python)
  • Trade-off: larger file transfer (93KB vs 18KB) but no PC step
  • Memory: need ~93KB RAM during conversion (currently tight on fragmented heap)

2. USB serial upload

  • Host sends CAP/DGP file over serial to device
  • Device streams to card LOAD commands directly (no full file in RAM)
  • Could be integrated into Specter-Desktop USB protocol
  • Already partially possible via mpremote cp

3. QR code (airgapped)

  • Encode DGP as a sequence of QR codes (alphanumeric mode, ~2.9KB per QR)
  • ~7 QR codes for SeedKeeper (18KB DGP)
  • Device scans QR codes, reassembles, loads to card
  • Maximum security: no USB or network connection needed
  • Trade-off: slow UX, but enables fully airgapped provisioning

Open questions

  • Should we support raw CAP or only DGP? (CAP needs ZIP extraction code)
  • Memory constraints: 93KB CAP in RAM may fail on fragmented heap (we saw this with SeedKeeper DGP at 18KB)
  • Streaming LOAD: read CAP components from SD and LOAD one at a time without buffering the whole file
  • QR encoding: BCQR/UR types vs custom encoding

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature creepIncreases merge complexity; scope should be reduced or deferredpriority: lowNice to have, not blockingseedkeeperSeedKeeper keystore support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions