From c26098f766d6179c81830fa5bcf82e079dff3200 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Thu, 22 Dec 2022 13:14:16 +0100 Subject: [PATCH 1/2] Use write timeout for write command Writing to "larger" devices can fail with the non-obvious "ERROR: Write failed." because the read timeout is applied to the write command. --- fpdkcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpdkcom.c b/fpdkcom.c index edbccf3..3cc61fa 100644 --- a/fpdkcom.c +++ b/fpdkcom.c @@ -449,7 +449,7 @@ int FPDKCOM_IC_Write(const int fd, write_block_clock_group_trail_clocks }; uint8_t resp[3+sizeof(uint16_t)]; - if( sizeof(resp) != _FPDKCOM_SendReceiveCommandWithTimeout(fd, FPDKPROTO_CMD_WRITEIC, dat,sizeof(dat), resp, sizeof(resp), FPDKCOM_CMDRSP_READIC_TIMEOUT) ) + if( sizeof(resp) != _FPDKCOM_SendReceiveCommandWithTimeout(fd, FPDKPROTO_CMD_WRITEIC, dat,sizeof(dat), resp, sizeof(resp), FPDKCOM_CMDRSP_WRITE_TIMEOUT) ) return -1; return( resp[3] | (((int)resp[4])<<8) ); From 5d11e24efdf96d92ee716aa18c2229f53048322b Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Thu, 22 Dec 2022 13:31:22 +0100 Subject: [PATCH 2/2] Increase write timeout to 4s PFC161 has 4KiB flash; this takes a while to write. On a new chip writing takes about 2.8s. To be on the safe side we bump the timeout to 4s. --- fpdkcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpdkcom.c b/fpdkcom.c index 3cc61fa..829f235 100644 --- a/fpdkcom.c +++ b/fpdkcom.c @@ -31,7 +31,7 @@ static const char FPDK_VERSCAN[] = "FREE-PDK EASY PROG - HW:%u.%u SW:%u.%u PROTO #define FPDKCOM_CMDRSP_PROBEIC_TIMEOUT 3500 #define FPDKCOM_CMDRSP_READIC_TIMEOUT 1000 #define FPDKCOM_CMDRSP_ERASE_TIMEOUT 2000 -#define FPDKCOM_CMDRSP_WRITE_TIMEOUT 2000 +#define FPDKCOM_CMDRSP_WRITE_TIMEOUT 4000 #define FPDKCOM_CMDRSP_CALIBRATEIC_TIMEOUT 10000 static bool _FPDKCOM_SendCommand(const int fd, const FPDKPROTO_CMD cmd, const uint8_t* dat, const uint8_t len)