mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-09-10 09:26:31 +00:00
The FPGA trace loop was the last OLD reply on the device outside the two the bootrom also serves. It stayed OLD because the DMA double-buffer was sized to the frame payload and an NG header did not obviously fit in front of it. DMA straight into chunk->data of a download_chunk_t instead, so a filled buffer is already a complete NG payload and needs no copy. Chunking now follows DOWNLOAD_CHUNK_MAX and scales with PM3_CMD_DATA_SIZE. The terminator carries download_done_t like the other bulk downloads. No client change needed, dl_it already had the NG branch. Two fixes fall out of it: FPGA_TRACE_SIZE is 3072, an exact multiple of 512 but not of DOWNLOAD_CHUNK_MAX. Each transfer is now armed for exactly the bytes still expected - arming a full chunk for the short last one would spin in FPGA_SSC_DMA_RX_Done() forever. This also drops the stray extra DMA the old loop left armed. get_tosend() moved after FpgaDownloadAndGo(). The loader calls BigBuf_free(), which nulls s_toSend.buf, then reuses that same region for its decompression ring buffer - the old code captured the pointer before the free and only worked because the loader was done with it in time. 3072 bytes goes from 6 OLD frames to 7 NG frames at PM3_CMD_DATA_SIZE 512, and would be 5 at 688.