Switching an Arduino Leonardo to DFU

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have a look in the datasheet: www.atmel.com/Images/doc7618.pdf‎

Especially note chapter 3.

There is also some notes somewhere about how for instance dfu-programmer can switch an application over to dfu mode, if the application exports a dfu descriptor and uses the technique from the datasheet to switch over.

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok so sounds like the simple option is to set HWBE and use the /HWB pin - but that isn't possible on these boards because SparkFun designed them with it always grounded - doh! Well it's going to be usually connected while debugging so no harm.