From 6385fb09f7057d0193b825afcc8cc7f4b403438b Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 27 Nov 2022 22:41:29 +0100 Subject: [PATCH 1/3] Add missing stk500v2 status constants --- src/stk500v2_private.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stk500v2_private.h b/src/stk500v2_private.h index 560f143e..873fb668 100644 --- a/src/stk500v2_private.h +++ b/src/stk500v2_private.h @@ -138,6 +138,9 @@ #define STATUS_CKSUM_ERROR 0xC1 #define STATUS_CMD_UNKNOWN 0xC9 #define STATUS_CMD_ILLEGAL_PARAMETER 0xCA +#define STATUS_PHY_ERROR 0xCB +#define STATUS_CLOCK_ERROR 0xCC +#define STATUS_BAUD_INVALID 0xCD // Status #define STATUS_ISP_READY 0x00 From 2d7ad8e37310316163f0d2e47e97e932f0913cb6 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 27 Nov 2022 22:52:45 +0100 Subject: [PATCH 2/3] Print meaningful ISP clock error message Currently, only some JTAG3 compatible programmers are able to detect that the connected target's main clock speed actually is too low for for the programmer. In this case, these will return 0xCC. --- src/main.c | 7 +++++-- src/stk500v2.c | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 691369cf..cb3232b4 100644 --- a/src/main.c +++ b/src/main.c @@ -1242,8 +1242,11 @@ int main(int argc, char * argv []) init_ok = (rc = pgm->initialize(pgm, p)) >= 0; if (!init_ok) { pmsg_error("initialization failed, rc=%d\n", rc); - imsg_error("- double check the connections and try again\n"); - imsg_error("- use -B to set lower ISP clock frequency, e.g. -B 200kHz\n"); + if(rc == -2) + imsg_error("The programmer ISP clock is too fast for the target\n"); + else + imsg_error("- double check the connections and try again\n"); + imsg_error("- use -B to set lower ISP clock frequency, e.g. -B 125kHz\n"); if (!ovsigck) { imsg_error("- use -F to override this check\n\n"); exitrc = 1; diff --git a/src/stk500v2.c b/src/stk500v2.c index bb086c10..5455ef3d 100644 --- a/src/stk500v2.c +++ b/src/stk500v2.c @@ -795,6 +795,11 @@ retry: // attempt to read the status back status = stk500v2_recv(pgm,buf,maxlen); + DEBUG("STK500V2: stk500v2_command() received content: [ "); + for (size_t i=0; i 0) { DEBUG(" = %d\n",status); @@ -858,6 +863,9 @@ retry: return status; } else if (buf[1] == STATUS_CMD_FAILED) { pmsg_error("command failed\n"); + } else if (buf[1] == STATUS_CLOCK_ERROR) { + pmsg_error("target clock speed error\n"); + return -2; } else if (buf[1] == STATUS_CMD_UNKNOWN) { pmsg_error("unknown command\n"); } else { From 0be8f3b82d755dde994f1f10caf11f4a28ded3f0 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Fri, 16 Dec 2022 20:27:20 +0100 Subject: [PATCH 3/3] Start sentence with lower case character --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index cb3232b4..337d5e35 100644 --- a/src/main.c +++ b/src/main.c @@ -1243,7 +1243,7 @@ int main(int argc, char * argv []) if (!init_ok) { pmsg_error("initialization failed, rc=%d\n", rc); if(rc == -2) - imsg_error("The programmer ISP clock is too fast for the target\n"); + imsg_error("the programmer ISP clock is too fast for the target\n"); else imsg_error("- double check the connections and try again\n"); imsg_error("- use -B to set lower ISP clock frequency, e.g. -B 125kHz\n");