From 0b59efcb4261621ff3312bda815ab3eb27590852 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Tue, 9 Jan 2024 18:48:21 +0100 Subject: [PATCH] src/gowin: GW5A/SPI flash: adding delay after erase flash and after SPI mode instruction. Seems fixed write error. --- src/gowin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gowin.cpp b/src/gowin.cpp index ef2c37f..9c1992f 100644 --- a/src/gowin.cpp +++ b/src/gowin.cpp @@ -1144,18 +1144,22 @@ bool Gowin::dumpFlash(uint32_t base_addr, uint32_t len) bool Gowin::prepare_flash_access() { - _jtag->setClkFreq(10000000); - if (!eraseSRAM()) { printError("Error: fail to erase SRAM"); return false; } if (is_gw5a) { + if (!eraseSRAM()) { + printError("Error: fail to erase SRAM"); + return false; + } + usleep(100000); if (!gw5a_enable_spi()) { printError("Error: fail to switch GW5A to SPI mode"); return false; } + usleep(100000); } else if (!is_gw2a) { if (!enableCfg()) { return false; @@ -1163,6 +1167,8 @@ bool Gowin::prepare_flash_access() send_command(0x3D); } + _jtag->setClkFreq(10000000); + return true; }