From cf4575b94a3c65e6535a159fc71fc885aebc2620 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Aug 2019 14:02:40 -0700 Subject: Fix the LUFA lib to use a submodule instead of just files (#6245) * Remove LUFA files * Update descriptions for newer version of LUFA * Create PR6245.md * Fix CDC(Serial) type errors * Fix missed merge conflict for AUDIO_DTYPE_CSInterface --- lib/lufa/Bootloaders/DFU/BootloaderAPI.c | 76 - lib/lufa/Bootloaders/DFU/BootloaderAPI.h | 58 - lib/lufa/Bootloaders/DFU/BootloaderAPITable.S | 91 - lib/lufa/Bootloaders/DFU/BootloaderDFU.c | 891 --------- lib/lufa/Bootloaders/DFU/BootloaderDFU.h | 216 --- lib/lufa/Bootloaders/DFU/BootloaderDFU.txt | 235 --- lib/lufa/Bootloaders/DFU/Config/AppConfig.h | 48 - lib/lufa/Bootloaders/DFU/Config/LUFAConfig.h | 93 - lib/lufa/Bootloaders/DFU/Descriptors.c | 193 -- lib/lufa/Bootloaders/DFU/Descriptors.h | 200 --- lib/lufa/Bootloaders/DFU/asf.xml | 156 -- lib/lufa/Bootloaders/DFU/doxyfile | 2396 ------------------------- lib/lufa/Bootloaders/DFU/makefile | 62 - 13 files changed, 4715 deletions(-) delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderAPI.c delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderAPI.h delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderAPITable.S delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderDFU.c delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderDFU.h delete mode 100644 lib/lufa/Bootloaders/DFU/BootloaderDFU.txt delete mode 100644 lib/lufa/Bootloaders/DFU/Config/AppConfig.h delete mode 100644 lib/lufa/Bootloaders/DFU/Config/LUFAConfig.h delete mode 100644 lib/lufa/Bootloaders/DFU/Descriptors.c delete mode 100644 lib/lufa/Bootloaders/DFU/Descriptors.h delete mode 100644 lib/lufa/Bootloaders/DFU/asf.xml delete mode 100644 lib/lufa/Bootloaders/DFU/doxyfile delete mode 100644 lib/lufa/Bootloaders/DFU/makefile (limited to 'lib/lufa/Bootloaders/DFU') diff --git a/lib/lufa/Bootloaders/DFU/BootloaderAPI.c b/lib/lufa/Bootloaders/DFU/BootloaderAPI.c deleted file mode 100644 index 491c506d0f..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderAPI.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Bootloader user application API functions. - */ - -#include "BootloaderAPI.h" - -void BootloaderAPI_ErasePage(const uint32_t Address) -{ - 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(); -} - -void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word) -{ - boot_page_fill_safe(Address, Word); -} - -uint8_t BootloaderAPI_ReadSignature(const uint16_t Address) -{ - return boot_signature_byte_get(Address); -} - -uint8_t BootloaderAPI_ReadFuse(const uint16_t Address) -{ - return boot_lock_fuse_bits_get(Address); -} - -uint8_t BootloaderAPI_ReadLock(void) -{ - return boot_lock_fuse_bits_get(GET_LOCK_BITS); -} - -void BootloaderAPI_WriteLock(const uint8_t LockBits) -{ - boot_lock_bits_set_safe(LockBits); -} - diff --git a/lib/lufa/Bootloaders/DFU/BootloaderAPI.h b/lib/lufa/Bootloaders/DFU/BootloaderAPI.h deleted file mode 100644 index 5169bbc3c4..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderAPI.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for BootloaderAPI.c. - */ - -#ifndef _BOOTLOADER_API_H_ -#define _BOOTLOADER_API_H_ - - /* Includes: */ - #include - #include - #include - - #include - - #include "Config/AppConfig.h" - - /* Function Prototypes: */ - void BootloaderAPI_ErasePage(const uint32_t Address); - void BootloaderAPI_WritePage(const uint32_t Address); - void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word); - uint8_t BootloaderAPI_ReadSignature(const uint16_t Address); - uint8_t BootloaderAPI_ReadFuse(const uint16_t Address); - uint8_t BootloaderAPI_ReadLock(void); - void BootloaderAPI_WriteLock(const uint8_t LockBits); - -#endif - diff --git a/lib/lufa/Bootloaders/DFU/BootloaderAPITable.S b/lib/lufa/Bootloaders/DFU/BootloaderAPITable.S deleted file mode 100644 index 95fd8e5c37..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderAPITable.S +++ /dev/null @@ -1,91 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -; Trampolines to actual API implementations if the target address is outside the -; range of a rjmp instruction (can happen with large bootloader sections) -.section .apitable_trampolines, "ax" -.global BootloaderAPI_Trampolines -BootloaderAPI_Trampolines: - - BootloaderAPI_ErasePage_Trampoline: - jmp BootloaderAPI_ErasePage - BootloaderAPI_WritePage_Trampoline: - jmp BootloaderAPI_WritePage - BootloaderAPI_FillWord_Trampoline: - jmp BootloaderAPI_FillWord - BootloaderAPI_ReadSignature_Trampoline: - jmp BootloaderAPI_ReadSignature - BootloaderAPI_ReadFuse_Trampoline: - jmp BootloaderAPI_ReadFuse - BootloaderAPI_ReadLock_Trampoline: - jmp BootloaderAPI_ReadLock - BootloaderAPI_WriteLock_Trampoline: - jmp BootloaderAPI_WriteLock - BootloaderAPI_UNUSED1: - ret - BootloaderAPI_UNUSED2: - ret - BootloaderAPI_UNUSED3: - ret - BootloaderAPI_UNUSED4: - ret - BootloaderAPI_UNUSED5: - ret - - - -; API function jump table -.section .apitable_jumptable, "ax" -.global BootloaderAPI_JumpTable -BootloaderAPI_JumpTable: - - rjmp BootloaderAPI_ErasePage_Trampoline - rjmp BootloaderAPI_WritePage_Trampoline - rjmp BootloaderAPI_FillWord_Trampoline - rjmp BootloaderAPI_ReadSignature_Trampoline - rjmp BootloaderAPI_ReadFuse_Trampoline - rjmp BootloaderAPI_ReadLock_Trampoline - rjmp BootloaderAPI_WriteLock_Trampoline - rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1 - rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2 - rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3 - rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4 - rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5 - - - -; Bootloader table signatures and information -.section .apitable_signatures, "ax" -.global BootloaderAPI_Signatures -BootloaderAPI_Signatures: - - .long BOOT_START_ADDR ; Start address of the bootloader - .word 0xDF10 ; Signature for the DFU class bootloader, V1 - .word 0xDCFB ; Signature for a LUFA class bootloader diff --git a/lib/lufa/Bootloaders/DFU/BootloaderDFU.c b/lib/lufa/Bootloaders/DFU/BootloaderDFU.c deleted file mode 100644 index a2307219ec..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderDFU.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Main source file for the DFU class bootloader. This file contains the complete bootloader logic. - */ - -#define INCLUDE_FROM_BOOTLOADER_C -#include "BootloaderDFU.h" - -/** Flag to indicate if the bootloader is currently running in secure mode, disallowing memory operations - * other than erase. This is initially set to the value set by SECURE_MODE, and cleared by the bootloader - * once a memory erase has completed in a bootloader session. - */ -static bool IsSecure = SECURE_MODE; - -/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run - * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application - * jumped to via an indirect jump to location 0x0000 (or other location specified by the host). - */ -static bool RunBootloader = true; - -/** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and - * jump to the application address it specifies, it sends two sequential commands which must be properly - * acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set, - * causing the bootloader to wait for the final exit command before shutting down. - */ -static bool WaitForExit = false; - -/** Current DFU state machine state, one of the values in the DFU_State_t enum. */ -static uint8_t DFU_State = dfuIDLE; - -/** Status code of the last executed DFU command. This is set to one of the values in the DFU_Status_t enum after - * each operation, and returned to the host when a Get Status DFU request is issued. - */ -static uint8_t DFU_Status = OK; - -/** Data containing the DFU command sent from the host. */ -static DFU_Command_t SentCommand; - -/** Response to the last issued Read Data DFU command. Unlike other DFU commands, the read command - * requires a single byte response from the bootloader containing the read data when the next DFU_UPLOAD command - * is issued by the host. - */ -static uint8_t ResponseByte; - -/** Pointer to the start of the user application. By default this is 0x0000 (the reset vector), however the host - * may specify an alternate address when issuing the application soft-start command. - */ -static AppPtr_t AppStartPtr = (AppPtr_t)0x0000; - -/** 64-bit flash page number. This is concatenated with the current 16-bit address on USB AVRs containing more than - * 64KB of flash memory. - */ -static uint8_t Flash64KBPage = 0; - -/** Memory start address, indicating the current address in the memory being addressed (either FLASH or EEPROM - * depending on the issued command from the host). - */ -static uint16_t StartAddr = 0x0000; - -/** Memory end address, indicating the end address to read from/write to in the memory being addressed (either FLASH - * of EEPROM depending on the issued command from the host). - */ -static uint16_t EndAddr = 0x0000; - -/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader - * will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held - * low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value - * \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start. - */ -uint16_t MagicBootKey ATTR_NO_INIT; - - -/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application - * start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid, - * this will force the user application to start via a software jump. - */ -void Application_Jump_Check(void) -{ - bool JumpToApplication = false; - - #if (BOARD == BOARD_LEONARDO) - /* Enable pull-up on the IO13 pin so we can use it to select the mode */ - PORTC |= (1 << 7); - Delay_MS(10); - - /* If IO13 is not jumpered to ground, start the user application instead */ - JumpToApplication = ((PINC & (1 << 7)) != 0); - - /* Disable pull-up after the check has completed */ - PORTC &= ~(1 << 7); - #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) - /* Disable JTAG debugging */ - JTAG_DISABLE(); - - /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */ - PORTF |= (1 << 4); - Delay_MS(10); - - /* If the TCK pin is not jumpered to ground, start the user application instead */ - JumpToApplication = ((PINF & (1 << 4)) != 0); - - /* Re-enable JTAG debugging */ - 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 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)) - // JumpToApplication = true; - - /* Clear reset source */ - MCUSR &= ~(1 << EXTRF); - } - else - { - /* If the reset source was the bootloader and the key is correct, clear it and jump to the application; - * this can happen in the HWBE fuse is set, and the HBE pin is low during the watchdog reset */ - //if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) - // JumpToApplication = true; - - /* Clear reset source */ - MCUSR &= ~(1 << WDRF); - } - #endif - - /* Don't run the user application if the reset vector is blank (no app loaded) */ - bool ApplicationValid = (pgm_read_word_near(0) != 0xFFFF); - - /* If a request has been made to jump to the user application, honor it */ - if (JumpToApplication && ApplicationValid) - { - /* Turn off the watchdog */ - MCUSR &= ~(1 << WDRF); - wdt_disable(); - - /* Clear the boot key and jump to the user application */ - MagicBootKey = 0; - - // cppcheck-suppress constStatement - ((void (*)(void))0x0000)(); - } -} - -/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously - * runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start - * the loaded application code. - */ -int main(void) -{ - /* Configure hardware required by the bootloader */ - SetupHardware(); - - /* Turn on first LED on the board to indicate that the bootloader has started */ - LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED2); - - /* Enable global interrupts so that the USB stack can function */ - GlobalInterruptEnable(); - - - #if (BOARD == BOARD_QMK) - uint16_t keypress = 0; - #endif - - /* Run the USB management task while the bootloader is supposed to be running */ - while (RunBootloader || WaitForExit) { - USB_USBTask(); - #if (BOARD == BOARD_QMK) - bool pressed = (PIN(QMK_ESC_INPUT) & NUM(QMK_ESC_INPUT)); - if ((DFU_State == dfuIDLE) && (keypress > 5000) && pressed) { - break; - } - if (pressed) { - keypress++; - } else { - keypress = 0; - } - - #endif - } - - /* Reset configured hardware back to their original states for the user application */ - ResetHardware(); - - /* Start the user application */ - AppStartPtr(); -} - -/** Configures all hardware required for the bootloader. */ -static void SetupHardware(void) -{ - /* Disable watchdog if enabled by bootloader/fuses */ - MCUSR &= ~(1 << WDRF); - wdt_disable(); - - /* Disable clock division */ - clock_prescale_set(clock_div_1); - - /* Relocate the interrupt vector table to the bootloader section */ - MCUCR = (1 << IVCE); - MCUCR = (1 << IVSEL); - - #if (BOARD == BOARD_QMK) - // output setup - DDR(QMK_ESC_OUTPUT) |= NUM(QMK_ESC_OUTPUT); - PORT(QMK_ESC_OUTPUT) |= NUM(QMK_ESC_OUTPUT); - - // input setup - DDR(QMK_ESC_INPUT) |= NUM(QMK_ESC_INPUT); - #endif - - /* Initialize the USB and other board hardware drivers */ - USB_Init(); - LEDs_Init(); - - /* Bootloader active LED toggle timer initialization */ - TIMSK1 = (1 << TOIE1); - TCCR1B = ((1 << CS11) | (1 << CS10)); - -} - -/** Resets all configured hardware required for the bootloader back to their original states. */ -static void ResetHardware(void) -{ - /* Shut down the USB and other board hardware drivers */ - USB_Disable(); - LEDs_Disable(); - - /* Disable Bootloader active LED toggle timer */ - TIMSK1 = 0; - TCCR1B = 0; - - /* Relocate the interrupt vector table back to the application section */ - MCUCR = (1 << IVCE); - MCUCR = 0; - - #if (BOARD == BOARD_QMK) - DDR(QMK_ESC_OUTPUT) = PORT(QMK_ESC_OUTPUT) = DDR(QMK_ESC_INPUT) = PORT(QMK_ESC_INPUT) = 0; - #endif -} - -/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */ -ISR(TIMER1_OVF_vect, ISR_BLOCK) -{ - LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2); -} - -/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to - * the device from the USB host before passing along unhandled control requests to the library for processing - * internally. - */ -void EVENT_USB_Device_ControlRequest(void) -{ - /* Ignore any requests that aren't directed to the DFU interface */ - if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != - (REQTYPE_CLASS | REQREC_INTERFACE)) - { - return; - } - - /* Activity - toggle indicator LEDs */ - LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2); - - /* Get the size of the command and data from the wLength value */ - SentCommand.DataSize = USB_ControlRequest.wLength; - - switch (USB_ControlRequest.bRequest) - { - case DFU_REQ_DNLOAD: - Endpoint_ClearSETUP(); - - /* Check if bootloader is waiting to terminate */ - if (WaitForExit) - { - /* Bootloader is terminating - process last received command */ - ProcessBootloaderCommand(); - - /* Indicate that the last command has now been processed - free to exit bootloader */ - WaitForExit = false; - } - - /* If the request has a data stage, load it into the command struct */ - if (SentCommand.DataSize) - { - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - /* First byte of the data stage is the DNLOAD request's command */ - SentCommand.Command = Endpoint_Read_8(); - - /* One byte of the data stage is the command, so subtract it from the total data bytes */ - SentCommand.DataSize--; - - /* Load in the rest of the data stage as command parameters */ - for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) && - Endpoint_BytesInEndpoint(); DataByte++) - { - SentCommand.Data[DataByte] = Endpoint_Read_8(); - SentCommand.DataSize--; - } - - /* Process the command */ - ProcessBootloaderCommand(); - } - - /* Check if currently downloading firmware */ - if (DFU_State == dfuDNLOAD_IDLE) - { - if (!(SentCommand.DataSize)) - { - DFU_State = dfuIDLE; - } - else - { - /* Throw away the filler bytes before the start of the firmware */ - DiscardFillerBytes(DFU_FILLER_BYTES_SIZE); - - /* Throw away the packet alignment filler bytes before the start of the firmware */ - DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE); - - /* Calculate the number of bytes remaining to be written */ - uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); - - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash - { - /* Calculate the number of words to be written from the number of bytes to be written */ - uint16_t WordsRemaining = (BytesRemaining >> 1); - - union - { - uint16_t Words[2]; - uint32_t Long; - } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; - - uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long; - uint8_t WordsInFlashPage = 0; - - while (WordsRemaining--) - { - /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ - if (!(Endpoint_BytesInEndpoint())) - { - Endpoint_ClearOUT(); - - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - - /* Write the next word into the current flash page */ - boot_page_fill(CurrFlashAddress.Long, Endpoint_Read_16_LE()); - - /* Adjust counters */ - WordsInFlashPage += 1; - CurrFlashAddress.Long += 2; - - /* See if an entire page has been written to the flash page buffer */ - if ((WordsInFlashPage == (SPM_PAGESIZE >> 1)) || !(WordsRemaining)) - { - /* Commit the flash page to memory */ - boot_page_write(CurrFlashPageStartAddress); - boot_spm_busy_wait(); - - /* Check if programming incomplete */ - if (WordsRemaining) - { - CurrFlashPageStartAddress = CurrFlashAddress.Long; - WordsInFlashPage = 0; - - /* Erase next page's temp buffer */ - boot_page_erase(CurrFlashAddress.Long); - boot_spm_busy_wait(); - } - } - } - - /* Once programming complete, start address equals the end address */ - StartAddr = EndAddr; - - /* Re-enable the RWW section of flash */ - boot_rww_enable(); - } - else // Write EEPROM - { - while (BytesRemaining--) - { - /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ - if (!(Endpoint_BytesInEndpoint())) - { - Endpoint_ClearOUT(); - - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - - /* Read the byte from the USB interface and write to to the EEPROM */ - eeprom_update_byte((uint8_t*)StartAddr, Endpoint_Read_8()); - - /* Adjust counters */ - StartAddr++; - } - } - - /* Throw away the currently unused DFU file suffix */ - DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE); - } - } - - Endpoint_ClearOUT(); - - Endpoint_ClearStatusStage(); - - break; - case DFU_REQ_UPLOAD: - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - if (DFU_State != dfuUPLOAD_IDLE) - { - if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check - { - /* Blank checking is performed in the DFU_DNLOAD request - if we get here we've told the host - that the memory isn't blank, and the host is requesting the first non-blank address */ - Endpoint_Write_16_LE(StartAddr); - } - else - { - /* Idle state upload - send response to last issued command */ - Endpoint_Write_8(ResponseByte); - } - } - else - { - /* Determine the number of bytes remaining in the current block */ - uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); - - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read FLASH - { - /* Calculate the number of words to be written from the number of bytes to be written */ - uint16_t WordsRemaining = (BytesRemaining >> 1); - - union - { - uint16_t Words[2]; - uint32_t Long; - } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; - - while (WordsRemaining--) - { - /* Check if endpoint is full - if so clear it and wait until ready for next packet */ - if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) - { - Endpoint_ClearIN(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - - /* Read the flash word and send it via USB to the host */ - #if (FLASHEND > 0xFFFF) - Endpoint_Write_16_LE(pgm_read_word_far(CurrFlashAddress.Long)); - #else - Endpoint_Write_16_LE(pgm_read_word(CurrFlashAddress.Long)); - #endif - - /* Adjust counters */ - CurrFlashAddress.Long += 2; - } - - /* Once reading is complete, start address equals the end address */ - StartAddr = EndAddr; - } - else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM - { - while (BytesRemaining--) - { - /* Check if endpoint is full - if so clear it and wait until ready for next packet */ - if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) - { - Endpoint_ClearIN(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - - /* Read the EEPROM byte and send it via USB to the host */ - Endpoint_Write_8(eeprom_read_byte((uint8_t*)StartAddr)); - - /* Adjust counters */ - StartAddr++; - } - } - - /* Return to idle state */ - DFU_State = dfuIDLE; - } - - Endpoint_ClearIN(); - - Endpoint_ClearStatusStage(); - break; - case DFU_REQ_GETSTATUS: - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - /* Write 8-bit status value */ - Endpoint_Write_8(DFU_Status); - - /* Write 24-bit poll timeout value */ - Endpoint_Write_8(0); - Endpoint_Write_16_LE(0); - - /* Write 8-bit state value */ - Endpoint_Write_8(DFU_State); - - /* Write 8-bit state string ID number */ - Endpoint_Write_8(0); - - Endpoint_ClearIN(); - - Endpoint_ClearStatusStage(); - break; - case DFU_REQ_CLRSTATUS: - Endpoint_ClearSETUP(); - - /* Reset the status value variable to the default OK status */ - DFU_Status = OK; - - Endpoint_ClearStatusStage(); - break; - case DFU_REQ_GETSTATE: - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - /* Write the current device state to the endpoint */ - Endpoint_Write_8(DFU_State); - - Endpoint_ClearIN(); - - Endpoint_ClearStatusStage(); - break; - case DFU_REQ_ABORT: - Endpoint_ClearSETUP(); - - /* Reset the current state variable to the default idle state */ - DFU_State = dfuIDLE; - - Endpoint_ClearStatusStage(); - break; - } -} - -/** Routine to discard the specified number of bytes from the control endpoint stream. This is used to - * discard unused bytes in the stream from the host, including the memory program block suffix. - * - * \param[in] NumberOfBytes Number of bytes to discard from the host from the control endpoint - */ -static void DiscardFillerBytes(uint8_t NumberOfBytes) -{ - while (NumberOfBytes--) - { - if (!(Endpoint_BytesInEndpoint())) - { - Endpoint_ClearOUT(); - - /* Wait until next data packet received */ - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - else - { - Endpoint_Discard_8(); - } - } -} - -/** Routine to process an issued command from the host, via a DFU_DNLOAD request wrapper. This routine ensures - * that the command is allowed based on the current secure mode flag value, and passes the command off to the - * appropriate handler function. - */ -static void ProcessBootloaderCommand(void) -{ - /* Check if device is in secure mode */ - if (IsSecure) - { - /* Don't process command unless it is a READ or chip erase command */ - if (!(((SentCommand.Command == COMMAND_WRITE) && - IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) || - (SentCommand.Command == COMMAND_READ))) - { - /* Set the state and status variables to indicate the error */ - DFU_State = dfuERROR; - DFU_Status = errWRITE; - - /* Stall command */ - Endpoint_StallTransaction(); - - /* Don't process the command */ - return; - } - } - - /* Dispatch the required command processing routine based on the command type */ - switch (SentCommand.Command) - { - case COMMAND_PROG_START: - ProcessMemProgCommand(); - break; - case COMMAND_DISP_DATA: - ProcessMemReadCommand(); - break; - case COMMAND_WRITE: - ProcessWriteCommand(); - break; - case COMMAND_READ: - ProcessReadCommand(); - break; - case COMMAND_CHANGE_BASE_ADDR: - if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x03, 0x00)) // Set 64KB flash page command - Flash64KBPage = SentCommand.Data[2]; - - break; - } -} - -/** Routine to concatenate the given pair of 16-bit memory start and end addresses from the host, and store them - * in the StartAddr and EndAddr global variables. - */ -static void LoadStartEndAddresses(void) -{ - union - { - uint8_t Bytes[2]; - uint16_t Word; - } Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}}, - {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}}; - - /* Load in the start and ending read addresses from the sent data packet */ - StartAddr = Address[0].Word; - EndAddr = Address[1].Word; -} - -/** Handler for a Memory Program command issued by the host. This routine handles the preparations needed - * to write subsequent data from the host into the specified memory. - */ -static void ProcessMemProgCommand(void) -{ - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Write FLASH command - IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Write EEPROM command - { - /* Load in the start and ending read addresses */ - LoadStartEndAddresses(); - - /* If FLASH is being written to, we need to pre-erase the first page to write to */ - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) - { - union - { - uint16_t Words[2]; - uint32_t Long; - } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; - - /* Erase the current page's temp buffer */ - boot_page_erase(CurrFlashAddress.Long); - boot_spm_busy_wait(); - } - - /* Set the state so that the next DNLOAD requests reads in the firmware */ - DFU_State = dfuDNLOAD_IDLE; - } -} - -/** Handler for a Memory Read command issued by the host. This routine handles the preparations needed - * to read subsequent data from the specified memory out to the host, as well as implementing the memory - * blank check command. - */ -static void ProcessMemReadCommand(void) -{ - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Read FLASH command - IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM command - { - /* Load in the start and ending read addresses */ - LoadStartEndAddresses(); - - /* Set the state so that the next UPLOAD requests read out the firmware */ - DFU_State = dfuUPLOAD_IDLE; - } - else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank check FLASH command - { - uint32_t CurrFlashAddress = 0; - - while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR) - { - /* Check if the current byte is not blank */ - #if (FLASHEND > 0xFFFF) - if (pgm_read_byte_far(CurrFlashAddress) != 0xFF) - #else - if (pgm_read_byte(CurrFlashAddress) != 0xFF) - #endif - { - /* Save the location of the first non-blank byte for response back to the host */ - Flash64KBPage = (CurrFlashAddress >> 16); - StartAddr = CurrFlashAddress; - - /* Set state and status variables to the appropriate error values */ - DFU_State = dfuERROR; - DFU_Status = errCHECK_ERASED; - - break; - } - - CurrFlashAddress++; - } - } -} - -/** Handler for a Data Write command issued by the host. This routine handles non-programming commands such as - * bootloader exit (both via software jumps and hardware watchdog resets) and flash memory erasure. - */ -static void ProcessWriteCommand(void) -{ - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x03)) // Start application - { - /* Indicate that the bootloader is terminating */ - WaitForExit = true; - - /* Check if data supplied for the Start Program command - no data executes the program */ - if (SentCommand.DataSize) - { - if (SentCommand.Data[1] == 0x01) // Start via jump - { - union - { - uint8_t Bytes[2]; - AppPtr_t FuncPtr; - } Address = {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}; - - /* Load in the jump address into the application start address pointer */ - AppStartPtr = Address.FuncPtr; - } - } - else - { - if (SentCommand.Data[1] == 0x00) // Start via watchdog - { - /* Unlock the forced application start mode of the bootloader if it is restarted */ - MagicBootKey = MAGIC_BOOT_KEY; - - /* Start the watchdog to reset the AVR once the communications are finalized */ - wdt_enable(WDTO_250MS); - } - else // Start via jump - { - /* Set the flag to terminate the bootloader at next opportunity if a valid application has been loaded */ - if (pgm_read_word_near(0) == 0xFFFF) - RunBootloader = false; - } - } - } - 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(); - - /* Memory has been erased, reset the security bit so that programming/reading is allowed */ - IsSecure = false; - } -} - -/** Handler for a Data Read command issued by the host. This routine handles bootloader information retrieval - * commands such as device signature and bootloader version retrieval. - */ -static void ProcessReadCommand(void) -{ - const uint8_t BootloaderInfo[3] = {BOOTLOADER_VERSION, BOOTLOADER_ID_BYTE1, BOOTLOADER_ID_BYTE2}; - const uint8_t SignatureInfo[4] = {0x58, AVR_SIGNATURE_1, AVR_SIGNATURE_2, AVR_SIGNATURE_3}; - - uint8_t DataIndexToRead = SentCommand.Data[1]; - bool ReadAddressInvalid = false; - - if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read bootloader info - { - if (DataIndexToRead < 3) - ResponseByte = BootloaderInfo[DataIndexToRead]; - else - ReadAddressInvalid = true; - } - else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte - { - switch (DataIndexToRead) - { - case 0x30: - ResponseByte = SignatureInfo[0]; - break; - case 0x31: - ResponseByte = SignatureInfo[1]; - break; - case 0x60: - ResponseByte = SignatureInfo[2]; - break; - case 0x61: - ResponseByte = SignatureInfo[3]; - break; - default: - ReadAddressInvalid = true; - break; - } - } - - if (ReadAddressInvalid) - { - /* Set the state and status variables to indicate the error */ - DFU_State = dfuERROR; - DFU_Status = errADDRESS; - } -} diff --git a/lib/lufa/Bootloaders/DFU/BootloaderDFU.h b/lib/lufa/Bootloaders/DFU/BootloaderDFU.h deleted file mode 100644 index a97ba6c7ef..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderDFU.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for BootloaderDFU.c. - */ - -#ifndef _BOOTLOADER_H_ -#define _BOOTLOADER_H_ - - /* Includes: */ - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #include "Descriptors.h" - #include "BootloaderAPI.h" - #include "Config/AppConfig.h" - - #include - #include - #include - - /* Preprocessor Checks: */ - #if !defined(__OPTIMIZE_SIZE__) - #error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again. - #endif - - /* Macros: */ - /** Major bootloader version number. */ - #define BOOTLOADER_VERSION_MINOR 2 - - /** Minor bootloader version number. */ - #define BOOTLOADER_VERSION_REV 0 - - /** Magic bootloader key to unlock forced application start mode. */ - #define MAGIC_BOOT_KEY 0xDC42 - - /** Complete bootloader version number expressed as a packed byte, constructed from the - * two individual bootloader version macros. - */ - #define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) - - /** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ - #define BOOTLOADER_ID_BYTE1 0xDC - - /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ - #define BOOTLOADER_ID_BYTE2 0xFB - - /** Convenience macro, used to determine if the issued command is the given one-byte long command. - * - * \param[in] dataarr Command byte array to check against - * \param[in] cb1 First command byte to check - */ - #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == (cb1)) - - /** Convenience macro, used to determine if the issued command is the given two-byte long command. - * - * \param[in] dataarr Command byte array to check against - * \param[in] cb1 First command byte to check - * \param[in] cb2 Second command byte to check - */ - #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) - - /** Length of the DFU file suffix block, appended to the end of each complete memory write command. - * The DFU file suffix is currently unused (but is designed to give extra file information, such as - * a CRC of the complete firmware for error checking) and so is discarded. - */ - #define DFU_FILE_SUFFIX_SIZE 16 - - /** Length of the DFU file filler block, appended to the start of each complete memory write command. - * Filler bytes are added to the start of each complete memory write command, and must be discarded. - */ - #define DFU_FILLER_BYTES_SIZE 26 - - /** DFU class command request to detach from the host. */ - #define DFU_REQ_DETATCH 0x00 - - /** DFU class command request to send data from the host to the bootloader. */ - #define DFU_REQ_DNLOAD 0x01 - - /** DFU class command request to send data from the bootloader to the host. */ - #define DFU_REQ_UPLOAD 0x02 - - /** DFU class command request to get the current DFU status and state from the bootloader. */ - #define DFU_REQ_GETSTATUS 0x03 - - /** DFU class command request to reset the current DFU status and state variables to their defaults. */ - #define DFU_REQ_CLRSTATUS 0x04 - - /** DFU class command request to get the current DFU state of the bootloader. */ - #define DFU_REQ_GETSTATE 0x05 - - /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ - #define DFU_REQ_ABORT 0x06 - - /** DFU command to begin programming the device's memory. */ - #define COMMAND_PROG_START 0x01 - - /** DFU command to begin reading the device's memory. */ - #define COMMAND_DISP_DATA 0x03 - - /** DFU command to issue a write command. */ - #define COMMAND_WRITE 0x04 - - /** DFU command to issue a read command. */ - #define COMMAND_READ 0x05 - - /** DFU command to issue a memory base address change command, to set the current 64KB flash page - * that subsequent flash operations should use. */ - #define COMMAND_CHANGE_BASE_ADDR 0x06 - - /* Type Defines: */ - /** Type define for a non-returning function pointer to the loaded application. */ - typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; - - /** Type define for a structure containing a complete DFU command issued by the host. */ - typedef struct - { - uint8_t Command; /**< Single byte command to perform, one of the \c COMMAND_* macro values */ - uint8_t Data[5]; /**< Command parameters */ - uint16_t DataSize; /**< Size of the command parameters */ - } DFU_Command_t; - - /* Enums: */ - /** DFU bootloader states. Refer to the DFU class specification for information on each state. */ - enum DFU_State_t - { - appIDLE = 0, - appDETACH = 1, - dfuIDLE = 2, - dfuDNLOAD_SYNC = 3, - dfuDNBUSY = 4, - dfuDNLOAD_IDLE = 5, - dfuMANIFEST_SYNC = 6, - dfuMANIFEST = 7, - dfuMANIFEST_WAIT_RESET = 8, - dfuUPLOAD_IDLE = 9, - dfuERROR = 10 - }; - - /** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ - enum DFU_Status_t - { - OK = 0, - errTARGET = 1, - errFILE = 2, - errWRITE = 3, - errERASE = 4, - errCHECK_ERASED = 5, - errPROG = 6, - errVERIFY = 7, - errADDRESS = 8, - errNOTDONE = 9, - errFIRMWARE = 10, - errVENDOR = 11, - errUSBR = 12, - errPOR = 13, - errUNKNOWN = 14, - errSTALLEDPKT = 15 - }; - - /* Function Prototypes: */ - static void SetupHardware(void); - static void ResetHardware(void); - - void EVENT_USB_Device_ControlRequest(void); - - #if defined(INCLUDE_FROM_BOOTLOADER_C) - static void DiscardFillerBytes(uint8_t NumberOfBytes); - static void ProcessBootloaderCommand(void); - static void LoadStartEndAddresses(void); - static void ProcessMemProgCommand(void); - static void ProcessMemReadCommand(void); - static void ProcessWriteCommand(void); - static void ProcessReadCommand(void); - #endif - - void Application_Jump_Check(void) ATTR_INIT_SECTION(3); - -#endif - diff --git a/lib/lufa/Bootloaders/DFU/BootloaderDFU.txt b/lib/lufa/Bootloaders/DFU/BootloaderDFU.txt deleted file mode 100644 index b2540a5b6c..0000000000 --- a/lib/lufa/Bootloaders/DFU/BootloaderDFU.txt +++ /dev/null @@ -1,235 +0,0 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \mainpage DFU Class USB AVR Bootloader - * - * \section Sec_Compat Demo Compatibility: - * - * The following list indicates what microcontrollers are compatible with this demo. - * - * \li Series 7 USB AVRs (AT90USBxxx7) - * \li Series 6 USB AVRs (AT90USBxxx6) - * \li Series 4 USB AVRs (ATMEGAxxU4) - See \ref SSec_Aux_Space - * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - See \ref SSec_Aux_Space - * - * \section Sec_Info USB Information: - * - * The following table gives a rundown of the USB utilization of this demo. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
USB Mode:Device
USB Class:Device Firmware Update Class (DFU)
USB Subclass:None
Relevant Standards:USBIF DFU Class Standard, Atmel USB Bootloader Datasheet
Supported USB Speeds:Low Speed Mode \n - * Full Speed Mode
- * - * \section Sec_Description Project Description: - * - * This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming - * software to load firmware onto the AVR. - * - * Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit - * into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to - * edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile. - * - * When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the - * bootloader from the normal user application. - * - * \section Sec_Running Running the Bootloader - * - * On the USB AVR8 devices, setting the \c HWBE device fuse will cause the bootloader to run if the \c HWB pin of - * the AVR is grounded when the device is reset. - * - * The are two behaviours of this bootloader, depending on the device's fuses: - * - * If the device's BOOTRST fuse is set, the bootloader will run any time the system is reset from - * the external reset pin, unless no valid user application has been loaded. To initiate the bootloader, the - * device's external reset pin should be grounded momentarily. - * - * If the device's BOOTRST fuse is not set, the bootloader will run only if initiated via a software - * jump, or if the \c HWB pin was low during the last device reset (if the \c HWBE fuse is set). - * - * For board specific exceptions to the above, see below. - * - * \subsection SSec_XPLAIN Atmel Xplain Board - * Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the - * \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board. - * - * \subsection SSec_Leonardo Arduino Leonardo Board - * Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the - * \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board. - * - * \section Sec_Installation Driver Installation - * - * This bootloader is designed to be compatible with Atmel's provided Windows DFU class drivers. You will need to - * install Atmel's DFU drivers prior to using this bootloader on Windows platforms. If you are using a 64 bit Windows - * OS, you will need to either disable the driver signing requirement (see online tutorials for details) or use a - * digitally signed version of the official Atmel driver provided by a third party AVR user at - * http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project. - * - * \note This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader - * drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please - * manually change them in Descriptors.c and alter your driver's INF file accordingly. - * - * \section Sec_HostApp Host Controller Application - * - * This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines. - * - * \subsection SSec_FLIP FLIP (Windows) - * - * FLIP (Flexible In-System Programmer) is a utility written by Atmel, and distributed for free on the Atmel website. - * The FLIP utility is designed to assist in the bootloader programming of a range of Atmel devices, through several - * popular physical interfaces including USB. It is written in Java, however makes use of native extensions for USB - * support and thus is only offered on Windows. - * - * To program a device using FLIP, refer to the Atmel FLIP documentation. - * - * \subsection SSec_DFUProgrammer dfu-programmer (Linux) - * - * dfu-programmer is an open-source command line solution for the bootloader programming of Atmel devices through a - * USB connection, using the DFU protocol, available for download at http://sourceforge.net/projects/dfu-programmer/. - * - * The following example loads a HEX file into the AVR's FLASH memory using dfu-programmer: - * \code - * dfu-programmer at90usb1287 erase flash Mouse.hex - * \endcode - * - * \section Sec_API User Application API - * - * Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, - * allowing the user application to call into the bootloader at runtime to read and write FLASH data. - * - * \warning The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader. - * - * By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the - * following layout: - * - * \code - * #define BOOTLOADER_API_TABLE_SIZE 32 - * #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE) - * #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2) - * - * void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0); - * void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1); - * void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2); - * uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3); - * uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4); - * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5); - * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6); - * - * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2)) - * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB - * - * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4)) - * #define BOOTLOADER_DFU_SIGNATURE 0xDF10 - * - * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8)) - * #define BOOTLOADER_ADDRESS_LENGTH 4 - * \endcode - * - * From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address - * \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader - * can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them - * to the value \c BOOTLOADER_DFU_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH - * memory starting from address \c BOOTLOADER_ADDRESS_START. - * - * \subsection SSec_API_MemLayout Device Memory Map - * The following illustration indicates the final memory map of the device when loaded with the bootloader. - * - * \verbatim - * +----------------------------+ 0x0000 - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * | User Application | - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE - * | Booloader Start Trampoline | - * | (Not User App. Accessible) | - * +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4) - * | | - * | Auxillery Bootloader | - * | Space for Smaller Devices | - * | (Not User App. Accessible) | - * | | - * +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - * | | - * | Bootloader Application | - * | (Not User App. Accessible) | - * | | - * +----------------------------+ FLASHEND - 96 - * | API Table Trampolines | - * | (Not User App. Accessible) | - * +----------------------------+ FLASHEND - 32 - * | Bootloader API Table | - * | (User App. Accessible) | - * +----------------------------+ FLASHEND - 8 - * | Bootloader ID Constants | - * | (User App. Accessible) | - * +----------------------------+ FLASHEND - * \endverbatim - * - * \subsection SSec_Aux_Space Auxiliary Bootloader Section - * To make the bootloader function on smaller devices (those with a physical - * bootloader section of smaller than 6KB) - * - * \section Sec_KnownIssues Known Issues: - * - * \par On Linux machines, the DFU bootloader is inaccessible. - * On many Linux systems, non-root users do not have automatic access to newly - * inserted DFU devices. Root privileges or a UDEV rule is required to gain - * access. - * See here for resolution steps. - * - * \section Sec_Options Project Options - * - * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. - * - * - * - * - * - * - * - * - * - * - * - * - *
Define Name:Location:Description:
SECURE_MODEAppConfig.hIf defined to \c true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an - * erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from - * being dumped by unauthorized persons. When false, all memory operations are allowed at any time.
- */ - diff --git a/lib/lufa/Bootloaders/DFU/Config/AppConfig.h b/lib/lufa/Bootloaders/DFU/Config/AppConfig.h deleted file mode 100644 index 3acf33c7ea..0000000000 --- a/lib/lufa/Bootloaders/DFU/Config/AppConfig.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Application Configuration Header File - * - * This is a header file which is be used to configure some of - * the application's compile time options, as an alternative to - * specifying the compile time constants supplied through a - * makefile or build system. - * - * For information on what each token does, refer to the - * \ref Sec_Options section of the application documentation. - */ - -#ifndef _APP_CONFIG_H_ -#define _APP_CONFIG_H_ - - #define SECURE_MODE false - -#endif diff --git a/lib/lufa/Bootloaders/DFU/Config/LUFAConfig.h b/lib/lufa/Bootloaders/DFU/Config/LUFAConfig.h deleted file mode 100644 index 59ae519e4c..0000000000 --- a/lib/lufa/Bootloaders/DFU/Config/LUFAConfig.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief LUFA Library Configuration Header File - * - * This header file is used to configure LUFA's compile time options, - * as an alternative to the compile time constants supplied through - * a makefile. - * - * For information on what each token does, refer to the LUFA - * manual section "Summary of Compile Tokens". - */ - -#ifndef _LUFA_CONFIG_H_ -#define _LUFA_CONFIG_H_ - - #if (ARCH == ARCH_AVR8) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ -// #define ORDERED_EP_CONFIG - #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) - #define USB_DEVICE_ONLY -// #define USB_HOST_ONLY -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT - #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ - #define USE_RAM_DESCRIPTORS -// #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS - #define NO_INTERNAL_SERIAL - #define FIXED_CONTROL_ENDPOINT_SIZE 32 - #define DEVICE_STATE_AS_GPIOR 0 - #define FIXED_NUM_CONFIGURATIONS 1 - #define CONTROL_ONLY_DEVICE -// #define INTERRUPT_CONTROL_ENDPOINT - #define NO_DEVICE_REMOTE_WAKEUP - #define NO_DEVICE_SELF_POWER - - /* USB Host Mode Driver Related Tokens: */ -// #define HOST_STATE_AS_GPIOR {Insert Value Here} -// #define USB_HOST_TIMEOUT_MS {Insert Value Here} -// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} -// #define NO_AUTO_VBUS_MANAGEMENT -// #define INVERTED_VBUS_ENABLE_LINE - - #else - - #error Unsupported architecture for this LUFA configuration file. - - #endif -#endif diff --git a/lib/lufa/Bootloaders/DFU/Descriptors.c b/lib/lufa/Bootloaders/DFU/Descriptors.c deleted file mode 100644 index 46120781b1..0000000000 --- a/lib/lufa/Bootloaders/DFU/Descriptors.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 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 - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability -