nfc_tag_14a_unwrap_frame() computes the de-parity'd data-bit count in a size_t
but returns uint8_t. For any received frame of 32 bytes or more the data-bit
count exceeds 255, so the uint8_t return wraps it modulo 256, silently
truncating the frame the caller (nfc_tag_14a_data_process) then processes.
Concretely a 44-byte reader->tag command is 352 data bits; 352 & 0xFF = 96 bits
= 12 bytes, so only the first 12 bytes reach the tag/APDU layer. This breaks any
ISO14443-4 (T=CL) tag emulation that receives a command of 32+ bytes -- e.g. an
EMV GET PROCESSING OPTIONS carrying a full PDOL, where the card then answers
6700 (wrong length).
Verified on nRF52840 hardware: the NFCT RXD.AMOUNT register reports the correct
length at every frame size (396 for a 44-byte frame); only the truncated return
value was wrong. Changing the return type to uint16_t makes large commands
arrive intact.
Reproduced deterministically by having one Chameleon (RC522 reader) send
commands of increasing size to another (NFCT emulator): received length was
(frame length mod 32) before the fix, full length after.
The FSK demod (fsk_feed) ran the Goertzel tone detection directly on the
raw ADC samples. Their large DC offset leaks into the fc/8 bin and biases
every decision toward bit 0; on a weakly-coupled card the AC signal is too
small to overcome it, so the whole bitstream collapses to zeros and nothing
decodes. Strong signals overrode the bias, which is why this went unnoticed.
Adds an opt-in running DC baseline tracker to the demod (fsk_t.dc_block):
a slow per-sample IIR estimate (~64-sample time constant) subtracted before
the Goertzel. Unlike a per-window mean it doesn't distort fc/8's non-integer
cycle count. Enabled for the HID Prox and ioProx modems.
Validated on hardware (HID H10301, FC 12 / CN 3456 on a T55xx clone):
- well coupled (std 25): stock reads; with fix 5/5
- weak coupled (std 15): stock fails 4/4; with fix 4/5 correct
- very weak (std 11): stock fails; with fix reads (occasional
misread — HID 26-bit has only parity, no CRC, so marginal bit errors can
pass; this is an HID format limitation, not introduced here)
ioProx uses the identical demod path; enabled by analogy (no card to test).
The same dc_block path is reused by the Farpointe/Pyramid reader, which is
stacked on top of this commit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds full Farpointe/Pyramid (FSK2a, RF/50, 128-bit frame) LF support to
the Chameleon Ultra firmware: emulation, reading/decoding, and the
T55x7-equivalent on-air frame handling.
Emulation (modulator):
- New protocols/pyramid.c/.h replays the raw 128-bit frame. FSK2a needs
exact RF/50 bit-period alignment (unlike HID/ioProx which emit a fixed
integer cycle count per bit): the 15-bit all-fc/8 preamble run drifts
if each bit is a fixed 6 cycles (48 ticks) instead of 50, dropping a
preamble bit so fixed-clock readers fail. A phase accumulator keeps
every bit boundary on its exact (i+1)*50-tick mark.
- TAG_TYPE_FARPOINTE_PYRAMID registered in tag_base_type.h /
tag_emulation.c, with load/save/factory callbacks in lf_tag_em.c.
Reader (decoder):
- Streaming FSK demod -> 256-bit ring -> scan for the 24-bit preamble,
then triple-gate a candidate frame: 24-bit preamble + odd parity on
every 8-bit group + CRC-8/Maxim trailer. A read returns the raw 16-byte
frame (same layout as emulation, so a read can be written to a slot).
- lf_pyramid_data.c (pyramid_read), scan_pyramid in lf_reader_main, and
DATA_CMD_PYRAMID_SCAN (3021) in app_cmd.c.
Weak-coupling demod:
- The Pyramid tag couples poorly on this antenna, so reading relies on the
opt-in DC-block demod added in the preceding commit and enables it for
the Pyramid modem (pyramid.c, fsk_t.dc_block). Without it the raw 14-bit
SAADC DC offset leaks into the fc/8 Goertzel bin and pins every decision
to bit 0, so nothing decodes.
Build hygiene:
- Drop the temporary -Wno-error from application/Makefile and fix the
pre-existing unused-but-set 'blk_num' warning (newer GCC) so the tree
builds clean under -Werror again.
Validated on hardware against a physical Farpointe tag: emulation reads
back on Proxmark and `lf pyramid` reading decodes it (len 82, Card 11231,
Raw 0001014a3e0101010101014ae35e7f4f).
Note: tag type 202 and command 3021 are local IDs pending upstream
coordination.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The build targets the Cortex-M4F single-precision FPU (-mfpu=fpv4-sp-d16),
which has no double-precision hardware. goertzel_mag() used sqrt() (double):
the float result was promoted to double for the call and converted back, and
a software double-sqrt routine ran -- twice per decoded bit.
The bit decision only compares the two Goertzel outputs, and power is
monotonic with magnitude, so the sqrt is unnecessary. goertzel_power()
returns the squared magnitude and fsk_feed() compares that directly. This
also removes a latent sqrt(NaN): the magnitude argument can round slightly
negative near zero signal, which sqrt() turned into NaN (and NaN comparisons
make the bit decision unreliable); comparing the raw power is well-defined.
The old goertzel_mag() had no callers anywhere and was not declared in the
header, so it is removed rather than kept.
Shared by all FSK readers (HID Prox, ioProx, Pyramid): bit decisions are
identical, the soft-float double dependency is gone, and the time-sensitive
demod loop is slightly faster.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep SCAN(3019)/WRITE(3020) adjacent, matching the SCAN+WRITE
adjacency convention used by every other LF protocol
(EM410X 3000/3001, HIDPROX 3002/3003, VIKING 3004/3005,
IOPROX 3010/3011, PAC 3014/3015). Slot 3017 is now free for
future use.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolved conflicts from upstream feature additions (IDTECK PR #407,
LF_T55XX_WRITE PR #413, ISO14443-4 T=CL emulation, HF14A scan-keep,
etc.) by keeping both sides where independent.
Command ID note for reviewer:
- Maintainer's IDTECK shift commit (1e78976) stated "Jablotron retains
the original slots 3016 and 3017", but upstream had already taken
3016 for DATA_CMD_LF_T55XX_WRITE. Only 3017 was actually free.
- Resolution: JABLOTRON_WRITE_TO_T55XX kept at 3017 (honors intent).
JABLOTRON_SCAN moved 3016 -> 3019 (next free slot).
- 5xxx range: JABLOTRON_SET/GET_EMU_ID = 5010/5011 unchanged
(IDTECK shifted to 5012/5013 as planned).
Python files parse cleanly. No duplicate command IDs in data_cmd.h
(3xxx and 5xxx ranges checked).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.