From fe228f5141f501160927970890817037b417af97 Mon Sep 17 00:00:00 2001 From: Peter Henn Date: Fri, 7 Jan 2022 12:07:45 +0000 Subject: [PATCH] Add ProMicro bootloader DFU/README.md --- Bootloaders/DFU/README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Bootloaders/DFU/README.md diff --git a/Bootloaders/DFU/README.md b/Bootloaders/DFU/README.md new file mode 100644 index 000000000..b25591a72 --- /dev/null +++ b/Bootloaders/DFU/README.md @@ -0,0 +1,77 @@ +DFU-Bootloader for Sparkfun Pro-Micro or Arduino Micro Boards +============================================================= + +This Bootloader is optimized for Sparkfun Pro-Micro or Arduino Micro Boards. +The Bootloader will be entered by default for 5 seconds before the application +code is executed. This time frame is signaled by a slow blicking green LED on +the Pro-Micro board. So the application code can be reflashed via USB, although +the application itself might not support any software update or possibly blocks +the USB interface because of bugs. The reprogram of the CPU can be done with +the dfu-programmer program. +The bootloader will start after this 5 seconds timeout the application code, +if a reset vector to the application is programmed after a power-on or +external reset. This 5 second delay before the application code is started +by the bootloader can be omitted for other kind of resets like USB reset, +watchdog reset or low voltage (brown-out) or JTAG reset, if the FUSE_HWBE is +*not* programmed. +Once a DFU program interacts this the bootloader during this first 5 seconds, +the timeout is stopped and the application needs to be started by DFU bootloader +command manually or using another reset. +To use the CPU pin of the yellow LED as a SPI slave select input signal, the +yellow LED is disabled and not used by the bootloader. If this pin is also need +as input signal, naturally the application code shall never program this pin as +output. Note that this possibly requires changes in the Arduino core code for +ProMicro or Micro boards. + + +Bootloader compilation and programming +-------------------------------------- +The Makefile is patched already to generate a DFU bootloader for ProMicro +Boards. Generating the hex files requires a make, avrdude, an AVR gcc compiler +installed and an ISP programmer available. The bootloader will be generated +wiht a simple make: + + cd .../lufa/Bootloaders/DFU + make + +Initial the bootloader BootloaderDFU.hex file must be programmed via an ISP +programmer. Here an example for the USBasp ISP programmer: + + avrdude -c usbasp -p m32u4 -U flash:r:flash-backup.hex:i -B100 + avrdude -c usbasp -p m32u4 -U flash:w:BootloaderDFU.hex:i -B100 + +The option "-B100" is only required, if the internal oscilator is enabled and/or +the CPU clock prescaller is enabled. + + +AVR Fuse settings +----------------- +Naturally the fuse settings is mostly depending on the application code. But at +least the in the hfuse some fuse bits are recommended: +- SPIEN: SPI ISP enabled as fallback +- BOOTRESET: Move the reset boot vector into the bootloader, because ProMicro + uses normally a power-on reset. +- BOOTSZ1, BOOTSZ0: define the bootloader of 4kByte size. + + +A fuses calculator can be found for the Atmega32U4 here: +https://www.engbedded.com/fusecalc/ + +Here fuses example for a ProMicro with 3.3V supply with debugging disabled: + lfuse: 0xff : CKDIV8, CKSEL0 (ext. 8 MHz Quarz) + hfuse: 0xd8 : SPIEN, BOOTSZ1, BOOTSZ0, BOOTRESET(4kByte Boot & Reset to Boot) + efuse: 0xXe : BODLEVEL0 (Brown-out 2.0V) + + avrdude -c usbasp -p m32u4 -B100 -U efuse:w:0xce:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m + + +Here fuses example for a ProMicro with 3.3V supply with debugging enabled and +always starting the application over the bootloader: + lfuse: 0xff : CKDIV8, CKSEL0 (ext. 8 MHz Quarz) + hfuse: 0x18 : SPIEN, BOOTSZ1, BOOTSZ0, BOOTRESET + JTAGEN, OCDEN (4kByte Boot & Reset to Boot) + efuse: 0xX6 : BODLEVEL0, HWBE (Brown-out 2.0V) + + avrdude -c usbasp -p m32u4 -B100 -U efuse:w:0xc6:m -U hfuse:w:0x18:m -U lfuse:w:0xff:m + + -- 2.11.0