From 06f53eed83b4ad639698aeb9bcc1a3702e2ac7c4 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 1 Oct 2017 16:25:36 +1100 Subject: Fixed bootloaders not disabling global interrupts during erase and write operations (thanks to Zoltan). --- Bootloaders/DFU/BootloaderAPI.c | 24 ++++++++++++++++-------- Bootloaders/DFU/BootloaderAPI.h | 1 + Bootloaders/DFU/BootloaderDFU.c | 32 +++++++------------------------- 3 files changed, 24 insertions(+), 33 deletions(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderAPI.c b/Bootloaders/DFU/BootloaderAPI.c index 491c506d0..5198ea7f0 100644 --- a/Bootloaders/DFU/BootloaderAPI.c +++ b/Bootloaders/DFU/BootloaderAPI.c @@ -37,16 +37,22 @@ void BootloaderAPI_ErasePage(const uint32_t Address) { - boot_page_erase_safe(Address); - boot_spm_busy_wait(); - boot_rww_enable(); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + boot_page_erase_safe(Address); + boot_spm_busy_wait(); + boot_rww_enable(); + } } void BootloaderAPI_WritePage(const uint32_t Address) { - boot_page_write_safe(Address); - boot_spm_busy_wait(); - boot_rww_enable(); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + boot_page_write_safe(Address); + boot_spm_busy_wait(); + boot_rww_enable(); + } } void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word) @@ -71,6 +77,8 @@ uint8_t BootloaderAPI_ReadLock(void) void BootloaderAPI_WriteLock(const uint8_t LockBits) { - boot_lock_bits_set_safe(LockBits); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + boot_lock_bits_set_safe(LockBits); + } } - diff --git a/Bootloaders/DFU/BootloaderAPI.h b/Bootloaders/DFU/BootloaderAPI.h index 5169bbc3c..8f119d792 100644 --- a/Bootloaders/DFU/BootloaderAPI.h +++ b/Bootloaders/DFU/BootloaderAPI.h @@ -39,6 +39,7 @@ /* Includes: */ #include #include + #include #include #include diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 8da725d24..8e8011fe2 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -133,7 +133,7 @@ void Application_Jump_Check(void) JTAG_ENABLE(); #else /* Check if the device's BOOTRST fuse is set */ - if (boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS) & FUSE_BOOTRST) + if (BootloaderAPI_ReadFuse(GET_HIGH_FUSE_BITS) & FUSE_BOOTRST) { /* If the reset source was not an external reset or the key is correct, clear it and jump to the application */ if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY)) @@ -351,7 +351,7 @@ void EVENT_USB_Device_ControlRequest(void) } /* Write the next word into the current flash page */ - boot_page_fill(CurrFlashAddress.Long, Endpoint_Read_16_LE()); + BootloaderAPI_FillWord(CurrFlashAddress.Long, Endpoint_Read_16_LE()); /* Adjust counters */ WordsInFlashPage += 1; @@ -361,8 +361,7 @@ void EVENT_USB_Device_ControlRequest(void) if ((WordsInFlashPage == (SPM_PAGESIZE >> 1)) || !(WordsRemaining)) { /* Commit the flash page to memory */ - boot_page_write(CurrFlashPageStartAddress); - boot_spm_busy_wait(); + BootloaderAPI_WritePage(CurrFlashPageStartAddress); /* Check if programming incomplete */ if (WordsRemaining) @@ -371,17 +370,13 @@ void EVENT_USB_Device_ControlRequest(void) WordsInFlashPage = 0; /* Erase next page's temp buffer */ - boot_page_erase(CurrFlashAddress.Long); - boot_spm_busy_wait(); + BootloaderAPI_ErasePage(CurrFlashAddress.Long); } } } /* Once programming complete, start address equals the end address */ StartAddr = EndAddr; - - /* Re-enable the RWW section of flash */ - boot_rww_enable(); } else // Write EEPROM { @@ -691,8 +686,7 @@ static void ProcessMemProgCommand(void) } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; /* Erase the current page's temp buffer */ - boot_page_erase(CurrFlashAddress.Long); - boot_spm_busy_wait(); + BootloaderAPI_ErasePage(CurrFlashAddress.Long); } /* Set the state so that the next DNLOAD requests reads in the firmware */ @@ -789,21 +783,9 @@ static void ProcessWriteCommand(void) } else if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) // Erase flash { - uint32_t CurrFlashAddress = 0; - /* Clear the application section of flash */ - while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR) - { - boot_page_erase(CurrFlashAddress); - boot_spm_busy_wait(); - boot_page_write(CurrFlashAddress); - boot_spm_busy_wait(); - - CurrFlashAddress += SPM_PAGESIZE; - } - - /* Re-enable the RWW section of flash as writing to the flash locks it out */ - boot_rww_enable(); + for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < (uint32_t)BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE) + BootloaderAPI_ErasePage(CurrFlashAddress); /* Memory has been erased, reset the security bit so that programming/reading is allowed */ IsSecure = false; -- cgit v1.2.3 From ad9225bdd34230e13333be5d4c29e4f96abc9b2b Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 4 Jan 2018 20:12:48 +1100 Subject: Update copyrights for 2018. --- Bootloaders/DFU/BootloaderAPI.c | 4 ++-- Bootloaders/DFU/BootloaderAPI.h | 4 ++-- Bootloaders/DFU/BootloaderAPITable.S | 4 ++-- Bootloaders/DFU/BootloaderDFU.c | 4 ++-- Bootloaders/DFU/BootloaderDFU.h | 4 ++-- Bootloaders/DFU/Config/AppConfig.h | 4 ++-- Bootloaders/DFU/Config/LUFAConfig.h | 4 ++-- Bootloaders/DFU/Descriptors.c | 4 ++-- Bootloaders/DFU/Descriptors.h | 4 ++-- Bootloaders/DFU/makefile | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderAPI.c b/Bootloaders/DFU/BootloaderAPI.c index 5198ea7f0..5e8083ed3 100644 --- a/Bootloaders/DFU/BootloaderAPI.c +++ b/Bootloaders/DFU/BootloaderAPI.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderAPI.h b/Bootloaders/DFU/BootloaderAPI.h index 8f119d792..47b5bd223 100644 --- a/Bootloaders/DFU/BootloaderAPI.h +++ b/Bootloaders/DFU/BootloaderAPI.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderAPITable.S b/Bootloaders/DFU/BootloaderAPITable.S index 95fd8e5c3..1d15aae2c 100644 --- a/Bootloaders/DFU/BootloaderAPITable.S +++ b/Bootloaders/DFU/BootloaderAPITable.S @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 8e8011fe2..b13917f45 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index a97ba6c7e..04c8e1ab0 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Config/AppConfig.h b/Bootloaders/DFU/Config/AppConfig.h index 3acf33c7e..df54cf249 100644 --- a/Bootloaders/DFU/Config/AppConfig.h +++ b/Bootloaders/DFU/Config/AppConfig.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Config/LUFAConfig.h b/Bootloaders/DFU/Config/LUFAConfig.h index 59ae519e4..6be69e6dc 100644 --- a/Bootloaders/DFU/Config/LUFAConfig.h +++ b/Bootloaders/DFU/Config/LUFAConfig.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index f7fe1cbb4..be21f28d4 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Descriptors.h b/Bootloaders/DFU/Descriptors.h index 5487f88f3..61987285f 100644 --- a/Bootloaders/DFU/Descriptors.h +++ b/Bootloaders/DFU/Descriptors.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2017. + Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index 6e15cedfc..6ac4ce645 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -1,6 +1,6 @@ # # LUFA Library -# Copyright (C) Dean Camera, 2017. +# Copyright (C) Dean Camera, 2018. # # dean [at] fourwalledcubicle [dot] com # www.lufa-lib.org -- cgit v1.2.3 From ba6d9c1a971db3c42bf0b054ebb64f72b3e3ddba Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 22 Jan 2018 16:14:44 +1100 Subject: Fixed bootloaders accepting flash writes to the bootloader region (thanks to NicoHood). --- Bootloaders/DFU/BootloaderAPI.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderAPI.c b/Bootloaders/DFU/BootloaderAPI.c index 5e8083ed3..c1e76d3bd 100644 --- a/Bootloaders/DFU/BootloaderAPI.c +++ b/Bootloaders/DFU/BootloaderAPI.c @@ -35,8 +35,20 @@ #include "BootloaderAPI.h" +static bool IsPageAddressValid(const uint32_t Address) +{ + /* Determine if the given page address is correctly aligned to the + start of a flash page. */ + bool PageAddressIsAligned = !(Address & (SPM_PAGESIZE - 1)); + + return (Address < BOOT_START_ADDR) && PageAddressIsAligned; +} + void BootloaderAPI_ErasePage(const uint32_t Address) { + if (! IsPageAddressValid(Address)) + return; + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { boot_page_erase_safe(Address); @@ -47,6 +59,9 @@ void BootloaderAPI_ErasePage(const uint32_t Address) void BootloaderAPI_WritePage(const uint32_t Address) { + if (! IsPageAddressValid(Address)) + return; + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { boot_page_write_safe(Address); -- cgit v1.2.3 From d6a528f9a03fe338e30d93f306e0482612e02e3e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 22 Jan 2018 16:27:39 +1100 Subject: Add short delays before detaching from the USB bus in the bootloaders (thanks to NicoHood). --- Bootloaders/DFU/BootloaderDFU.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index b13917f45..cafbd572b 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -191,6 +191,9 @@ int main(void) while (RunBootloader || WaitForExit) USB_USBTask(); + /* Wait a short time to end all USB transactions and then disconnect */ + _delay_us(1000); + /* Reset configured hardware back to their original states for the user application */ ResetHardware(); -- cgit v1.2.3 From 1e9148db894bca208d1076c291e85e134a2f3308 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 2 Apr 2018 14:51:18 +1000 Subject: Fix bootloaders incorrectly checking the BOOTRST fuse on start (thanks to Braden Kell). --- Bootloaders/DFU/BootloaderDFU.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index cafbd572b..3167c8972 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -133,7 +133,7 @@ void Application_Jump_Check(void) JTAG_ENABLE(); #else /* Check if the device's BOOTRST fuse is set */ - if (BootloaderAPI_ReadFuse(GET_HIGH_FUSE_BITS) & FUSE_BOOTRST) + if (!(BootloaderAPI_ReadFuse(GET_HIGH_FUSE_BITS) & ~FUSE_BOOTRST)) { /* If the reset source was not an external reset or the key is correct, clear it and jump to the application */ if (!(MCUSR & (1 << EXTRF)) || (MagicBootKey == MAGIC_BOOT_KEY)) -- cgit v1.2.3 From 45ab627b4a06f7d0186d7263c1afd30ef4a80dcd Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 22 Apr 2018 16:10:55 +1000 Subject: Update all project manufacturer strings with a generic title. --- Bootloaders/DFU/Descriptors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index be21f28d4..32256fa93 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -125,7 +125,7 @@ const USB_Descriptor_String_t LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGU * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ -const USB_Descriptor_String_t ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera"); +const USB_Descriptor_String_t ManufacturerString = USB_STRING_DESCRIPTOR(L"LUFA Library"); /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device -- cgit v1.2.3 From 101ed6b74e0d6549e53a7c8216147af37ffc70df Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 8 Jan 2019 19:59:41 +1100 Subject: Documentation: Update copyrights to 2019. --- Bootloaders/DFU/BootloaderAPI.c | 4 ++-- Bootloaders/DFU/BootloaderAPI.h | 4 ++-- Bootloaders/DFU/BootloaderAPITable.S | 4 ++-- Bootloaders/DFU/BootloaderDFU.c | 4 ++-- Bootloaders/DFU/BootloaderDFU.h | 4 ++-- Bootloaders/DFU/Config/AppConfig.h | 4 ++-- Bootloaders/DFU/Config/LUFAConfig.h | 4 ++-- Bootloaders/DFU/Descriptors.c | 4 ++-- Bootloaders/DFU/Descriptors.h | 4 ++-- Bootloaders/DFU/makefile | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderAPI.c b/Bootloaders/DFU/BootloaderAPI.c index c1e76d3bd..21d13bbe3 100644 --- a/Bootloaders/DFU/BootloaderAPI.c +++ b/Bootloaders/DFU/BootloaderAPI.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderAPI.h b/Bootloaders/DFU/BootloaderAPI.h index 47b5bd223..d00645b5a 100644 --- a/Bootloaders/DFU/BootloaderAPI.h +++ b/Bootloaders/DFU/BootloaderAPI.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderAPITable.S b/Bootloaders/DFU/BootloaderAPITable.S index 1d15aae2c..24208fb6c 100644 --- a/Bootloaders/DFU/BootloaderAPITable.S +++ b/Bootloaders/DFU/BootloaderAPITable.S @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 3167c8972..f20cdd72b 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index 04c8e1ab0..bef122c72 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Config/AppConfig.h b/Bootloaders/DFU/Config/AppConfig.h index df54cf249..db580c2b4 100644 --- a/Bootloaders/DFU/Config/AppConfig.h +++ b/Bootloaders/DFU/Config/AppConfig.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Config/LUFAConfig.h b/Bootloaders/DFU/Config/LUFAConfig.h index 6be69e6dc..cbe773b42 100644 --- a/Bootloaders/DFU/Config/LUFAConfig.h +++ b/Bootloaders/DFU/Config/LUFAConfig.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index 32256fa93..234469d37 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/Descriptors.h b/Bootloaders/DFU/Descriptors.h index 61987285f..d70b477dc 100644 --- a/Bootloaders/DFU/Descriptors.h +++ b/Bootloaders/DFU/Descriptors.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2018. + Copyright (C) Dean Camera, 2019. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2019 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index 6ac4ce645..dc54ba954 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -1,6 +1,6 @@ # # LUFA Library -# Copyright (C) Dean Camera, 2018. +# Copyright (C) Dean Camera, 2019. # # dean [at] fourwalledcubicle [dot] com # www.lufa-lib.org -- cgit v1.2.3 From a5e62ff2517e4add49ec67c1844b93e38144ea31 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 3 Jul 2019 07:36:03 -0700 Subject: QMK Lufa Bootloader Generation (qmk#2009) This re-implements the code changes into QMK's LUFA repo --- Bootloaders/DFU/BootloaderDFU.c | 12 ++++++------ Bootloaders/DFU/Descriptors.c | 12 ++++++++++-- Bootloaders/DFU/Descriptors.h | 9 ++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 10396f012..883afef03 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -196,7 +196,7 @@ int main(void) while (RunBootloader || WaitForExit) { USB_USBTask(); #if (BOARD == BOARD_QMK) - bool pressed = (PIN(QMK_ESC_ROW) & NUM(QMK_ESC_ROW)); + bool pressed = (PIN(QMK_ESC_INPUT) & NUM(QMK_ESC_INPUT)); if ((DFU_State == dfuIDLE) && (keypress > 5000) && pressed) { break; } @@ -234,12 +234,12 @@ static void SetupHardware(void) MCUCR = (1 << IVSEL); #if (BOARD == BOARD_QMK) - // column setup - DDR(QMK_ESC_COL) |= NUM(QMK_ESC_COL); - PORT(QMK_ESC_COL) |= NUM(QMK_ESC_COL); + // output setup + DDR(QMK_ESC_OUTPUT) |= NUM(QMK_ESC_OUTPUT); + PORT(QMK_ESC_OUTPUT) |= NUM(QMK_ESC_OUTPUT); // row setup - DDR(QMK_ESC_ROW) |= NUM(QMK_ESC_ROW); + DDR(QMK_ESC_INPUT) |= NUM(QMK_ESC_INPUT); #endif /* Initialize the USB and other board hardware drivers */ @@ -268,7 +268,7 @@ static void ResetHardware(void) MCUCR = 0; #if (BOARD == BOARD_QMK) - DDR(QMK_ESC_COL) = PORT(QMK_ESC_COL) = DDR(QMK_ESC_ROW) = PORT(QMK_ESC_ROW) = 0; + DDR(QMK_ESC_OUTPUT) = PORT(QMK_ESC_OUTPUT) = DDR(QMK_ESC_INPUT) = PORT(QMK_ESC_INPUT) = 0; #endif } diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index 37c36dcc3..dcad11d6c 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -36,6 +36,14 @@ */ #include "Descriptors.h" +#include "Keyboard.h" + + #ifndef MANUFACTURER + #define MANUFACTURER QMK +#endif +#ifndef PRODUCT + #define PRODUCT Keyboard +#endif /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall * device characteristics, including the supported USB version, control endpoint size and the @@ -125,13 +133,13 @@ const USB_Descriptor_String_t LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGU * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ -const USB_Descriptor_String_t ManufacturerString = USB_STRING_DESCRIPTOR(L"QMK"); +const USB_Descriptor_String_t ManufacturerString = USB_STRING_DESCRIPTOR(LSTR(MANUFACTURER)); /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device * Descriptor. */ -const USB_Descriptor_String_t ProductString = USB_STRING_DESCRIPTOR(L"KB"); +const USB_Descriptor_String_t ProductString = USB_STRING_DESCRIPTOR(LSTR(PRODUCT)); /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" * documentation) by the application code so that the address and size of a requested descriptor can be given diff --git a/Bootloaders/DFU/Descriptors.h b/Bootloaders/DFU/Descriptors.h index d70b477dc..40f604a1e 100644 --- a/Bootloaders/DFU/Descriptors.h +++ b/Bootloaders/DFU/Descriptors.h @@ -189,6 +189,13 @@ const uint16_t wIndex, const void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + + // convert to L string + #define LSTR(s) XLSTR(s) + #define XLSTR(s) L ## #s + // convert to string + #define STR(s) XSTR(s) + #define XSTR(s) #s -#endif +#endif -- cgit v1.2.3 From 57edb9b0976fad82bfd0384b16c6c3269e0d19ce Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 5 Jul 2019 04:26:46 -0700 Subject: Soft set LUFA DFU Bootloader options so they can be overridden for :bootloader target --- Bootloaders/DFU/makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Bootloaders/DFU') diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index 53c2b1a03..3df99a57d 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -11,11 +11,11 @@ # Run "make help" for target help. -MCU = atmega32u4 -ARCH = AVR8 +MCU ?= atmega32u4 +ARCH ?= AVR8 BOARD = QMK -F_CPU = 16000000 -F_USB = $(F_CPU) +F_CPU ?= 16000000 +F_USB ?= $(F_CPU) OPTIMIZATION = s TARGET = BootloaderDFU SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB) @@ -26,8 +26,8 @@ LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAG # Flash size and bootloader section sizes of the target, in KB. These must # match the target's total FLASH size and the bootloader size set in the # device's fuses. -FLASH_SIZE_KB = 32 -BOOT_SECTION_SIZE_KB = 4 +FLASH_SIZE_KB ?= 32 +BOOT_SECTION_SIZE_KB ?= 4 # Bootloader address calculation formulas # Do not modify these macros, but rather modify the dependent values above. -- cgit v1.2.3