rkf_tcas_t has a padding byte before mac (offset 31). rkf_read_tcas()
set every field but left that byte, and both the TCAS instance check
in hf mf view and its selftest compare the two instances with memcmp.
The result depended on stack contents: the Makefile client passed, the
CMake client failed "tcas instances equal". Since 6fbe96e18 the CI
greps the aggregate Transit selftest line, so every cmake test job
(ubuntu, macos, wsl, proxspace) failed.
Zero the whole struct in rkf_read_tcas().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The upload used its own printf "\rProgress: [n%]" line, without the
client prefix, spinner or emoji. Print it with PrintAndLogEx(INPLACE),
in the same format as the spiffs upload, and drop the unused helper.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The progress line was printed once per chunk, about 55 lines for a PM5
bitstream. Print it in place and end the line once the transfer is done.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Probing every identifying key of every transit sector, A and B, took up to
12 key check calls / 44 authentications, most of the time being the 50 ms
field power up per call.
Stage 1 now checks one signature per parser, key A only, one call per
sector (sectors 0, 4, 7, 8). Signatures are A or A/B keys, so key A holds
one of them on a real card. Only when a signature matches does stage 2
check that parser's remaining keys. Sector 0 is skipped when info already
found its key A.
Foreign card: 3-4 calls instead of 8-12, roughly 0.3 s instead of 0.7-1.2 s.
The probe lives in parsetransit.c behind a key check callback, the self
tests drive it with a dump and pin the call counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
client/resources/PM5_FPGA_fix_loedge_bug.bin was a Gowin IDE build
posted in #3449 on 2026-08-15, before the FPGA sources were opened in
#3697. Its lo_edge_detect fix (adc_clk = pck0) has been in the sources
since 7666e8444, so the shipped binary only lagged behind them and
could not be checked against anything in the tree.
Add `make -C fpga fpga_pm5_release`, which builds fpga_pm5.bin and
copies it with its sha512 to client/resources. It stays out of `all`
so a local test build does not replace the shipped image by accident.
Point update_fpga.cmd and update_fpga_and_bwm.cmd at fpga_pm5.bin and
document the build in Getting_Started_With_PM5.md.
The image was built with oss-cad-suite 2026-10-11, the release pinned
in fpga-pm5.yml. A clean rebuild gives the same bytes, IDCODE is
0x1100381B, and all clocks meet timing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T-Mobilitat historical bytes tag is all info has without reading the
application list, so the line says "Possible" and hints `hf mfdes info`,
which confirms it by AID and prints the card number. No card exchange
added; `hf search` gets it through the same code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same "Transit.......... <name> ( <region> )" line as the other info
commands, from the ticketing environment before the records are read.
No hint, info already runs the full decode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only on 512 bit SRx / ST25TB tags, where Intertic tickets live. The
whole tag is 16 blocks plus the system block, so info reads all 17 and
runs the ST25TB transit parsers on them, the same data `hf 14b dump`
decodes. Detection is a layout check, so the line says "Possible".
4K tags are left alone. Hints `hf 14b dump`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Names Japan IC (system 0003), Octopus (8008) and Shenzhen Tong (8005)
from the system codes info already discovers, no extra card exchange.
Hints `hf felica dump`, which reads the public services and decodes
balance and history. `hf felica reader` only polls for the IDm and is
left alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fingerprint read now covers at least pages 0..15, two more page
reads inside the same READCARD exchange and no extra round trip. That is
all the Troika Ultralight, TRT and Ventra parsers use, so a match is
decoded in full right there. Their detection is a layout check, so the
line says "Possible". Hints `hf mfu dump`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Identifies MIFARE Classic transit cards by their sector keys and MAD
block 1. Keys info already found for sectors 0 and 1 are reused. Every
other sector a parser identifies by (0, 1, 4, 5, 7, 8 today) gets one
`mf_check_keys` exchange per key type carrying only that sector's
candidate keys, and no key B check once key A is known. Worst case is
12 exchanges and about 45 authentications, typically fewer. Block 1 is
read with the sector 0 key info found, for Nextfare and Zolotaya Korona.
Prints "Transit.........." in the Fingerprint section and hints
`hf mf autopwn`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Names the card system from the AID list info already reads (Clipper,
ITSO, myki, nol, Opal, T-Mobilitat with its ATS), then reads the free
files the matching parser decodes card number and balance from and runs
the parser on that partial image, like the HRT parser already does here.
Adds one select plus a settings and a read exchange per summary file,
only on an identified card. Hints `hf mfdes dump --no-auth` for the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each card system can now be named from the partial data an info command
already has: sector keys and MAD block 1 for MIFARE Classic, the
application list and ATS for DESFire, system codes for FeliCa, and the
same data a dump has for Ultralight, ST25TB and Calypso.
Dispatch rows gain a display name, region, decode hint and identify
entry. Detection is shared, not duplicated: the MFC key checks become
key sets matched against either a dump or the keys an info probe found,
the DESFire checks run over an application list built from the dump.
transit_mfdes_summary_files() lists the free files a parser decodes card
number and balance from. Every identify path has a positive and a
negative selftest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EmGetCmdTimeout() calls AdcSetupRssiChannel() before every listen. On
AT32 that resets the ADC, waits for ready, runs both calibration phases
and a blocking 640.5 cycle vref conversion, all before Uart14aInit and
before the SSC is read. The single byte SPI4 buffer overruns meanwhile,
so a reader frame sent close to the minimum FDT loses its start. Hardware
paced frames like the MIFARE auth nR/aR hit this; host paced activation
frames do not. The Miller decoder then syncs mid frame and logs short
fragments with parity errors.
Keep the full setup for the first call or a channel change. Otherwise
clear a stale conversion flag and restart the conversion. A dropped ADC
(RDY clear) still takes the full path. RDV4 is unaffected.
Reported in #3768.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring the SAM commands to parity with Seader's (bettse/seader, GPLv3)
read and save options:
- hf mf sam: MIFARE Classic SE via CMD_HF_SAM_MFC
- hf mfdes sam: DESFire EV1/EV2 via CMD_HF_SAM_SEOS, as Seader drives it
- --dg legacy|sr|prox|mfc and --save on hf iclass / seos / mf / mfdes sam
- wiegand downgrade: the same outputs offline, from a saved credential
or PACS bits, plus --selftest
Outputs follow seader_credential.c:
- legacy / sr: 20 block iCLASS dump, Seader's config, epurse, Kd from the
HID standard key, block 6 03030303 0003E014 (A3 for SR, PACS left
unencrypted), PACS in block 7, SR SIO in blocks 10-17. A CSN read from
iCLASS is kept, anything else gets Seader's fake CSN 7AF53113FEFF12E0.
- mfc: 1K dump with Seader's block 0, MAD, HID sector 1 keys and PACS in
block 5, the layout hf mf encodehid writes.
- prox: lf hid clone --bin, and -w H10301 for 26 bits as Seader does.
- --save: a "hid credential" JSON with PACS, bits, UID, SIO, media type.
The PACS parsing hf iclass sam and hf seos sam each had a copy of moves
to hidsio.c; hf seos sam is now the shared ISO14443-A command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HID stores PACS bits behind a sentinel bit, right aligned, both in iCLASS
block 7 and in MIFARE Classic block 5. Move hf mf encodehid's packing
into wiegand_pack_sentinel_bytes() so the SAM downgrades reuse it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sam_mfc.c was empty and CMD_HF_SAM_MFC was a no-op. Implement the relay
the way Seader's plugin_hf_mfc_transmit does it. The SAM runs Crypto1
itself and tags each nfcSend with a format:
- 00 C0 00: plain bytes, CRC already included, parity generated
- 00 00 40 / 24 / 44: air order bit stream carrying the SAM's own parity
Answers to the latter go back in the same bit form, len + len / 8 + 1
bytes like Seader. Unlike Seader, every byte gets its real parity bit;
Seader leaves bytes 8 and on at zero. A silent card is reported to the
SAM as rfStatus 00 20, an unknown format as 00 04, Seader's codes, and
the conversation continues.
Card detected follows Seader for MIFARE Classic: protocol, CSN and SAK,
no ATQA. The card is selected without RATS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seader keeps the SIO it sees on the air while the SAM reads a card, which
is what lets it write an iCLASS SR downgrade. Do the same:
- iCLASS: READ / READ4 answers from block 6 on are kept; the SIO is the
lowest captured block holding a SEQUENCE whose DER length is covered by
contiguous captured blocks (so a legacy block 7 that happens to start
with 0x30 is not taken for it).
- DESFire: the ReadData of file 0x0F Seader keys on, plus 91 AF
continuations (Seader only keeps the first frame).
A new request flag (bit 7 for CMD_HF_SAM_PICOPASS, bit 2 for
CMD_HF_SAM_SEOS) asks for a sam_ext_reply_hdr_t ahead of the SAM
response. It is only sent for a plain PACS request, so -d, --info and
--break replies are unchanged. The capture lives in .bss and the reply
is built in BigBuf to keep the RDV4 stack untouched.
Also from Seader: a DESFire EV2 answers the Seos select with a 6F 22 85 20
FCI. Hide it from the SAM as 6A 82 and add Le to the DESFire select.
sam_set_card_detected_seos() moves to sam_common.c as
sam_set_card_detected_iso14a() so the MIFARE Classic path can share it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A HID SAM driving MIFARE Classic hands over Crypto1 frames as one bit
stream: each byte's 8 data bits LSB first followed by its parity bit.
These convert between that stream and the bytes plus parity array the
PM3 reader and trace code use. Shared so the client can self test them.
Cross checked against a port of Seader's plugin_hf_mfc_transmit for
frames up to 8 bytes (its limit) and for 4 and 18 byte answers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run from hf calypso info. parsecalypso.c is a table driven EN 1545 walker
(fixed fields, presence bitmaps, repeated containers) after Metrodroid's
En1545Parser, shared by the network parsers:
Navigo (Paris, 250901) Metrodroid transit/intercode
Intercode, other 250xxx Metrodroid transit/intercode
Opus (Montreal, 124001) Metrodroid transit/opus
Rav-Kav (Israel, 376xxx) Metrodroid transit/ravkav
hf calypso info additionally hands over the ICC record, so Intercode and
Opus print the card number as issued, reads the second contracts file
(SFI 06) after a full first one, and reads the per contract counters at
SFI 0A..0D, where Rav-Kav keeps its stored value.
Holder data is deliberately not decoded. Self tests are synthetic,
neither Metrodroid nor Metroflip ships real record hex for these.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FeliCa parsers run from hf felica dump over the services it read without
authentication:
Japan IC (Suica, PASMO, ICOCA, ...) Metrodroid transit/suica
issuer named from its service codes
Octopus, Shenzhen Tong Metrodroid transit/octopus
The dump adapter now keeps locked services in the list, without blocks,
since the Japan IC issuer naming depends on them.
ST25TB parser, run from hf 14b view / dump on SRT512:
Intertic (French networks) pyscripts/intertic.py, Metroflip
Self tests: Metrodroid SuicaTest service sets and OctopusTest balances,
synthetic history blocks and Intertic tickets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESFire parsers run from hf mfdes view / dump and are detected by AID.
They decode the free-read files; `hf mfdes dump --no-auth` is what reads
those, and a parser says so when a file it needs is missing. Locked
balance/trip files (myki, nol, T-Mobilitat) need operator keys and are
only named.
Clipper (SF Bay) Metrodroid, Flipper clipper.c
Opal (Sydney) Metrodroid
myki (Melbourne) Metrodroid, card number only
ITSO (UK) Flipper itso.c
nol (Dubai) Metrodroid, Metroflip
T-Mobilitat Metroflip, number from ATS historical bytes
Ultralight parsers run from hf mfu view / dump:
TRT Flipper trt.c
Ventra (Chicago) Flipper ventra.c, Metrodroid Nextfare UL
Self tests: Metrodroid ClipperTest, MykiTest, OpalTest plus the real
opal-transit-litter dump matched against Metrodroid's parsed output;
synthetic for the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run from hf mf view / dump / autopwn on the full dump. Detection is by
sector keys plus a data signature, as Metrodroid and Flipper do it, so
a dump needs the real keys in its trailers.
Bip! (Santiago) Metrodroid ChileBip, Flipper bip.c
CharlieCard (Boston) Metrodroid, Flipper charliecard.c
Kazan Metrodroid, Flipper kazan.c
Metromoney (Tbilisi) Metrodroid, Flipper metromoney.c
Nextfare: Go card (Brisbane), TAP (LA), Go-To (Minneapolis)
Metrodroid Nextfare/SeqGo/LaxTap/MspGoto
Podorozhnik / Plantain Metrodroid, Flipper plantain.c
RENFE Suma 10 Metroflip renfe_sum10.c, partial
SmartRider (Perth), MyWay Metrodroid
Troika, MFC and Ultralight Metrodroid, Flipper troika.c
Umarsh Metrodroid, Flipper umarsh.c
Zolotaya Korona Metrodroid
Two Cities cards match both Troika and Podorozhnik, each printing its own
half. Self tests use the Metrodroid vectors where they exist (Troika UL
asset, Nextfare, a SmartRider timestamp) and synthetic dumps otherwise.
parsetransitmfc.h holds the shared sector/key accessors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds parsers/parsetransit.{c,h}: MSB/LSB bit readers and writers, date,
datetime and money formatting, one print style for every card system,
and a dispatcher per technology that runs each registered parser whose
detection matches. The tables start empty, card systems follow.
Hook points, each run on data the command already has:
hf mf view / hf mf dump / hf mf autopwn -> transit_mfc_parse
hf mfdes view / hf mfdes dump -> transit_mfdes_parse
hf mfu view / hf mfu dump -> transit_mfu_parse
hf 14b view / dump (SRx) -> transit_st25tb_parse
hf felica dump -> transit_felica_parse
hf calypso info -> transit_calypso_parse
hf calypso info now also reads the contract list, counters, contracts
and events by SFI for the Calypso parsers. Self tests hang off the same
commands via --selftest; hf mfu view gains that flag, hf felica dump and
hf calypso info gain it and become always available so it runs offline,
with an explicit device check for the real path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New client command for VivoKey Thermo / Temptress style implants. The
NTAG 5 link (NTP5332) is used as I2C master: energy harvesting is enabled
through the EH_CONFIG_REG session register (AN12365), the TI sensor is
driven with WRITE I2C / READ I2C / READ SRAM and the I2C master status
register is polled for completion and NAKs. Sensors at 0x48-0x4B are
probed and identified by the TMP117/TMP119 device id register, a one-shot
conversion is triggered and the result printed in C and F.
Pure client side, uses CMD_HF_ISO15693_COMMAND with the field kept on.
Offline self test for the conversions is hooked into pm3_tests.sh, and
hf 15 info hints at the command for NTAG 5 tags.
Not tested on hardware, no implant available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New `hf goodisplay load` for the NFC-D1 tags GDEY0154D67, GDEY0213B74,
GDEY029T94 and GDEY037T03. They use a Fudan FM1280 talking ISO14443-4
with proprietary CLA F0 APDUs (config F0 DB/DA, image F0 D2 in 250 byte
chained blocks, refresh F0 D4), unlike the raw 14a CD xx frames of
Waveshare tags, hence a separate command family. Protocol and init
sequence from the Flipper Zero NFC Eink app (GPLv3, RebornedBrain).
Image load/crop/dither, save and 1bpp packing move from cmdhfwaveshare.c
into imgutils.c so both commands share them. Waveshare output is
unchanged.
hf 14a info hints at hf waveshare for its known UIDs (now incl. FSTN11m)
and at hf goodisplay for a SAK 28 ATS 0B 78 33 A0 02 90 <UID> 00 tag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 2.7" panel is 176x264: the send loop pushes 48 x 121 = 5808 bytes,
so with 276 rows the bottom 12 rows of the image were silently dropped.
map8to1() stored a partial last byte before the final shift, leaving its
pixels right-aligned. On the 122 px wide 2.13" the last two columns were
drawn at off-panel columns 126/127. MSB-align the partial byte instead.
Byte-aligned widths are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DemodPCF7931 called DoAcquisition with sample_size 0 and no trigger, so
every capture filled all of BigBuf and only the button could stop it:
~1s on RDV4 (~32 KB), ~13s on PM5 (~405 KB). The decoder then stored
every whole block into an 8-entry stack array and copied them into
ReadPCF7931's 4-entry buffer, both unbounded - a PM5 capture holds ~190.
Capture 4.5 blocks (~0.3s on every platform), decode only the samples
taken and stop storing at the 4 blocks the caller has room for.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compares the version the ESP reports with the image's app descriptor
version (esp_app_desc_t at 0x20). The ESP may report only the git hash,
so "<hash>" matches "V1-12-g<hash>". Prints "unknown ( n/a )" when the
module doesn't answer, instead of no line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MFU-C AUTH and iCLASS READCHECK skipped the next record before checking
it was the tag's reply. With an unanswered command, the reader's next
frame was swallowed: a retried 1A 00 lost the whole MFU-C auth, and a
CHECK right after READCHECK was taken as the epurse, hiding the lookup.
Now the record is only consumed when it is a tag frame of the expected
shape.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
.data shared the bootphase2 output section with the RAM-executed code, so
the PM5 bootrom linked with "LOAD segment with RWX permissions" (CMake
silenced it with --no-warn-rwx-segments). Put .data in .bootphase2_data
with its own PT_LOAD, placed right after .bootphase2 in RAM and flash so
the existing copy loop still covers it; asserts guard the contiguity.
Same image size on RDV4/PM5/PM5+BWM; code identical bar .ramfunc moving
ahead of .data, data bytes unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
common_arm/Makefile.hal already includes it, so a direct "make -C bootrom"
appended the standalone define twice and stopped with "You must choose only
one Standalone mode!: LF_SAMYRUN LF_SAMYRUN". Matches armsrc/Makefile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v is unsigned long; PRIu64 is "llu" on macOS, so clang fails the build
with the PrintAndLogEx format attribute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 4-byte packing loop read up to 3 bytes beyond src when length was not
a multiple of 4 (ASan heap-buffer-overflow in data test_ss8). Pack byte by
byte into the zeroed backing buffer instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
save_buffer8/32/S32 allocate a backing buffer that the self tests never
released. Found by cppcheck 2.22 follow-up, confirmed with LeakSanitizer
(696 bytes in 3 allocations per run of the three tests).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
size_t printed with %lu/%ld/PRIu64 and uint64_t with %lu are correct on
64-bit Linux/macOS only; with the new format attribute they fail -Werror
builds on 32-bit hosts (RPi, 32-bit Windows), and %lu for uint64_t also on
64-bit Windows. unsigned long printed with PRIu64 likewise.
Found by a 32-bit (arm-none-eabi) syntax-only pass over the client.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>