FTDI chip resetting my device 3 times on WIN8.1 USB insertion

I've seen something like this before but didn't pay enough attention until I got my own design doing it:

I have win8.1, FT233RL chip and ATMEGA1284P. Reset mechanism is the same as UNO with 0.1uF cap and 10K resistor. Upon plugging into the USB port, my LCD back light flashed 3 times, indicating the chip reset 3 times, each time turning the pin that controls the back light into input, thus turning back light off, and then into output.

This might be ok if I'm running something useless like flashing some LEDs. But my device is supposed to save settings to EEPROM on first startup. If it gets reset while saving to EEPROM, that would be pretty bad.

So does the multiple resetting occur with FTDI chips? windows? any other reasons? Thanks.

Are you using optiboot from https://code.google.com/p/optiboot/

I think optiboot may be setup to flash the "LED" pin
if "LED_START_FLASHES" is set to three some place.

Looks like LED is defined as B7 unless it is a wildfirev3

I am getting lost trying to figure out what pin that is...
The relevant part of the code in optiboot.c looks like

#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
    LED_PORT ^= _BV(LED);
    LED_PIN |= _BV(LED);

and _BV(bit) is

B7 is port B bit 7.

the optiboot pin_defs.h file has the define

My LED back light is on PD7. The bootloader is indeed optiboot. But I don't think I am using the latest one. Here is my pin_defs.h:

#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ 
#define LED_DDR     DDRB
#define LED_PORT    PORTB
#define LED_PIN     PINB
#define LED         PINB5

/* Ports for soft UART */
#ifdef SOFT_UART
#define UART_PIN    PIND
#define UART_DDR    DDRD
#define UART_TX_BIT 1
#define UART_RX_BIT 0

#if defined(__AVR_ATmega8__)
  //Name conversion R.Wiersma
  #define UCSR0A	UCSRA
  #define UDR0 		UDR
  #define UDRE0 	UDRE
  #define RXC0		RXC
  #define FE0           FE
  #define TIFR1 	TIFR
  #define WDTCSR	WDTCR

/* Luminet support */
#if defined(__AVR_ATtiny84__)
/* Red LED is connected to pin PA4 */ 
#define LED_DDR     DDRA
#define LED_PORT    PORTA
#define LED_PIN     PINA
#define LED         PINA4
/* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */
#ifdef SOFT_UART
#define UART_PIN    PINA
#define UART_DDR    DDRA
#define UART_TX_BIT 2
#define UART_RX_BIT 3

/* Sanguino support */
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
/* Onboard LED is connected to pin PB0 on Sanguino */ 
#define LED_DDR     DDRB
#define LED_PORT    PORTB
#define LED_PIN     PINB
#define LED         PINB1

I am using 1284P, so my LED pin seems to be PB1 although the comment says PB0. So I still don't know what caused the LCD back light flashing. In the makefile, LED_START_FLASHES is defined as 3. So I'll try to rebuild the optiboot for 1284P with say LED_START_FLASHES 6 tomorrow and load it to my device to see if it does flash 6 times.

Here is my makefile (removed some content to stay within 9000 chars):

atmega1284: TARGET = atmega1284p
atmega1284: MCU_TARGET = atmega1284p
atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
atmega1284: AVR_FREQ = 16000000L
atmega1284: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
atmega1284: $(PROGRAM)_atmega1284p.hex
atmega1284: $(PROGRAM)_atmega1284p.lst

atmega1284_isp: atmega1284
atmega1284_isp: TARGET = atmega1284p
atmega1284_isp: MCU_TARGET = atmega1284p
# 1024 byte boot
atmega1284_isp: HFUSE = DE
# Low power xtal (16MHz) 16KCK/14CK+65ms
atmega1284_isp: LFUSE = FF
# 2.7V brownout
atmega1284_isp: EFUSE = FD
atmega1284_isp: isp

atmega1284_slow: TARGET = atmega1284p_slow
atmega1284_slow: MCU_TARGET = atmega1284p
atmega1284_slow: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=19200' '-DBIGBOOT'
atmega1284_slow: AVR_FREQ = 16000000L
atmega1284_slow: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
atmega1284_slow: $(PROGRAM)_atmega1284p_slow.hex
atmega1284_slow: $(PROGRAM)_atmega1284p_slow.lst

atmega1284_slow_isp: atmega1284_slow
atmega1284_slow_isp: TARGET = atmega1284p_slow
atmega1284_slow_isp: MCU_TARGET = atmega1284p
# 1024 byte boot
atmega1284_slow_isp: HFUSE = DE
# Low power xtal (16MHz) 16KCK/14CK+65ms
atmega1284_slow_isp: LFUSE = FF
# 2.7V brownout
atmega1284_slow_isp: EFUSE = FD
atmega1284_slow_isp: isp