Files
proxmark3/armsrc
Antiklesys 0ffe244a6b Fix for circular buffer error during hf iclass sim
Issue origin:
Commit 6b7665ed5 "Added live fc/cn update to hf iclass tagsim" added a data_available() poll inside the per-byte DMA loop of GetIso15693CommandFromReader so the ARM could drop out of RF-listen and process live emulator updates.

Before that commit, that tight loop had no USB poll at all — only gotFrame / BUTTON_PRESS / WDT_HIT. Verified via git show 6b7665ed5^:armsrc/iso15693.c.

Why it shows up on sim -t 3/6/7: those are the FULL sim modes that share do_iclass_simulation. Between reader commands the decoder sits in STATE_READER_UNSYNCD, so the gated poll at iso15693.c:1570-1575 fires every byte (reading UDP peripheral registers). With DMA filling at ~1 byte / ~19 µs, the added USB register reads plus jitter occasionally push the CPU past the 90% lag threshold → behindBy 461 with DMA_BUFFER_SIZE=512.

Commit fb8f94fa2 narrowed the gate to UNSYNCD to stop mid-frame exits, but the per-byte poll itself is still what's new on that path.

Fix:

New mode constant in include/iclass_cmd.h:

#define ICLASS_SIM_MODE_FULL_LIVE  8  // FULL + allow USB interrupt for live emul updates
Treat it identically to ICLASS_SIM_MODE_FULL everywhere except for the poll gate.

Add a flag param to GetIso15693CommandFromReader — e.g. bool allow_usb_interrupt in iso15693.c:1495 and iso15693.h:42. Wrap the poll:

if (allow_usb_interrupt &&
    (dr->state == STATE_READER_UNSYNCD ||
     dr->state == STATE_READER_AWAIT_1ST_FALLING_EDGE_OF_SOF) &&
     data_available()) { ... }
Pass true only for live mode in do_iclass_simulation iclass.c:502:

bool live = (simulationMode == ICLASS_SIM_MODE_FULL_LIVE);
len = GetIso15693CommandFromReader(receivedCmd, MAX_FRAME_SIZE, &reader_eof_time, live);
The len == -2 drain block stays but becomes dead code for non-live modes (never returns -2).

Client side: cmdhficlass.c:1687 (CmdHFiClassTagSim) sends ICLASS_SIM_MODE_FULL_LIVE. CmdHFiClassSim -t 3/6/7 keeps sending ICLASS_SIM_MODE_FULL / _GLITCH / _GLITCH_KEY.

Other callers (iso15693.c:2270, iclass.c:1121 = reader-attack sim) pass false.

Result:

hf iclass sim -t 3/6/7 → byte-inner loop is back to its pre-tagsim shape → no blow-buffer abort.
hf iclass tagsim → keeps live update ability; still has the overhead, but that's the trade-off the feature needs.
2026-04-17 03:00:14 +08:00
..
…
2026-04-13 09:35:02 +02:00
2026-04-13 09:35:02 +02:00
2026-03-31 12:02:23 +03:00
2025-12-21 02:58:56 -07:00
2025-12-21 00:34:11 -07:00
2026-03-24 14:21:54 +07:00
2024-10-04 23:25:15 +08:00
2024-05-14 12:32:57 +02:00
…
2025-03-16 01:05:55 -07:00
2025-03-21 11:25:31 +01:00
2026-03-29 09:38:09 +07:00
…
2026-03-24 11:13:48 +07:00
…
2026-03-31 12:02:23 +03:00
2026-02-06 13:43:41 +01:00
…
…
…
…
2024-05-27 20:29:02 +02:00
2024-08-22 02:01:43 +08:00
2025-03-19 11:26:25 +01:00
2026-04-07 08:08:36 +07:00
2024-11-21 19:23:03 +00:00
2025-09-12 22:00:46 +02:00
2025-06-12 19:42:56 +08:00
2026-04-04 17:15:13 -04:00
2026-04-13 09:35:02 +02:00
…
2024-02-02 20:51:56 +01:00
2025-06-11 18:14:19 +02:00
…
2025-09-12 22:00:46 +02:00
…
…
2026-03-25 19:10:59 +07:00
2026-03-25 12:49:43 +07:00
2025-09-12 22:00:46 +02:00
2025-09-12 22:00:46 +02:00
2026-04-13 09:35:02 +02:00
…
…
2024-05-14 10:10:44 +02:00
2025-03-18 08:11:06 +01:00
2025-03-18 08:11:06 +01:00
2025-03-25 10:12:16 +01:00
…
2025-06-11 01:06:38 +08:00
2025-06-11 01:06:38 +08:00
2026-04-13 09:35:02 +02:00
2026-04-13 09:35:02 +02:00
2026-04-13 09:35:02 +02:00
2025-12-21 04:26:44 -07:00
2025-01-14 18:01:09 -08:00
2025-01-14 18:01:09 -08:00
…
…
2025-04-21 23:17:47 +10:00
2025-04-21 23:17:47 +10:00
2024-09-18 18:10:53 +08:00
2024-09-19 19:14:23 +08:00
…
…
…
…