378 Commits

Author SHA1 Message Date
matteoscrugli 1e78976bd9 feat(lf): shift IDTECK command IDs to avoid collision with Jablotron PR #404
LupusE requested in the PR #407 review (2026-05-13) to move IDTECK
command IDs since PR #404 (Jablotron) also uses 3017 / 5010 / 5011.
Both PRs are open with the feature-freeze label; Jablotron retains
the original slots and IDTECK shifts up:

  DATA_CMD_IDTECK_WRITE_TO_T55XX: 3017 -> 3018
  DATA_CMD_IDTECK_SET_EMU_ID:     5010 -> 5012
  DATA_CMD_IDTECK_GET_EMU_ID:     5011 -> 5013

Files changed:
- firmware/application/src/data_cmd.h
- software/script/chameleon_enum.py

app_cmd.c references the constants by name only, no edit needed there.
2026-05-15 10:09:51 +02:00
matteoscrugli 77e967c78b feat(lf): integrate IDTECK into firmware command and T55xx write paths
Exposes IDTECK to the host command protocol:
- DATA_CMD_IDTECK_SET_EMU_ID (5010) / GET_EMU_ID (5011) / WRITE_TO_T55XX (3017)
- Matching handlers in app_cmd.c for setting the emulated frame on
  the current LF slot, reading it back, and programming a T55xx tag

Adds write_idteck_to_t55xx in lf_reader_main (modeled on the other
per-protocol T55xx writers), wrapping idteck_t55xx_writer and the
shared write_t55xx helper.

After this commit the firmware is fully functional for IDTECK: a
host can set an emulated frame, read it back, or clone it to a T55xx.
The CLI wiring is added in the following commit.
2026-05-15 10:08:48 +02:00
matteoscrugli b8f070851c feat(lf): add IDTECK tag emulation (PSK1 RF/32)
Adds IDTECK as a new LF protocol for tag emulation. IDTECK is a PSK1
encoding at RF/32 with a 64-bit frame: a 32-bit fixed preamble
0x4944544B ("IDTK") followed by a 32-bit card payload (one-byte
checksum + 24-bit card number in byte-reversed layout, matching the
format used by the Proxmark3 client).

The modulator drives LF_MOD (load-modulation, same hardware path used
for FSK protocols like HID Prox) via the shared utils/psk1 helper,
producing a 62.5kHz subcarrier with a 180-degree phase flip at every
differential bit transition. Because PSK1 is differential the reader
decodes phase transitions between consecutive bits rather than
absolute phase, so carrier phase-lock is not required — a free-running
subcarrier from HFXO (±40ppm) stays within the tolerance of consumer
readers.

The 16us subcarrier period is below the counter_top minimum of 3 at
the legacy 125kHz PWM base clock used for ASK/FSK protocols. To avoid
rescaling every existing protocol, pwm_init now selects the base
clock based on the active tag type (predicate IS_PSK1_TYPE): 1MHz for
PSK1, 125kHz otherwise. Legacy protocols are untouched.

The comment in lf_sense_enable is updated to reflect that the absence
of carrier phase-lock (envelope-only tag-mode antenna taps) rules out
coherent demod but does not preclude differential-phase encodings
like the one introduced here.

T5577 cloning configuration uses the existing T5577_MODULATION_PSK1
symbol combined with RF/32 bitrate and 2 data blocks. Emulation read
is not added: the tag-emulation ADC path is 125kHz envelope-filtered,
so PSK demod would need a dedicated edge-timing decoder (left as a
follow-up).
2026-05-15 10:08:48 +02:00
matteoscrugli 5e2401587e feat(lf): add shared PSK1 wave-form helper for tag emulation
Factors out the PSK1 subcarrier generator into utils/psk1.{c,h}.
The helper takes a frame (MSB-first bytes), a bit count and a
destination wave-form buffer, and fills the buffer with PWM entries
expressing differential PSK1 as polarity flips at bit transitions.

No protocol uses this helper yet; it is introduced alone so that
individual PSK1 protocol files (starting with IDTECK in the next
commit) can plug into the same timing and encoding logic without
each re-implementing it.

