From ff7766af77fbe9bb1379b25c1c7fa51c55f4c07f Mon Sep 17 00:00:00 2001 From: Matthew Carroll Date: Tue, 1 Sep 2026 23:54:34 -0700 Subject: [PATCH] lf t55xx: drop the psk3 candidates from detect because they can only misfire Both psk3 entries run the same demodulation as the psk2 entry beside them and differ only in the constant given to test(). test() accepts a word only when that word's own modulation field matches the constant, so the psk3 entry needs a recovered word whose field reads 3. Field 3 is 00011, so it needs two adjacent 1's. What this demodulation recovers is the data's rising edges, and a rising edge needs a 0 before the 1, so no two of them are ever adjacent. The words it produces can never carry field 3, and so the psk3 entries can never match the case they were written for. What they can do, however, is match on a demodulation error, and then detect names psk3 and a block 0 word the tag does not hold. psk3 is still reached, by ruling psk2 out from the broadcast period rather than by demodulating for it - see t55xx_psk3_resolve(). Tags that only these branches matched now read as psk2, or as undetected where no offset yields a plausible psk2 word, on the basis that a wrong answer is worse than none if nothing about it tells you it is wrong. Edited by a human. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 1 + client/src/cmdlft55xx.c | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c261fa87f..2ecfdaab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fixed `lf t55xx detect` - dropped the psk3 candidates, which run the same demodulation as the psk2 one beside them and so can never match a psk3 tag, only fire on demodulation errors (@mfcarroll) - Fixed `lf t55xx detect` - a psk3 tag read back as psk2 with a block 0 one bit out, and a freshly wiped psk2 tag was reported as psk3 on no evidence; the two are now reported as ambiguous where the waveform cannot separate them, and block 0 is narrowed using the subcarrier, the broadcast period and whether password mode is in use (@mfcarroll) - Added doc/md/PM5_Start_Here/Getting_Started_With_PM5.md now exists as a starting point for those who have their PM5 (@innocentbystanderproxmark) - Fixed `tools/ePassport` - the personal number read from the MRZ optional-data field showed a filler character where a space belonged, and a document number longer than nine characters left its overflow there (@pkilar) diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 6ae42664e..fc9fbd648 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -1202,7 +1202,9 @@ static void t55xx_psk_coherent(int fitclk, uint8_t clk, t55xx_conf_block_t *test if (n >= 32) { - for (int variant = 0; variant < 4 && *hits == before; variant++) { + // three variants, not four: inverting does not move a stream's + // transitions, so a fourth barely differed from variant 2 + for (int variant = 0; variant < 3 && *hits == before; variant++) { const bool inverted = ((variant & 1) != 0); @@ -1217,7 +1219,7 @@ static void t55xx_psk_coherent(int fitclk, uint8_t clk, t55xx_conf_block_t *test setDemodBuff(work, n, 0); setClockGrid((uint32_t)(got_clk + 0.5), got_phase); - static const uint8_t modes[4] = { DEMOD_PSK1, DEMOD_PSK1, DEMOD_PSK2, DEMOD_PSK3 }; + static const uint8_t modes[3] = { DEMOD_PSK1, DEMOD_PSK1, DEMOD_PSK2 }; int bitRate = 0; if (test(modes[variant], &tests[*hits].offset, &bitRate, clk, &tests[*hits].Q5) == false) { @@ -1776,20 +1778,13 @@ bool t55xxTryDetectModulationEx(uint8_t downlink_mode, bool print_config, uint32 ++hits; } } // inverse waves does not affect this demod - // PSK3 - needs a call to psk1TOpsk2. - if (PSKDemod(0, 0, 6, false) == PM3_SUCCESS) { - psk1TOpsk2(g_DemodBuffer, g_DemodBufferLen); - if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { - tests[hits].modulation = DEMOD_PSK3; - tests[hits].psk_carrier = t55xx_observed_psk_carrier(); - tests[hits].bitrate = bitRate; - tests[hits].inverted = false; - tests[hits].block0 = PackBits(tests[hits].offset, 32, g_DemodBuffer); - tests[hits].ST = false; - tests[hits].downlink_mode = downlink_mode; - ++hits; - } - } // inverse waves does not affect this demod + + // no psk3 candidate here on purpose: it would demodulate the same + // as psk2 and only differ in the test() constant, which wants two + // adjacent ones - and this demod recovers rising edges, which are + // never adjacent. psk3 is reached by ruling psk2 out instead, see + // t55xx_psk3_resolve() + //undo trim samples restore_bufferS32(saveState, g_GraphBuffer); g_GridOffset = saveState.offset;