stop an FPGA bitstream download from eating the emulator memory
FpgaDownloadAndGoEx() with keep_em false does BigBuf_free() plus
BigBuf_Clear_ext(): the emulator memory pointer is nulled and all of BigBuf is
zeroed. iso14443a_setup() calls that variant, and Mifare1ksim(),
SimulateIso14443aTagEx() and SimulateIso14443aTagAID() build their precompiled
anticollision responses in BigBuf first. CMD_HF_MIFARE_EML_MEMGET had it the
other way round - it downloaded, then read the memory it had just wiped, so
'hf mf eview' and 'hf mf esave' returned their own zeros after any lf hitag,
hf iclass or hf 15 command. A download already cached early-returns, so which
image the FPGA held decided whether any of this happened.
All five now call FpgaDownloadAndGo_keep_EM() before any BigBuf allocation.
Free-BigBuf floor at download time goes 16384 -> 20480 (ring plus the 4096 byte
emulator block); BigBuf measures 29084..31420 across all standalone configs on
RDV4 and 40120 on a PM3 Easy.
The sim paths also clear the trace before taking their modulation buffer -
BigBuf_malloc() refuses memory a stale trace holds, and MifareSimInit() ignored
the NULL, leaving prepare_tag_modulation() to memcpy 571 bytes over the vector
table at address 0.
'hf mf eload' now zeroes emulator memory device side: CMD_HF_MIFARE_EML_MEMSET
takes a flags byte, set on the first chunk only, so 'hf mf esetblk' and every
other partial write still touch only their own blocks. That byte is why
CAPABILITIES_VERSION goes 9 -> 10; mismatched client and firmware refuse to
connect rather than write everything one byte offset.
Reported in #2836, whose USB drop is separately addressed by bc289cf43.
Builds clean for PM3RDV4, PM5 and the client; astyle clean. Not yet verified on
hardware.
Co-Authored-By: Claude Opus 5 (1M context)
This commit is contained in:
1 parent
054fae4ac1
commit
4d7d49e089
11 files changed
+82
-16
No files matched your search
+4
-1
@@ -277,7 +277,10 @@ typedef struct {
|
||||
// PM5 can use this to inform which size they support oo.
|
||||
uint16_t max_cmd_data_size; // device side PM3_CMD_DATA_SIZE
|
||||
} PACKED capabilities_t;
|
||||
#define CAPABILITIES_VERSION 9
|
||||
// Bump this whenever a command payload changes shape, so a mismatched client and
|
||||
// firmware refuse to talk instead of misparsing each other.
|
||||
// 10: CMD_HF_MIFARE_EML_MEMSET gained a flags byte
|
||||
#define CAPABILITIES_VERSION 10
|
||||
// what a pre-v9 device would have used, it could not tell us
|
||||
#define CAPABILITIES_LEGACY_CMD_DATA_SIZE 512
|
||||
extern capabilities_t g_pm3_capabilities;
|
||||
|
||||
Reference in new issue
Block a user