From 0151c0d710df82a406c6a68c53370fc371c8f5b0 Mon Sep 17 00:00:00 2001 From: xNovyz Date: Tue, 10 Mar 2026 23:06:41 +0100 Subject: [PATCH] fix(fpga): add FpgaResetBitstream() to force re-initialization After aggressive field cycling (e.g. tear-off attacks), the FPGA's internal SSC/DMA state can become corrupted even though the bitstream is technically loaded. FpgaDownloadAndGo() caches downloaded_bitstream and skips re-download if it matches, so subsequent commands fail silently or hang. Add FpgaResetBitstream() which sets downloaded_bitstream to FPGA_BITSTREAM_UNKNOWN, forcing the next FpgaDownloadAndGo() to perform a complete reload. --- armsrc/fpgaloader.c | 4 ++++ armsrc/fpgaloader.h | 1 + 2 files changed, 5 insertions(+) diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c index 384ec236c..e1c313414 100644 --- a/armsrc/fpgaloader.c +++ b/armsrc/fpgaloader.c @@ -630,6 +630,10 @@ int FpgaGetCurrent(void) { return downloaded_bitstream; } +void FpgaResetBitstream(void) { + downloaded_bitstream = FPGA_BITSTREAM_UNKNOWN; +} + // Turns off the antenna, // log message // if HF, Disable SSC DMA diff --git a/armsrc/fpgaloader.h b/armsrc/fpgaloader.h index 0786e608c..05fed4b1a 100644 --- a/armsrc/fpgaloader.h +++ b/armsrc/fpgaloader.h @@ -172,6 +172,7 @@ void SetupSpi(int mode); bool FpgaSetupSscDma(uint8_t *buf, uint16_t len); void Fpga_print_status(void); int FpgaGetCurrent(void); +void FpgaResetBitstream(void); void SetAdcMuxFor(uint32_t whichGpio); // extern and generel turn off the antenna method