ATMEGA328 how to load firmware with optiboot and FTDI without DTR

Hi,
I'm trying to find a solution to load a new firmware from FTDI FT232RL Serial to ATMEGA328 without using DTR and reset the ATMEGA. I don't want to auto-reset the microcontroller when I insert the USB and open Serial.

I introduced Watchdog feature: wdt_enable(WDTO_4S); in my code and I can reset the controller on demand from the firmware.

Unfortunately optiboot 6.2 does not wait to get a new firmware from Serial.

Am I missing something here?

Thanks,

That's the normal behavior of optiboot. It only listens for an upload after a hardware reset. It does not after a watchdog reset. You could manually reset the Arduino or you could modify the optiboot source code to change the behavior after a watchdog reset.

Alright,

I have to tweak optiboot.c . Is this gonna help?

watchdogConfig(WATCHDOG_1S);

Ok I found a dirty way to make bootloader wait for 4sec every time atmega powers up.

in bootloader.c (remove first line and add the 2nd one)

-- if (ch & (_BV(WDRF) | _BV(BORF) | _BV(PORF)))
++ if (ch & (_BV(WDRF)))

Also increase Watchdog to 4sec to have time for FTDI to get recognised in OS

watchdogConfig(WATCHDOG_4S);

Burn bootloader and enjoy :slight_smile: