From c1d7f919be803ea7b0af9e3b7a9934a307288f77 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 31 Jul 2023 13:11:57 +0100 Subject: [PATCH] Exit avrftdi_jtag_enable() when encountering incompatible chip The use of exit() is brought about by the fact that, unlike all other programming functions, pgm->enable() is of type void, ie, cannot easily tell the caller something went wrong. --- src/avrftdi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/avrftdi.c b/src/avrftdi.c index 22acf9715..95dded4e4 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -1464,6 +1464,18 @@ static int avrftdi_jtag_dr_inout(const PROGRAMMER *pgm, unsigned int dr, static void avrftdi_jtag_enable(PROGRAMMER *pgm, const AVRPART *p) { + if(!ovsigck) { + if(str_eq(p->id, "m128a") || str_eq(p->id, "m128") || + str_eq(p->id, "m64a") || str_eq(p->id, "m64") || + str_eq(p->id, "m32a") || str_eq(p->id, "m32") || + str_eq(p->id, "m16a") || str_eq(p->id, "m16") || + str_eq(p->id, "m162")) { + pmsg_error("programmer type %s is known not to work for %s\n", pgm->type, p->desc); + imsg_error("exiting; use -F to carry on regardless\n"); + exit(1); + } + } + pgm->powerup(pgm); set_pin(pgm, PIN_AVR_RESET, OFF);