I've got a few Atmega32u4 breakouts, currently they're set up to be Arduino Leonardo boards and I've had no problems programming via USB from the Arduino IDE. I've been trying to get the boards to work with dfu-programmer on OS X, the idea being that I don't need to use an ISP all the time.
Currently what I've managed is:
1) Erase via ISP to clear the lock bits
2) Flash Atmel's bootloader and update the lock bits:
$ avrdude -p m32u4 -c usbasp -v -U flash:w:ATMega32U4-usbdevice_dfu-1_0_0.hex -U lock:w:0x0f:m Fuses: (E:C3, H:98, L:5E)
3) Correct enumeration in dfu-programmer, I can then do:
dfu-programmer erase dfu-programmer flash blink.hex dfu-programmer start
Everything works as expected. The problem is I'd like to be able to flash a program over USB and then have it run when the AVR gets reset, but also be able to reprogram it in the same way.
Currently when it turns on, it'll go into the bootloader and I can only start the program using start. This is fine for debugging whilst connected to the computer, but it means I can't run an application without manually starting it over the command line (unless I've missed something).
If I have BOOTRST turned off (H:0x99), then it starts the program on reset, but will no longer enumerate in dfu-programmer.
Is there a way to have the best of both worlds, e.g. like Arduino?