Index: arduino.c
===================================================================
--- arduino.c	(revision 1504)
+++ arduino.c	(working copy)
@@ -84,7 +84,8 @@
 {
   union pinfo pinfo;
   strcpy(pgm->port, port);
-  pinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
+  pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
   if (serial_open(port, pinfo, &pgm->fd)==-1) {
     return -1;
   }
Index: avr910.c
===================================================================
--- avr910.c	(revision 1504)
+++ avr910.c	(working copy)
@@ -370,7 +370,8 @@
   }
 
   strcpy(pgm->port, port);
-  pinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
   if (serial_open(port, pinfo, &pgm->fd)==-1) {
     return -1;
   }
Index: buspirate.c
===================================================================
--- buspirate.c	(revision 1504)
+++ buspirate.c	(working copy)
@@ -427,7 +427,8 @@
 	if(pgm->baudrate == 0)
 		pgm->baudrate = 115200;
 
-	pinfo.baud = pgm->baudrate;
+	pinfo.serialinfo.baud = pgm->baudrate;
+	pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 	strcpy(pgm->port, port);
 	if (serial_open(port, pinfo, &pgm->fd)==-1) {
 		return -1;
Index: butterfly.c
===================================================================
--- butterfly.c	(revision 1504)
+++ butterfly.c	(working copy)
@@ -391,7 +391,8 @@
   if(pgm->baudrate == 0) {
     pgm->baudrate = 19200;
   }
-  pinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
   if (serial_open(port, pinfo, &pgm->fd)==-1) {
     return -1;
   }
Index: jtagmkI.c
===================================================================
--- jtagmkI.c	(revision 1504)
+++ jtagmkI.c	(working copy)
@@ -553,7 +553,7 @@
                 progname, pgm->baudrate);
       if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
         PDATA(pgm)->initial_baudrate = pgm->baudrate; /* don't adjust again later */
-        serial_setspeed(&pgm->fd, pgm->baudrate);
+        serial_setspeed(&pgm->fd, pgm->baudrate, SERIAL_DEFAULT_FLAGS);
       }
     }
   }
@@ -648,9 +648,10 @@
 
   for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) {
     union pinfo pinfo;
-    pinfo.baud = baudtab[i].baud;
+    pinfo.serialinfo.baud = baudtab[i].baud;
+    pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
     avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
-                      progname, pinfo.baud);
+                      progname, pinfo.serialinfo.baud);
     if (serial_open(port, pinfo, &pgm->fd)==-1) {
       return -1;
     }
@@ -697,7 +698,7 @@
                 "trying to set baudrate to %d\n",
                 progname, PDATA(pgm)->initial_baudrate);
       if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
-        serial_setspeed(&pgm->fd, pgm->baudrate);
+        serial_setspeed(&pgm->fd, pgm->baudrate, SERIAL_DEFAULT_FLAGS);
       }
     }
   }
Index: jtagmkII.c
===================================================================
--- jtagmkII.c	(revision 1504)
+++ jtagmkII.c	(working copy)
@@ -1312,7 +1312,7 @@
 		"trying to set baudrate to %d\n",
 		progname, pgm->baudrate);
       if (jtagmkII_setparm(pgm, PAR_BAUD_RATE, &b) == 0)
-	serial_setspeed(&pgm->fd, pgm->baudrate);
+	serial_setspeed(&pgm->fd, pgm->baudrate, SERIAL_DEFAULT_FLAGS);
     }
   }
   if ((pgm->flag & PGM_FL_IS_JTAG) && pgm->bitclock != 0.0) {
@@ -1490,7 +1490,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -1542,7 +1543,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -1594,7 +1596,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -1647,7 +1650,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -1700,7 +1704,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -1753,7 +1758,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -3330,7 +3336,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
Index: libavrdude.h
===================================================================
--- libavrdude.h	(revision 1504)
+++ libavrdude.h	(working copy)
@@ -530,9 +530,32 @@
   } usb;
 };
 
