em4x50: fix listen window sync, add runtime reader timings

Every bidirectional EM4x50 command (rdbl, info, dump, lf search) failed
on a PM3 Easy with a 500 uH antenna, while `lf em 4x50 reader` worked.
A raw ADC capture of the exchange showed RM being sent into the tag data
right after the double listen window: find_em4x50_tag() consumes the
first window, the second one is then taken as the first, and
invalid_bit() cannot reject data because its single 3/4-bit sample of
the AC-coupled, saturating signal always sits between g_Low and g_High.

- detect the second listen window by the absence of a rising edge over
  its 128-cycle low phase (Manchester data has one per bit)
- `lf em 4x50 config` (CMD_LF_EM4X50_CONFIG): threshold, pulse
  tolerance, "0" bit gap start/end and RM delay, changeable at runtime
- defaults moved to the centres of the working ranges measured with the
  new lf_em4x50_tune.lua sweep: tol 10 (5-15), gap end 38 (28-50),
  rm 132 (104-164); the old gap end 32 was 4 cycles from failing
- rdbl/info retry the login + selective read for up to 1 s
- at debug level extended the whole exchange is captured into BigBuf,
  fetch it with `data samples`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abou28andClaude Opus 5.5 committed 2026-11-05 11:51:59 +01:00
1 parent 1b71dfbbd4
commit 0f777089a4
10 files changed
+470 -47

No files matched your search

+22 -1
View File
@@ -12162,6 +12162,27 @@
],
"usage": "lf em 4x50 chk [-h] [-f <fn>]"
},
"lf em 4x50 config": {
"command": "lf em 4x50 config",
"description": "Get or set the reader timings used by EM4x50 commands, in carrier cycles. Settings are lost when the device restarts.",
"notes": [
"lf em 4x50 config -> show current settings",
"lf em 4x50 config --rm 136 -> send RM 136 cycles after the listen window",
"lf em 4x50 config --gs 4 --ge 28 -> field gap of a \"0\" bit from cycle 4 to 28",
"lf em 4x50 config -d -> restore defaults"
],
"offline": false,
"options": [
"-h, --help This help",
"-d, --default restore default settings",
"--thr <1-100> envelope threshold, percent of amplitude (def 75)",
"--tol <1-15> pulse length tolerance (def 10)",
"--gs <0-62> field gap start in a \"0\" bit (def 7)",
"--ge <1-63> field gap end in a \"0\" bit (def 38)",
"--rm <1-320> RM start after the first listen window (def 132)"
],
"usage": "lf em 4x50 config [-hd] [--thr <1-100>] [--tol <1-15>] [--gs <0-62>] [--ge <1-63>] [--rm <1-320>]"
},
"lf em 4x50 dump": {
"command": "lf em 4x50 dump",
"description": "Reads all blocks/words from EM4x50 tag and saves dump in (bin/json) format",
@@ -16810,7 +16831,7 @@
}
},
"metadata": {
"commands_extracted": 936,
"commands_extracted": 937,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2026-10-23T22:15:17+00:00"
}
+1
View File
@@ -1191,6 +1191,7 @@ Check column "offline" for their availability.
|`lf em 4x50 help `|Y |`This help`
|`lf em 4x50 brute `|N |`Bruteforce attack to find password`
|`lf em 4x50 chk `|N |`Check passwords`
|`lf em 4x50 config `|N |`Get/set reader timings`
|`lf em 4x50 dump `|N |`Dump EM4x50 tag`
|`lf em 4x50 info `|N |`Tag information`
|`lf em 4x50 login `|N |`Login into EM4x50 tag`