1 DFU-Bootloader for Sparkfun Pro-Micro or Arduino Micro Boards
2 =============================================================
4 This Bootloader is optimized for Sparkfun Pro-Micro or Arduino Micro Boards.
5 The Bootloader will be entered by default for 5 seconds before the application
6 code is executed. This time frame is signaled by a slow blicking green LED on
7 the Pro-Micro board. So the application code can be reflashed via USB, although
8 the application itself might not support any software update or possibly blocks
9 the USB interface because of bugs. The reprogram of the CPU can be done with
10 the dfu-programmer program.
11 The bootloader will start after this 5 seconds timeout the application code,
12 if a reset vector to the application is programmed after a power-on or
13 external reset. This 5 second delay before the application code is started
14 by the bootloader can be omitted for other kind of resets like USB reset,
15 watchdog reset or low voltage (brown-out) or JTAG reset, if the FUSE_HWBE is
17 Once a DFU program interacts this the bootloader during this first 5 seconds,
18 the timeout is stopped and the application needs to be started by DFU bootloader
19 command manually or using another reset.
20 To use the CPU pin of the yellow LED as a SPI slave select input signal, the
21 yellow LED is disabled and not used by the bootloader. If this pin is also need
22 as input signal, naturally the application code shall never program this pin as
23 output. Note that this possibly requires changes in the Arduino core code for
24 ProMicro or Micro boards.
27 Bootloader compilation and programming
28 --------------------------------------
29 The Makefile is patched already to generate a DFU bootloader for ProMicro
30 Boards. Generating the hex files requires a make, avrdude, an AVR gcc compiler
31 installed and an ISP programmer available. The bootloader will be generated
34 cd .../lufa/Bootloaders/DFU
37 Initial the bootloader BootloaderDFU.hex file must be programmed via an ISP
38 programmer. Here an example for the USBasp ISP programmer:
40 avrdude -c usbasp -p m32u4 -U flash:r:flash-backup.hex:i -B100
41 avrdude -c usbasp -p m32u4 -U flash:w:BootloaderDFU.hex:i -B100
43 The option "-B100" is only required, if the internal oscilator is enabled and/or
44 the CPU clock prescaller is enabled.
49 Naturally the fuse settings is mostly depending on the application code. But at
50 least the in the hfuse some fuse bits are recommended:
51 - SPIEN: SPI ISP enabled as fallback
52 - BOOTRESET: Move the reset boot vector into the bootloader, because ProMicro
53 uses normally a power-on reset.
54 - BOOTSZ1, BOOTSZ0: define the bootloader of 4kByte size.
57 A fuses calculator can be found for the Atmega32U4 here:
58 https://www.engbedded.com/fusecalc/
60 Here fuses example for a ProMicro with 3.3V supply with debugging disabled:
61 lfuse: 0xff : CKDIV8, CKSEL0 (ext. 8 MHz Quarz)
62 hfuse: 0xd8 : SPIEN, BOOTSZ1, BOOTSZ0, BOOTRESET(4kByte Boot & Reset to Boot)
63 efuse: 0xXe : BODLEVEL0 (Brown-out 2.0V)
65 avrdude -c usbasp -p m32u4 -B100 -U efuse:w:0xce:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m
68 Here fuses example for a ProMicro with 3.3V supply with debugging enabled and
69 always starting the application over the bootloader:
70 lfuse: 0xff : CKDIV8, CKSEL0 (ext. 8 MHz Quarz)
71 hfuse: 0x18 : SPIEN, BOOTSZ1, BOOTSZ0, BOOTRESET
72 JTAGEN, OCDEN (4kByte Boot & Reset to Boot)
73 efuse: 0xX6 : BODLEVEL0, HWBE (Brown-out 2.0V)
75 avrdude -c usbasp -p m32u4 -B100 -U efuse:w:0xc6:m -U hfuse:w:0x18:m -U lfuse:w:0xff:m
80 The DFU bootloader flags of the programmed Pro-Micro can be read by a script:
81 read-dfu-bootld-flags.sh
83 This script runs naturally also be used for other boards, but might output different
84 results other than expected.