fpga_io: reboot ASAP if USB Blaster loading is detected.

This commit is contained in:
sorgelig
2020-08-20 17:33:34 +08:00
parent 419ae67dee
commit 141c0bedae
4 changed files with 20 additions and 18 deletions

View File

@@ -657,6 +657,20 @@ void fpga_spi_en(uint32_t mask, uint32_t en)
fpga_gpo_write(en ? gpo | mask : gpo & ~mask);
}
void fpga_wait_to_reset()
{
printf("FPGA is not ready. JTAG uploading?\n");
printf("Waiting for FPGA to be ready...\n");
fpga_core_reset(1);
while (!is_fpga_ready(0))
{
sleep(1);
}
reboot(0);
}
uint16_t fpga_spi(uint16_t word)
{
uint32_t gpo = (fpga_gpo_read() & ~(0xFFFF | SSPI_STROBE)) | word;
@@ -671,6 +685,7 @@ uint16_t fpga_spi(uint16_t word)
if (gpi < 0)
{
printf("GPI[31]==1. FPGA is uninitialized?\n");
fpga_wait_to_reset();
return 0;
}
} while (!(gpi & SSPI_ACK));
@@ -683,6 +698,7 @@ uint16_t fpga_spi(uint16_t word)
if (gpi < 0)
{
printf("GPI[31]==1. FPGA is uninitialized?\n");
fpga_wait_to_reset();
return 0;
}
} while (gpi & SSPI_ACK);

View File

@@ -39,4 +39,6 @@ void reboot(int cold);
void app_restart(const char *path, const char *xml = 0);
char *getappname();
void fpga_wait_to_reset();
#endif

View File

@@ -76,13 +76,7 @@ int main(int argc, char *argv[])
{
if (!is_fpga_ready(1))
{
printf("FPGA is not ready. JTAG uploading?\n");
printf("Waiting for FPGA to be ready...\n");
//enable reset in advance
fpga_core_reset(1);
while (!is_fpga_ready(0)) sleep(1);
reboot(0);
fpga_wait_to_reset();
}
user_io_poll();

View File

@@ -16,17 +16,7 @@ static void scheduler_wait_fpga_ready(void)
{
while (!is_fpga_ready(1))
{
printf("FPGA is not ready. JTAG uploading?\n");
printf("Waiting for FPGA to be ready...\n");
//enable reset in advance
fpga_core_reset(1);
while (!is_fpga_ready(0))
{
sleep(1);
}
reboot(0);
fpga_wait_to_reset();
}
}