diff --git a/ChangeLog b/ChangeLog
index a7df3aea..38ee4864 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-04-25  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	* update.c (parse_op): do not assume default memtype here
+	* main.c: after locating the part information, determine default
+	memtype for all update options that didn't have a memtype
+	specified; this is "application" for Xmega parts, and "flash" for
+	everything else.
+
 2012-04-24  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	* fileio.c: Rework the way ELF file sections are considered: while
diff --git a/NEWS b/NEWS
index 90380316..2fa590bd 100644
--- a/NEWS
+++ b/NEWS
@@ -81,6 +81,11 @@ Current:
     the appropriate section contents that matches the requested memory
     region.
 
+  * Specifying a -U option without a memory type (short form of
+    option argument list) now defaults to "application" memory for
+    Xmega devices, and "flash" for everything else.  This ensures
+    the bootloader is not touched.
+
   * Programmers and parts lists
 
     They are now sorted at output with '-c ?'/'-p ?'. (patch #7671:
diff --git a/main.c b/main.c
index c2758e27..a39c4b84 100644
--- a/main.c
+++ b/main.c
@@ -859,6 +859,30 @@ int main(int argc, char * argv [])
     exit(1);
   }
 
+  /*
+   * Now that we know which part we are going to program, locate any
+   * -U options using the default memory region, and fill in the
+   * device-dependent default region name, either "application" (for
+   * Xmega devices), or "flash" (everything else).
+   */
+  for (ln=lfirst(updates); ln; ln=lnext(ln)) {
+    upd = ldata(ln);
+    if (upd->memtype == NULL) {
+      const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
+      if (verbose >= 2) {
+        fprintf(stderr,
+                "%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
+                progname,
+                (upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
+                upd->filename, mtype);
+      }
+      if ((upd->memtype = strdup(mtype)) == NULL) {
+        fprintf(stderr, "%s: out of memory\n", progname);
+        exit(1);
+      }
+    }
+  }
+
   /*
    * open the programmer
    */
diff --git a/update.c b/update.c
index d49f80a9..f5ecd6c2 100644
--- a/update.c
+++ b/update.c
@@ -54,17 +54,13 @@ UPDATE * parse_op(char * s)
   buf[i] = 0;
 
   if (*p != ':') {
-    upd->memtype = (char *)malloc(strlen("flash")+1);
-    if (upd->memtype == NULL) {
-      outofmem:
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-    strcpy(upd->memtype, "flash");
+    upd->memtype = NULL;        /* default memtype, "flash", or "application" */
     upd->op = DEVICE_WRITE;
     upd->filename = (char *)malloc(strlen(buf) + 1);
-    if (upd->filename == NULL)
-      goto outofmem;
+    if (upd->filename == NULL) {
+        fprintf(stderr, "%s: out of memory\n", progname);
+        exit(1);
+    }
     strcpy(upd->filename, buf);
     upd->format = FMT_AUTO;
     return upd;
@@ -177,7 +173,10 @@ UPDATE * dup_update(UPDATE * upd)
 
   memcpy(u, upd, sizeof(UPDATE));
 
-  u->memtype = strdup(upd->memtype);
+  if (upd->memtype != NULL)
+    u->memtype = strdup(upd->memtype);
+  else
+    u->memtype = NULL;
   u->filename = strdup(upd->filename);
 
   return u;