diff --git a/ChangeLog b/ChangeLog
index 55dfad1d..0e2a64b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-11-23  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	patch #9757: Fix ATtiny817 Xplained Mini programmer
+	* jtag3.c (jtag3_getsync, jtag3_close): correctly extract
+	programmer name from list of names
+
 2021-11-22  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	Submitted by David Sainty:
diff --git a/NEWS b/NEWS
index 727af752..426438b6 100644
--- a/NEWS
+++ b/NEWS
@@ -112,6 +112,7 @@ Current:
     patch #9122: Fixed MISO sampling in ftdi_syncbb
     patch #9123: ftdi_syncbb: use FT245R_CYCLES in ft245r_set_bitclock()
     patch #8719: Support Over-the-Air bootloading with XBeeBoot
+    patch #9757: Fix ATtiny817 Xplained Mini programmer
 
   * Internals:
     - New avrdude.conf keyword "family_id", used to verify SIB attributes
diff --git a/jtag3.c b/jtag3.c
index 122df1bd..4357e5d2 100644
--- a/jtag3.c
+++ b/jtag3.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/time.h>
@@ -161,6 +162,11 @@ u16_to_b2(unsigned char *b, unsigned short l)
   b[1] = (l >> 8) & 0xff;
 }
 
+static bool matches(const char *s, const char *pat)
+{
+  return strncmp(s, pat, strlen(pat)) == 0;
+}
+
 static void jtag3_print_data(unsigned char *b, size_t s)
 {
   int i;
@@ -866,12 +872,11 @@ int jtag3_getsync(PROGRAMMER * pgm, int mode) {
 
   /* XplainedMini boards do not need this, and early revisions had a
    * firmware bug where they complained about it. */
-  if (pgm->flag & PGM_FL_IS_EDBG) {
-    if (strcmp(pgm->id, "xplainedmini_updi") != 0) {
+  if ((pgm->flag & PGM_FL_IS_EDBG) &&
+      !matches(ldata(lfirst(pgm->id)), "xplainedmini")) {
       if (jtag3_edbg_prepare(pgm) < 0) {
         return -1;
       }
-    }
   }
 
   /* Get the sign-on information. */
@@ -1629,10 +1634,9 @@ void jtag3_close(PROGRAMMER * pgm)
 
   /* XplainedMini boards do not need this, and early revisions had a
    * firmware bug where they complained about it. */
-  if (pgm->flag & PGM_FL_IS_EDBG) {
-    if (strcmp(pgm->id, "xplainedmini_updi") != 0) {
+  if ((pgm->flag & PGM_FL_IS_EDBG) &&
+      !matches(ldata(lfirst(pgm->id)), "xplainedmini")) {
       jtag3_edbg_signoff(pgm);
-    }
   }
 
   serial_close(&pgm->fd);