Skip to content

Commit

Permalink
Merge pull request #427 from jgroman/master
Browse files Browse the repository at this point in the history
Fix Tang Primer 25K SRAM loading when flash is erased
  • Loading branch information
trabucayre authored Feb 2, 2024
2 parents f7826b8 + eba9c37 commit 39be00f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/gowin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,19 @@ void Gowin::sendClkUs(unsigned us)
bool Gowin::eraseSRAM()
{
printInfo("Erase SRAM ", false);
uint32_t status = readStatusReg();
if (_verbose)
displayReadReg("before erase sram", readStatusReg());
displayReadReg("before erase sram", status);

// If flash is invalid, send extra cmd 0x3F before SRAM erase
// This is required on GW5A-25
bool auto_boot_2nd_fail = (status & 0x8) >> 3;
if ((_idcode == 0x0001281B) && auto_boot_2nd_fail)
{
disableCfg();
send_command(0x3F);
send_command(NOOP);
}

if (!enableCfg()) {
printError("FAIL");
Expand Down

0 comments on commit 39be00f

Please sign in to comment.