gowin: Arora V: fix SRAM erase/load when flash is blank and timeout bit is set

This commit is contained in:
Gwenhael Goavec-Merou 2025-03-06 20:05:31 +01:00
parent ee8decdfe6
commit ab8d8fc0d3
1 changed files with 10 additions and 12 deletions

View File

@ -394,13 +394,6 @@ void Gowin::programSRAM()
if (!eraseSRAM())
return;
/* GW5AST-138k WA. Temporary until found correct solution/sequence */
if (is_gw5a && _idcode == 0x0001081b) {
printf("double eraseSRAM\n");
if (!eraseSRAM())
return;
}
/* load bitstream in SRAM */
if (!writeSRAM(_fs->getData(), _fs->getLength()))
return;
@ -912,13 +905,18 @@ bool Gowin::eraseSRAM()
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();
// This is required on GW5A-25 or GW5AST-138 when timeout bit
// is set
bool auto_boot_2nd_fail = (status & (1 << 4)) == (1 << 4);
bool is_timeout = (status & (1 << 3)) == (1 << 3);
if (is_gw5a && (is_timeout || auto_boot_2nd_fail)) {
send_command(CONFIG_ENABLE);
send_command(0x3F);
send_command(CONFIG_DISABLE);
send_command(NOOP);
send_command(READ_IDCODE);
send_command(NOOP);
_jtag->toggleClk(125 * 8);
}
if (!enableCfg()) {