aboutsummaryrefslogtreecommitdiff
path: root/variants
diff options
context:
space:
mode:
authorMartino Facchin <m.facchin@arduino.cc>2016-04-06 16:33:14 +0200
committerMartino Facchin <m.facchin@arduino.cc>2016-04-06 17:41:06 +0200
commit5e194bd8efe8dcd2fb6eaa13cec1a2a642c5254a (patch)
treef34c3a6aad5f9e3b43e121948bfa3563c1dd3495 /variants
parent71b87bf26bc7b485dc1c111603fd09327c1b6c53 (diff)
[AVR] Discover newer bootloader at runtime
Replaces #4280, only checks for the bootloader once Tested with Hoodloader2, should work with every LUFA-derived bootloader released after 2014 (.apitable_signatures section must be placed at end of the flash) BootloaderAPITable.S : .global BootloaderAPI_Signatures BootloaderAPI_Signatures: .long BOOT_START_ADDR ; Start address of the bootloader .word 0xDF00 ; Signature for the CDC class bootloader .word 0xDCFB ; Signature for a LUFA class bootloader makefile: BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
Diffstat (limited to 'variants')
-rw-r--r--variants/leonardo/pins_arduino.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/variants/leonardo/pins_arduino.h b/variants/leonardo/pins_arduino.h
index 6027223..7e0f669 100644
--- a/variants/leonardo/pins_arduino.h
+++ b/variants/leonardo/pins_arduino.h
@@ -366,4 +366,22 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
// Alias SerialUSB to Serial
#define SerialUSB SERIAL_PORT_USBVIRTUAL
+// Bootloader related fields
+// Old Caterian bootloader places the MAGIC key into unsafe RAM locations (it can be rewritten
+// by the running sketch before to actual reboot).
+// Newer bootloaders, recognizable by the LUFA "signature" at the end of the flash, can handle both
+// the usafe and the safe location. Check once (in USBCore.cpp) if the bootloader in new, then set the global
+// _updatedLUFAbootloader variable to true/false and place the magic key consequently
+#ifndef MAGIC_KEY
+#define MAGIC_KEY 0x7777
+#endif
+
+#ifndef MAGIC_KEY_POS
+#define MAGIC_KEY_POS 0x0800
+#endif
+
+#ifndef NEW_LUFA_SIGNATURE
+#define NEW_LUFA_SIGNATURE 0xDCFB
+#endif
+
#endif /* Pins_Arduino_h */