How rfidresearchgroup/chameleonultra works
1. Project shape
- This repository is a full product stack for the ChameleonUltra RFID device: embedded firmware, host-side tooling, hardware reference files, and documentation.
- The architectural center is the firmware for an nRF52-based device; the other directories support flashing, control, and card-key recovery workflows.
2. Device runtime split: bootloader vs application
- firmware/bootloader is a separate DFU-capable bootloader image.
- firmware/application is the main product firmware.
- The boundary is important: the bootloader handles secure firmware update and image validation, while the application owns all product behavior.
3. Embedded platform layer
- The firmware is built on Nordic’s nRF5 SDK (firmware/nrf52_sdk) plus local common code in firmware/common.
- These layers provide the SoC runtime, SoftDevice/BLE integration, USB/device drivers, logging, timers, flash storage, and low-level board support.
- The application code sits on top of this SDK layer and should be treated as the product-specific logic.
4. Main application responsibilities
- firmware/application/src/app_main.c, rfid_main.c, ble_main.c, usb_main.c, and settings.c indicate the application is split into:
- device initialization and lifecycle
- BLE transport
- USB transport
- RFID functionality
- persistent settings/state
- app_cmd.* and data_cmd.h suggest a command-driven core, with transport adapters feeding a shared command/data path.
5. RFID subsystem
- The largest application subtree is firmware/application/src/rfid, showing this is the core product function.
- It is organized into:
- reader code for interacting with tags/cards
- nfctag code for tag emulation
- protocol utilities such as parity, CRC, byte/hex helpers, and Crypto1-related code
- This subsystem is split by frequency band and protocol family:
- HF/NFC: MIFARE/NFC-A/NTAG-style handling
- LF/125 kHz: EM410x, HID Prox, ioprox, Viking, PAC, Wiegand, T55xx-related flows
- The architecture implies a protocol dispatcher above hardware radio primitives and protocol-specific codecs below it.
6. RFID data flow
- The hardware-facing radio code captures or transmits signal frames.
- Protocol decoders/encoders translate those frames into structured tag/reader data.
- Tag emulation modules then replay or synthesize responses based on stored tag state.
- Persistence (tag_persistence.c) indicates emulated tag profiles can survive resets via flash-backed storage.
7. Wireless and USB transport boundaries
- ble_main.c and usb_main.c are transport front ends, not the domain logic itself.
- They likely bridge the device’s internal command/data model to host clients over:
- BLE for mobile/desktop companion apps
- USB for CLI and wired tooling
- This keeps transport concerns separate from RFID and device-state logic.
8. State, storage, and system services
- settings.c, utils/fds_util.c, utils/delayed_reset.c, utils/timeslot.c, utils/syssleep.c, and the bsp helpers show a set of shared services for:
- nonvolatile settings
- flash storage
- reset/power management
- timing and radio coexistence
- These are the main cross-cutting infrastructure pieces used by RFID, BLE, and USB modules.
9. Host-side software stack
- software/ contains the companion tooling used to talk to the device and perform offline cryptographic attacks/recovery.
- software/script is a Python-based CLI and communication layer.
- software/src is a native C/CMake codebase containing RFID attack/recovery algorithms, especially hardnested and nested MIFARE-related tooling.
- The host software is therefore not just a UI; it is a computational backend for card-key recovery and device orchestration.
10. Host/device interaction model
- The Python layer (chameleon_cli_main.py, chameleon_com.py, chameleon_cmd.py) appears to be the primary control plane for issuing commands to the device.
- The native C code in software/src/HardnestedRecovery and related files provides the heavier cryptanalysis algorithms that complement the embedded device’s capture/emulation capabilities.
- So the system boundary is: device firmware handles live RFID operations; host software handles control and expensive offline computation.
11. Key distribution and update infrastructure
- resource/dfu_key/chameleon.pem and the DFU scripts show a signed-update pipeline.
- resource/tools/enter_dfu.py and enter_dfu_over_ble.py imply multiple update entry paths: USB and BLE.
- This means firmware updates are a first-class architectural path, not an afterthought.
12. Hardware boundary
- hardware/lite, hardware/ultra, and hardware/dev-tools contain reference schematics/packaging documents and zips.
- These are not executable components, but they define the physical hardware variants the firmware must support.
- The repo therefore spans both product firmware and board-specific hardware definitions.
13. Build and release orchestration
- GitHub Actions workflows cover firmware builds, client builds, Python checks, changelog reminders, wiki deployment, and PR/push validation.
- The firmware/Dockerfile and build scripts indicate a containerized/reproducible firmware toolchain.
- Architecture-wise, this is a multi-artifact repo: firmware images, host tools, docs, and packaged hardware assets are all produced from the same source tree.
14. Overall system view
- The clearest diagram is a three-tier model:
- Hardware device: nRF52 board running bootloader + application
- Transport/control clients: BLE/USB host tools and mobile/desktop apps
- Offline tooling: Python/C recovery and CLI utilities
- The primary data path is RFID signal acquisition/emulation on-device, with command/control and key-recovery flows coming in from host tools.
Main entry points: app_main.c App Core · main.c Bootloader · app_cmd.c Command Core · build_firmware.yml CI / Build
Components 18
Firmware
Device-side bootloader, application, and embedded platform layer
- Bootloader · Signed update bootloader with image validation and startup handoff
firmware/bootloader/src/main.c - App Core · Main product firmware entrypoint and lifecycle
firmware/application/src/app_main.c - Command Core · Shared command/data dispatch for transports and device actions
firmware/application/src/app_cmd.c - BLE Transport · Bluetooth control and data front end
firmware/application/src/ble_main.c - USB Transport · USB control and wired host front end
firmware/application/src/usb_main.c - RFID Runtime · Top-level RFID lifecycle and mode coordination
firmware/application/src/rfid_main.c - Readers · HF and LF reader-side radio capture and decoding
firmware/application/src/rfid/reader - Tag Emu · HF/LF tag emulation and replay state machines
firmware/application/src/rfid/nfctag - Protocols · Parity, CRC, Crypto1, and protocol helpers
firmware/application/src/rfid/crc_utils.c - Settings · Device configuration and flash-backed state
firmware/application/src/settings.c - Platform · nRF5 SDK, common board support, storage, timing, logging, and BLE/USB drivers
firmware/common/hw_connect.c
Host Tools
Python CLI and native recovery tooling
- Python CLI · Primary host command interface and device communication layer
software/script/chameleon_cli_main.py - Recovery Core · Offline nested and hardnested key recovery algorithms
software/src/HardnestedRecovery/hardnested_main.c - Legacy Crypto · Shared host-side MIFARE Crypto1 and attack helpers
software/src/crypto1.c
Assets
Hardware references, DFU keys, and packaging artifacts
Build Ops
Container, scripts, and CI workflows
- CI / Build · Repository workflows and containerized build orchestration
.github/workflows/build_firmware.yml
Connections 23
- Bootloader → DFU Key: validates · Bootloader uses signing key material to validate update images
- Bootloader → App Core: hands off · Bootloader starts the main application after DFU checks
- App Core → Platform: runs on · Application depends on Nordic SDK and common platform services
- App Core → Command Core: hosts · Device lifecycle initializes the shared command/data core
- App Core → RFID Runtime: starts · Product runtime enters RFID control paths
- App Core → BLE Transport: enables · Application brings up BLE transport
- App Core → USB Transport: enables · Application brings up USB transport
- BLE Transport → Command Core: bridges · BLE forwards host commands into the shared device model
- USB Transport → Command Core: bridges · USB forwards wired commands into the shared device model
- RFID Runtime → Readers: orchestrates · RFID runtime coordinates capture and decode flows
- RFID Runtime → Tag Emu: orchestrates · RFID runtime coordinates emulation flows
- Readers → Protocols: decodes · Reader-side raw frames are translated by protocol helpers
- Tag Emu → Protocols: encodes · Emulation synthesizes responses through protocol helpers
- Tag Emu → Settings: persists · Tag profiles and emulation state are stored across resets
- Settings → Platform: stores in · Persistent state relies on flash storage and system services
- Python CLI → Command Core: controls · Python CLI issues commands to the device
- Python CLI → Recovery Core: invokes · CLI workflows can hand off to offline key recovery
- Recovery Core → Legacy Crypto: uses · Native recovery algorithms share Crypto1-related code
- DFU Tools → Bootloader: enters · Update scripts trigger DFU mode for bootloader-based flashing
- CI / Build → Bootloader: builds · CI produces bootloader artifacts
- CI / Build → App Core: builds · CI produces application firmware artifacts
- CI / Build → Python CLI: builds · CI validates host tooling artifacts
- Hardware → Platform: targets · Hardware variants define the supported board boundary for firmware