From 90e62e07c36246a054a654cf03ee5ef02b256208 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Mon, 19 Aug 2024 21:29:30 -0400 Subject: [PATCH] efinix: add support for flash detect and flash dump in SoJ mode --- src/efinix.cpp | 18 +++++++++++++++--- src/efinix.hpp | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/efinix.cpp b/src/efinix.cpp index 87d3b35..328a5c2 100644 --- a/src/efinix.cpp +++ b/src/efinix.cpp @@ -228,11 +228,23 @@ void Efinix::program(unsigned int offset, bool unprotect_flash) delete bit; } +bool Efinix::detect_flash() +{ + if (_jtag) { + return SPIInterface::detect_flash(); + } + + uint32_t timeout = 1000; + _spi->gpio_clear(_rst_pin); + + return reinterpret_cast(_spi)->detect_flash(); +} + bool Efinix::dumpFlash(uint32_t base_addr, uint32_t len) { - if (!_spi) { - printError("jtag: dumpFlash not supported"); - return false; + if (_jtag) { + SPIInterface::set_filename(_filename); + return SPIInterface::dump(base_addr, len); } uint32_t timeout = 1000; diff --git a/src/efinix.hpp b/src/efinix.hpp index fda7384..2e0ac6a 100644 --- a/src/efinix.hpp +++ b/src/efinix.hpp @@ -28,6 +28,7 @@ class Efinix: public Device, SPIInterface { ~Efinix(); void program(unsigned int offset, bool unprotect_flash) override; + bool detect_flash() override; bool dumpFlash(uint32_t base_addr, uint32_t len) override; bool protect_flash(uint32_t len) override { (void) len;