Skip to content

Commit

Permalink
Split writeSRAM to show progress
Browse files Browse the repository at this point in the history
  • Loading branch information
aystarik committed Sep 25, 2023
1 parent 8f27630 commit 3b783c0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/gowin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,21 @@ bool Gowin::writeSRAM(const uint8_t *data, int length)
send_command(CONFIG_ENABLE); // config enable
send_command(INIT_ADDR); // address initialize
send_command(XFER_WRITE); // transfer configuration data

_jtag->shiftDR(data, NULL, length);
int remains = length;
const uint8_t *ptr = data;
int blength = length / 8;
while (remains) {
int chunk = (length / 10) & ~3; // round to byte boundary
Jtag::tapState_t next = Jtag::SHIFT_DR;
if (remains < chunk) {
chunk = remains;
next = Jtag::RUN_TEST_IDLE;
}
_jtag->shiftDR(ptr, NULL, chunk, next);
ptr += chunk / 8; // in bytes
remains -= chunk;
progress.display(ptr - data);
}
progress.done();
send_command(0x0a);
uint32_t checksum = static_cast<FsParser *>(_fs)->checksum();
Expand Down

0 comments on commit 3b783c0

Please sign in to comment.