The helper targets the 1MHz PWM base clock that will be selected by
pwm_init for PSK1 tag types; counter_top and duty constants are
defined accordingly.
2026-05-15 10:08:48 +02:00
Niel Nielsen 1bf8229d26 Add files via upload 2026-05-14 13:21:31 +02:00
Niel Nielsen 7e48d5427a Add files via upload 2026-05-13 21:22:03 +02:00
Niel Nielsen 1954faf3af Fix: Device does not go to sleep, #421
The fix in EVT_END_SEQ0:
	1.	ANT_NO_MOD() — silences LF_MOD so the local drive no longer charges the peak detector
	2.	bsp_delay_ms(2) — 2ms settle, slightly above the ~2ms time constant so the detector drains to reflect only the external field
	3.	is_lf_field_exists() — now sees the real field state
	4.	If field gone → nrfx_pwm_stop() → EVT_STOPPED → lf_field_lost() runs correctly
	5.	If field present → ANT_MOD() restores modulation for the next PWM sequence​​​​​​​​​​​​​​​​
2026-05-13 21:13:57 +02:00
Niel Nielsen cef8b42c26 make_style as that is best practise 2026-05-11 12:36:51 +02:00
Niel Nielsen 43f4d55c2b Update app_cmd.c 2026-05-11 10:25:50 +02:00
Niel Nielsen d3f9a521cb Update app_cmd.c 2026-05-11 09:50:23 +02:00
Niel Nielsen 5f8f29c8b4 Update data_cmd.h 2026-05-11 09:48:31 +02:00
Niel Nielsen 9d8c52fbdb Add sleep timeout commands for configuration 2026-05-11 09:45:32 +02:00
Niel Nielsen 68f929b23f Add files via upload 2026-05-10 20:40:39 +02:00
Niel Nielsen a64798f8a7 Add files via upload 2026-05-10 19:48:06 +02:00
Niel Nielsen 2701e64755 Add files via upload 2026-05-10 19:15:34 +02:00
Niel Nielsen c0fd09b737 Add files via upload 2026-05-10 19:13:59 +02:00
Niel Nielsen e2ce3f3a29 Add files via upload 2026-05-10 17:05:43 +02:00
Niel Nielsen 4bfc18ae6f Add files via upload 2026-05-10 17:05:06 +02:00
Niel Nielsen 394781a45f Add files via upload 2026-05-07 20:08:23 +02:00
Niel Nielsen f8b0ae6085 FEAT: hf 14a auth-trace 2026-05-07 17:46:53 +02:00
Niel Nielsen bba432c579 Add files via upload 2026-05-01 20:14:24 +02:00
Niel Nielsen f7feda5dc9 Add files via upload 2026-05-01 18:45:52 +02:00
Niel Nielsen 8555f86c22 Merge branch 'RfidResearchGroup:main' into t55write 2026-05-01 17:52:45 +02:00
Niel Nielsen c63cc16bb5 Add files via upload 2026-05-01 17:50:32 +02:00
naaraxi 0460d9b95e Support for changing the wake time in the client 2026-05-01 14:36:52 +03:00
Niel Nielsen ae345c6a59 Fix ADC buffer dimensions in ble_main.c 2026-04-24 11:41:59 +02:00
Niel Nielsen 378c2b302f Various bug fixes 2026-04-15 06:29:10 +02:00
Niel Nielsen d70a0dd63f fix hf14a sniff 2026-04-14 09:32:35 +02:00
Niel Nielsen 12284d5f71 Fix: emv scan truncation 2026-04-08 12:36:12 +02:00
Niel Nielsen e4dca3fcc4 align with RRG 2026-04-07 10:57:08 +02:00
Niel Nielsen 350a774d7c align with RRG 2026-04-07 10:47:41 +02:00
Niel Nielsen e16505e6a7 FEAT! Add T55 write commands 2026-04-07 10:36:06 +02:00
Niel Nielsen a3d3c1fc34 Remove conditional compilation for PROJECT_CHAMELEON_ULTRA 2026-04-07 10:29:12 +02:00
Niel Nielsen fcf0c31ca5 Fix syntax error in app_cmd.c 2026-04-07 10:29:12 +02:00
Niel Nielsen 9183ac40e4 Add PROJECT_CHAMELEON_ULTRA specific commands 2026-04-07 10:28:51 +02:00
Niel Nielsen c7e038cc61 Remove duplicate rc522.h include
Removed duplicate rc522.h include and adjusted spacing.
2026-04-07 10:25:13 +02:00
Niel Nielsen efa2ea2c7b protocol ISO 14443-4 and emv scan, loading json file from PM3rdv4 2026-04-07 10:23:58 +02:00
Kevin Yuan eddbb31c05 Merge branch 'main' into pac-emulation 2026-04-06 16:43:41 +01:00
GameTec-live a4b11e441a Merge pull request #388 from taichunmin/usb-serial-number
Fix firmware application USB serial number
2026-04-04 20:09:59 +02:00
Kevin Yuan 3924ad134b Merge branch 'main' into pac-emulation 2026-04-02 14:17:42 +01:00
Niel Nielsen 29c407464b fix: make each PR self-contained with all required source files 2026-04-02 08:14:18 +02:00
Niel Nielsen 0b6bb28fc1 fix(data): guard Ultra-only includes and processors for Lite build 2026-04-02 08:07:15 +02:00
Niel Nielsen ce932d2e8a feat(data): add LF capture analysis commands 2026-04-02 07:43:16 +02:00
Daniel Wagner a421e99648 request hfxo 2026-03-30 15:37:29 +01:00
Kevin Yuan 9e58461f9a Potential fix: Compare glitch in PWM module 2026-03-24 17:04:18 +00:00
Kevin Yuan f5d721bbfd PAC/Stanley CLI: replace --id with --cn/--raw (PM3 parity)
Split the single --id argument into --cn (8 ASCII chars) and --raw
(32 hex char T55XX bitstream, directly compatible with PM3 raw output).
Add Python-side PAC bitstream encoder/decoder for raw format support.
Output now shows CN and Raw labels matching PM3's format.

