From cb03b3fce7f1633bc11df59377aa3094805d1e0c Mon Sep 17 00:00:00 2001 From: Sylvain Lesne Date: Fri, 14 Oct 2022 12:07:54 +0200 Subject: [PATCH 1/3] nx: fix reboot It seems that with NX devices, simply sending LSC_REFRESH is not enough to reboot the FPGA (it stays in a blank state). With trial and error, I found out that doing a no-op (with 0xFF) after LSC_REFRESH seems to be enough to actually trigger the refresh. Signed-off-by: Sylvain Lesne --- ecpprog/ecpprog.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ecpprog/ecpprog.c b/ecpprog/ecpprog.c index d933620..cd21562 100644 --- a/ecpprog/ecpprog.c +++ b/ecpprog/ecpprog.c @@ -1291,8 +1291,11 @@ int main(int argc, char **argv) } if (reinitialize) { - fprintf(stderr, "rebooting ECP5...\n"); + fprintf(stderr, "rebooting FPGA...\n"); ecp_jtag_cmd(LSC_REFRESH); + if(connected_device.type == TYPE_NX){ + ecp_jtag_cmd(ISC_NOOP); + } } if (f != NULL && f != stdin && f != stdout) From e9d4044cf5809052e306b84f65c4bfd70e339fac Mon Sep 17 00:00:00 2001 From: Sylvain Lesne Date: Fri, 14 Oct 2022 12:17:56 +0200 Subject: [PATCH 2/3] program: improve FPGA reset sequence During my tests with the CertusPro-NX evaluation board, I found that the current program command doesn't work reliably: the JTAG usually doesn't have access to the flash (reports an ID full of zeroes, and the operations don't work). I noticed that in contrast, the test operation always reported correct flash IDs, so using the usleep() calls in between the JTAG commands seems to help getting the flash command to work reliably. Signed-off-by: Sylvain Lesne --- ecpprog/ecpprog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ecpprog/ecpprog.c b/ecpprog/ecpprog.c index cd21562..e5a20da 100644 --- a/ecpprog/ecpprog.c +++ b/ecpprog/ecpprog.c @@ -1163,7 +1163,9 @@ int main(int argc, char **argv) fprintf(stderr, "reset..\n"); /* Reset ECP5 to release SPI interface */ ecp_jtag_cmd8(ISC_ENABLE, 0); + usleep(10000); ecp_jtag_cmd8(ISC_ERASE, 0); + usleep(10000); ecp_jtag_cmd8(ISC_DISABLE, 0); /* Put device into SPI bypass mode */ From 792421a998a189beb1fad88646a4fae0e5116846 Mon Sep 17 00:00:00 2001 From: Sylvain Lesne Date: Fri, 14 Oct 2022 12:38:22 +0200 Subject: [PATCH 3/3] nx: improve SRAM programming It seems that using the current SRAM programming sequence on an already programmed NX FPGA leaves the on-chip memories un-initialized. The Radiant programmer sends an LSC_REFRESH command before the SRAM programming sequence, and it does seem to help, so do it here as well. Signed-off-by: Sylvain Lesne --- ecpprog/ecpprog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecpprog/ecpprog.c b/ecpprog/ecpprog.c index e5a20da..231d60a 100644 --- a/ecpprog/ecpprog.c +++ b/ecpprog/ecpprog.c @@ -1121,7 +1121,9 @@ int main(int argc, char **argv) // Reset // --------------------------------------------------------- fprintf(stderr, "reset..\n"); - + if(connected_device.type == TYPE_NX){ + ecp_jtag_cmd(LSC_REFRESH); + } ecp_jtag_cmd8(ISC_ENABLE, 0); ecp_jtag_cmd8(ISC_ERASE, 0); ecp_jtag_cmd8(LSC_RESET_CRC, 0);