+#define SERIAL_CS5          0x0000
+#define SERIAL_CS6          0x0001
+#define SERIAL_CS7          0x0002
+#define SERIAL_CS8          0x0004
+
+#define SERIAL_NO_CSTOPB    0x0000
+#define SERIAL_CSTOPB       0x0008
+
+#define SERIAL_NO_CREAD     0x0000
+#define SERIAL_CREAD        0x0010
+
+#define SERIAL_NO_PARITY    0x0000
+#define SERIAL_PARENB       0x0020
+#define SERIAL_PARODD       0x0040
+
+#define SERIAL_NO_CLOCAL    0x0000
+#define SERIAL_CLOCAL       0x0080
+
+#define SERIAL_DEFAULT_FLAGS (SERIAL_CS8 | SERIAL_NO_CSTOPB | SERIAL_CREAD | SERIAL_NO_PARITY | SERIAL_CLOCAL)
+
 union pinfo
 {
-  long baud;
+  struct {
+    long baud;
+    unsigned long cflags;
+  } serialinfo;
   struct
   {
     unsigned short vid;
@@ -548,7 +571,7 @@
 {
   // open should return -1 on error, other values on success
   int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd); 
-  int (*setspeed)(union filedescriptor *fd, long baud);
+  int (*setspeed)(union filedescriptor *fd, long baud, unsigned long cflags);
   void (*close)(union filedescriptor *fd);
 
   int (*send)(union filedescriptor *fd, const unsigned char * buf, size_t buflen);
Index: ser_posix.c
===================================================================
--- ser_posix.c	(revision 1504)
+++ ser_posix.c	(working copy)
@@ -55,6 +55,8 @@
 /* There are a lot more baud rates we could handle, but what's the point? */
 
 static struct baud_mapping baud_lookup_table [] = {
+  { 300,    B300 },
+  { 600,    B600 },
   { 1200,   B1200 },
   { 2400,   B2400 },
   { 4800,   B4800 },
@@ -96,8 +98,21 @@
   return baud;
 }
 
-static int ser_setspeed(union filedescriptor *fd, long baud)
+static tcflag_t translate_flags(unsigned long cflags)
 {
+  return ((cflags & SERIAL_CS5)                      ? CS5    : 0) |
+         ((cflags & SERIAL_CS6)                      ? CS6    : 0) |
+         ((cflags & SERIAL_CS7)                      ? CS7    : 0) |
+         ((cflags & SERIAL_CS8)                      ? CS8    : 0) |
+         ((cflags & SERIAL_CSTOPB)                   ? CSTOPB : 0) |
+         ((cflags & SERIAL_CREAD)                    ? CREAD  : 0) |
+         ((cflags & (SERIAL_PARENB | SERIAL_PARODD)) ? PARENB : 0) |
+         ((cflags & SERIAL_PARODD)                   ? PARODD : 0) |
+         ((cflags & SERIAL_CLOCAL)                   ? CLOCAL : 0) ;
+}
+
+static int ser_setspeed(union filedescriptor *fd, long baud, unsigned long cflags)
+{
   int rc;
   struct termios termios;
   speed_t speed = serial_baud_lookup (baud);
@@ -125,7 +140,7 @@
   termios.c_iflag = IGNBRK;
   termios.c_oflag = 0;
   termios.c_lflag = 0;
-  termios.c_cflag = (CS8 | CREAD | CLOCAL);
+  termios.c_cflag = translate_flags(cflags);
   termios.c_cc[VMIN]  = 1;
   termios.c_cc[VTIME] = 0;
 
@@ -298,7 +313,7 @@
   /*
    * set serial line attributes
    */
-  rc = ser_setspeed(fdp, pinfo.baud);
+  rc = ser_setspeed(fdp, pinfo.serialinfo.baud, pinfo.serialinfo.cflags);
   if (rc) {
     avrdude_message(MSG_INFO, "%s: ser_open(): can't set attributes for device \"%s\": %s\n",
                     progname, port, strerror(-rc));
@@ -308,7 +323,6 @@
   return 0;
 }
 
-
 static void ser_close(union filedescriptor *fd)
 {
   /*
Index: ser_win32.c
===================================================================
--- ser_win32.c	(revision 1504)
+++ ser_win32.c	(working copy)
@@ -54,6 +54,8 @@
 /* HANDLE hComPort=INVALID_HANDLE_VALUE; */
 
 static struct baud_mapping baud_lookup_table [] = {
+  { 300,    CBR_300 },
+  { 600,    CBR_600 },
   { 1200,   CBR_1200 },
   { 2400,   CBR_2400 },
   { 4800,   CBR_4800 },
@@ -97,7 +99,7 @@
 	return SetCommTimeouts(hComPort, &ctmo);
 }
 
-static int ser_setspeed(union filedescriptor *fd, long baud)
+static int ser_setspeed(union filedescriptor *fd, long baud, unsigned long cflags)
 {
 	if (serial_over_ethernet) {
 		return -ENOTTY;
@@ -111,9 +113,39 @@
 		dcb.fBinary = 1;
 		dcb.fDtrControl = DTR_CONTROL_DISABLE;
 		dcb.fRtsControl = RTS_CONTROL_DISABLE;
-		dcb.ByteSize = 8;
-		dcb.Parity = NOPARITY;
-		dcb.StopBits = ONESTOPBIT;
+		switch ((cflags & (SERIAL_CS5 | SERIAL_CS6 | SERIAL_CS7 | SERIAL_CS8))) {
+			case SERIAL_CS5:
+				dcb.ByteSize = 5;
+				break;
+			case SERIAL_CS6:
+				dcb.ByteSize = 6;
+				break;
+			case SERIAL_CS7:
+				dcb.ByteSize = 7;
+				break;
+			case SERIAL_CS8:
+				dcb.ByteSize = 8;
+				break;
+		}
+		switch ((cflags & (SERIAL_NO_PARITY | SERIAL_PARENB | SERIAL_PARODD))) {
+			case SERIAL_NO_PARITY:
+				dcb.Parity = NOPARITY;
+				break;
+			case SERIAL_PARENB:
+				dcb.Parity = EVENPARITY;
+				break;
+			case SERIAL_PARODD:
+				dcb.Parity = ODDPARITY;
+				break;
+		}
+		switch ((cflags & (SERIAL_NO_CSTOPB | SERIAL_CSTOPB))) {
+			case SERIAL_NO_CSTOPB:
+				dcb.StopBits = ONESTOPBIT;
+				break;
+			case SERIAL_CSTOPB:
+				dcb.StopBits = TWOSTOPBITS;
+				break;
+		}
 
 		if (!SetCommState(hComPort, &dcb))
 			return -1;
@@ -283,7 +315,7 @@
 	}
 
         fdp->pfd = (void *)hComPort;
-	if (ser_setspeed(fdp, pinfo.baud) != 0)
+	if (ser_setspeed(fdp, pinfo.serialinfo.baud, pinfo.serialinfo.cflags) != 0)
 	{
 		CloseHandle(hComPort);
 		avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n",
Index: stk500.c
===================================================================
--- stk500.c	(revision 1504)
+++ stk500.c	(working copy)
@@ -657,7 +657,8 @@
 {
   union pinfo pinfo;
   strcpy(pgm->port, port);
-  pinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
+  pinfo.serialinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
   if (serial_open(port, pinfo, &pgm->fd)==-1) {
     return -1;
   }
Index: stk500v2.c
===================================================================
--- stk500v2.c	(revision 1504)
+++ stk500v2.c	(working copy)
@@ -1603,12 +1603,12 @@
 
 static int stk500v2_open(PROGRAMMER * pgm, char * port)
 {
-  union pinfo pinfo = { .baud = 115200 };
+  union pinfo pinfo = { .serialinfo.baud = 115200, .serialinfo.cflags = SERIAL_DEFAULT_FLAGS };
 
   DEBUG("STK500V2: stk500v2_open()\n");
 
   if (pgm->baudrate)
-    pinfo.baud = pgm->baudrate;
+    pinfo.serialinfo.baud = pgm->baudrate;
 
   PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
 
@@ -1671,12 +1671,12 @@
 
 static int stk600_open(PROGRAMMER * pgm, char * port)
 {
-  union pinfo pinfo = { .baud = 115200 };
+  union pinfo pinfo = { .serialinfo.baud = 115200, .serialinfo.cflags = SERIAL_DEFAULT_FLAGS };
 
   DEBUG("STK500V2: stk600_open()\n");
 
   if (pgm->baudrate)
-    pinfo.baud = pgm->baudrate;
+    pinfo.serialinfo.baud = pgm->baudrate;
 
   PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
 
@@ -3392,7 +3392,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -3503,7 +3504,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
@@ -3581,7 +3583,8 @@
    * a higher baud rate, we switch to it later on, after establishing
    * the connection with the ICE.
    */
-  pinfo.baud = 19200;
+  pinfo.serialinfo.baud = 19200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /*
    * If the port name starts with "usb", divert the serial routines
Index: wiring.c
===================================================================
--- wiring.c	(revision 1504)
+++ wiring.c	(working copy)
@@ -150,7 +150,8 @@
   union pinfo pinfo;
 
   strcpy(pgm->port, port);
-  pinfo.baud = pgm->baudrate ? pgm->baudrate: 115200;
+  pinfo.serialinfo.baud = pgm->baudrate ? pgm->baudrate: 115200;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
   serial_open(port, pinfo, &pgm->fd);
 
   /* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */
Index: xbee.c
===================================================================
--- xbee.c	(revision 1504)
+++ xbee.c	(working copy)
@@ -1198,7 +1198,7 @@
                   (unsigned int)xbs->xbee_address[6],
                   (unsigned int)xbs->xbee_address[7]);
 
-  if (pinfo.baud) {
+  if (pinfo.serialinfo.baud) {
     /*
      * User supplied the correct baud rate.
      */
@@ -1222,7 +1222,7 @@
      * plugged in.  The doubled clock rate means a doubled serial
      * rate.  Double 9600 baud == 19200 baud.
      */
-    pinfo.baud = 19200;
+    pinfo.serialinfo.baud = 19200;
   } else {
     /*
      * In normal mode, default to 9600.
@@ -1234,10 +1234,11 @@
      * XBee baud rate we should select.  The baud rate of the AVR
      * device is irrelevant.
      */
-    pinfo.baud = 9600;
+    pinfo.serialinfo.baud = 9600;
   }
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
-  avrdude_message(MSG_NOTICE, "%s: Baud %ld\n", progname, (long)pinfo.baud);
+  avrdude_message(MSG_NOTICE, "%s: Baud %ld\n", progname, (long)pinfo.serialinfo.baud);
 
   {
     const int rc = xbs->serialDevice->open(tty, pinfo,
@@ -1640,7 +1641,8 @@
 {
   union pinfo pinfo;
   strcpy(pgm->port, port);
-  pinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.baud = pgm->baudrate;
+  pinfo.serialinfo.cflags = SERIAL_DEFAULT_FLAGS;
 
   /* Wireless is lossier than normal serial */
   serial_recv_timeout = 1000;