Add NRF_LOG module registration to pac.c for debug logging,
consistent with other protocol implementations.

Reassign PAC command IDs (3014/3015) to avoid collision with ioProx
(3010/3011) after rebase onto upstream/main.
2026-03-24 15:04:41 +00:00
Kevin Yuan ccf4510c1c Improve PAC/Stanley NRZ reader reliability
Three fixes that together bring rapid-fire read reliability from ~20%
to 100%:

- Add MIN_SPIKE_CAP floor (8000) to prevent spike_cap from clipping
  NRZ high when prescan correctly captures NRZ low. Without this,
  spike_cap = raw_min*3 ≈ 2820 collapses the signal range.

- Reorder carrier-before-SAADC in pac_read(): start the 125kHz field
  and wait 10ms before enabling ADC sampling, so prescan calibration
  sees real NRZ signal levels rather than T55XX power-on-reset noise.

- Add auto-recalibration: if no valid frame is found after 20480
  Phase 3 samples (~164ms, ~5 frame periods), reset the decoder to
  Phase 1 and re-calibrate from fresh samples. This gives ~3
  calibration attempts per 500ms scan window instead of just one.

Tested with Proxmark3 sim (15 consecutive rapid-fire reads, 100%) and
T55XX tag (write-read roundtrip + 15x rapid-fire, 100%).
2026-03-24 14:38:46 +00:00
Kevin Yuan 8442bea4c1 Add PAC/Stanley T55XX write support
Add pac_t55xx_writer() for encoding PAC card data into T55XX blocks,
along with the T5577_PAC_CONFIG (NRZ/Direct, RF/32, password-protected,
4 data blocks). Wire DATA_CMD_PAC_WRITE_TO_T55XX (3011) through the
command processor, dispatch table, and Python client.
2026-03-24 14:38:46 +00:00
Kevin Yuan 17ff2abf60 Replace moving average with PM3-style per-sample thresholding and fix integer overflows
Replace the 32-sample moving average + hysteresis demodulation with
Proxmark3-inspired per-sample thresholding and dead zone. This
eliminates ~16 samples of group delay per edge, reducing timing
jitter from ~11 samples to ~2-3 samples.

The new approach:
- Prescan: track raw_min, compute spike_cap (unchanged)
- Warmup: track min/max of clipped samples directly (not averaged)
- Detection: per-sample dead zone classification — sample >= high
  threshold → 1, sample <= low threshold → 0, between → keep
  previous state. Thresholds set at 75% fuzz of signal range.

Removes the avg_buf[32] circular buffer, avg_sum, avg_idx, and
sum-unit threshold/hysteresis state. Struct is 72 bytes smaller.

Widen integer types to prevent overflow UB:
- sample_count: uint16_t -> uint32_t (overflows at 524ms)
- interval, nbits: uint16_t -> uint32_t (matching sample_count width)
2026-03-24 14:38:46 +00:00
Kevin Yuan 2fd1a260cf Add PAC/Stanley LF tag emulation support
Implements NRZ/Direct modulation at RF/32 for PAC/Stanley tag emulation.
The modulator encodes 8-byte ASCII card IDs into 128-bit NRZ frames
(0xFF sync + 12 UART frames) and generates PWM waveforms using constant
output levels (compare=counter_top for HIGH, compare=0 for LOW).

Firmware: modulator in pac.c, load/save/factory callbacks in lf_tag_em,
tag_emulation registration, SET/GET_EMU_ID commands (5006/5007).
CLI: pac_set/get_emu_id methods, 'lf pac econfig' command, hw slot list
display for PAC tags.
2026-03-24 14:38:46 +00:00