From 359fbfe14d00ab378f85a36664820ea9ba538c3f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 10 May 2012 19:24:58 +0000 Subject: Add branch for the conversion of demos to use standard C header files for configuration, rather than makefile defined macros. --- Bootloaders/CDC/BootloaderCDC.c | 48 +++++++---- Bootloaders/CDC/BootloaderCDC.h | 5 ++ Bootloaders/CDC/BootloaderCDC.txt | 6 +- Bootloaders/CDC/Config/AppConfig.h | 50 ++++++++++++ Bootloaders/CDC/Config/LUFAConfig.h | 93 ++++++++++++++++++++++ Bootloaders/CDC/Descriptors.c | 10 +-- Bootloaders/CDC/Descriptors.h | 12 +-- Bootloaders/CDC/makefile | 21 +---- Bootloaders/DFU/BootloaderDFU.c | 24 ++++++ Bootloaders/DFU/BootloaderDFU.h | 5 ++ Bootloaders/DFU/BootloaderDFU.txt | 6 +- Bootloaders/DFU/Descriptors.c | 2 +- Bootloaders/DFU/makefile | 2 +- Bootloaders/HID/BootloaderHID.c | 30 ++++++- Bootloaders/HID/BootloaderHID.h | 5 ++ Bootloaders/HID/BootloaderHID.txt | 8 +- Bootloaders/HID/Descriptors.c | 4 +- Bootloaders/HID/Descriptors.h | 4 +- Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c | 4 - Bootloaders/HID/makefile | 2 +- 20 files changed, 274 insertions(+), 67 deletions(-) create mode 100644 Bootloaders/CDC/Config/AppConfig.h create mode 100644 Bootloaders/CDC/Config/LUFAConfig.h (limited to 'Bootloaders') diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c index e9ea8ae35..211b054e3 100644 --- a/Bootloaders/CDC/BootloaderCDC.c +++ b/Bootloaders/CDC/BootloaderCDC.c @@ -56,6 +56,28 @@ static uint32_t CurrAddress; */ static bool RunBootloader = true; +/** 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. + */ +uint32_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) +{ + /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */ + if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) + { + 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 @@ -80,6 +102,9 @@ int main(void) /* Disconnect from the host - USB interface will be reset later along with the AVR */ USB_Detach(); + + /* Unlock the forced application start mode of the bootloader if it is restarted */ + MagicBootKey = MAGIC_BOOT_KEY; /* Enable the watchdog and force a timeout to reset the AVR */ wdt_enable(WDTO_250MS); @@ -122,17 +147,12 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK) void EVENT_USB_Device_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints */ - Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, - ENDPOINT_DIR_IN, CDC_NOTIFICATION_EPSIZE, - ENDPOINT_BANK_SINGLE); + Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, + CDC_NOTIFICATION_EPSIZE, 1); - Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_IN, CDC_TXRX_EPSIZE, - ENDPOINT_BANK_SINGLE); + Endpoint_ConfigureEndpoint(CDC_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1); - Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_OUT, CDC_TXRX_EPSIZE, - ENDPOINT_BANK_SINGLE); + Endpoint_ConfigureEndpoint(CDC_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1); } /** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to @@ -303,7 +323,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command) static uint8_t FetchNextCommandByte(void) { /* Select the OUT endpoint so that the next data byte can be read */ - Endpoint_SelectEndpoint(CDC_RX_EPNUM); + Endpoint_SelectEndpoint(CDC_RX_EPADDR); /* If OUT endpoint empty, clear it and wait for the next packet from the host */ while (!(Endpoint_IsReadWriteAllowed())) @@ -329,7 +349,7 @@ static uint8_t FetchNextCommandByte(void) static void WriteNextResponseByte(const uint8_t Response) { /* Select the IN endpoint so that the next data byte can be written */ - Endpoint_SelectEndpoint(CDC_TX_EPNUM); + Endpoint_SelectEndpoint(CDC_TX_EPADDR); /* If IN endpoint full, clear it and wait until ready for the next packet to the host */ if (!(Endpoint_IsReadWriteAllowed())) @@ -353,7 +373,7 @@ static void WriteNextResponseByte(const uint8_t Response) static void CDC_Task(void) { /* Select the OUT endpoint */ - Endpoint_SelectEndpoint(CDC_RX_EPNUM); + Endpoint_SelectEndpoint(CDC_RX_EPADDR); /* Check if endpoint has a command in it sent from the host */ if (!(Endpoint_IsOUTReceived())) @@ -549,7 +569,7 @@ static void CDC_Task(void) } /* Select the IN endpoint */ - Endpoint_SelectEndpoint(CDC_TX_EPNUM); + Endpoint_SelectEndpoint(CDC_TX_EPADDR); /* Remember if the endpoint is completely full before clearing it */ bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed()); @@ -577,7 +597,7 @@ static void CDC_Task(void) } /* Select the OUT endpoint */ - Endpoint_SelectEndpoint(CDC_RX_EPNUM); + Endpoint_SelectEndpoint(CDC_RX_EPADDR); /* Acknowledge the command from the host */ Endpoint_ClearOUT(); diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h index 4b9e7d6d8..257e884e6 100644 --- a/Bootloaders/CDC/BootloaderCDC.h +++ b/Bootloaders/CDC/BootloaderCDC.h @@ -67,6 +67,9 @@ /** Eight character bootloader firmware identifier reported to the host when requested */ #define SOFTWARE_IDENTIFIER "LUFACDC" + /** Magic bootloader key to unlock forced application start mode. */ + #define MAGIC_BOOT_KEY 0xDC42CACA + /* Type Defines: */ /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; @@ -75,6 +78,8 @@ static void CDC_Task(void); static void SetupHardware(void); + void Application_Jump_Check(void) ATTR_INIT_SECTION(3); + void EVENT_USB_Device_ConfigurationChanged(void); #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) diff --git a/Bootloaders/CDC/BootloaderCDC.txt b/Bootloaders/CDC/BootloaderCDC.txt index d6ab94516..618b95d25 100644 --- a/Bootloaders/CDC/BootloaderCDC.txt +++ b/Bootloaders/CDC/BootloaderCDC.txt @@ -47,9 +47,9 @@ * This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109 * protocol compatible programming software to load firmware onto the AVR. * - * Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If - * you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU - * values in the accompanying makefile. + * 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. diff --git a/Bootloaders/CDC/Config/AppConfig.h b/Bootloaders/CDC/Config/AppConfig.h new file mode 100644 index 000000000..ae3e50e1d --- /dev/null +++ b/Bootloaders/CDC/Config/AppConfig.h @@ -0,0 +1,50 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 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 disclaim 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 is a header file which is be 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 _APP_CONFIG_H_ +#define _APP_CONFIG_H_ + + #define NO_BLOCK_SUPPORT + #define NO_EEPROM_BYTE_SUPPORT + #define NO_FLASH_BYTE_SUPPORT + #define NO_LOCK_BYTE_WRITE_SUPPORT + +#endif \ No newline at end of file diff --git a/Bootloaders/CDC/Config/LUFAConfig.h b/Bootloaders/CDC/Config/LUFAConfig.h new file mode 100644 index 000000000..c5a01c2fa --- /dev/null +++ b/Bootloaders/CDC/Config/LUFAConfig.h @@ -0,0 +1,93 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 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 disclaim 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 is a header file which is be 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 8 + #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/Bootloaders/CDC/Descriptors.c b/Bootloaders/CDC/Descriptors.c index 4bf3eced5..9c892f835 100644 --- a/Bootloaders/CDC/Descriptors.c +++ b/Bootloaders/CDC/Descriptors.c @@ -131,7 +131,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), + .EndpointAddress = CDC_NOTIFICATION_EPADDR, .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_NOTIFICATION_EPSIZE, .PollingIntervalMS = 0xFF @@ -157,20 +157,20 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), + .EndpointAddress = CDC_RX_EPADDR, .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x05 }, .CDC_DataInEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), + .EndpointAddress = CDC_TX_EPADDR, .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x05 } }; diff --git a/Bootloaders/CDC/Descriptors.h b/Bootloaders/CDC/Descriptors.h index e5ef64102..0010fc69b 100644 --- a/Bootloaders/CDC/Descriptors.h +++ b/Bootloaders/CDC/Descriptors.h @@ -92,14 +92,14 @@ #error The selected AVR part is not currently supported by this bootloader. #endif - /** Endpoint number for the CDC control interface event notification endpoint. */ - #define CDC_NOTIFICATION_EPNUM 2 + /** Endpoint address for the CDC control interface event notification endpoint. */ + #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2) - /** Endpoint number for the CDC data interface TX (data IN) endpoint. */ - #define CDC_TX_EPNUM 3 + /** Endpoint address for the CDC data interface TX (data IN) endpoint. */ + #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3) - /** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ - #define CDC_RX_EPNUM 4 + /** Endpoint address for the CDC data interface RX (data OUT) endpoint. */ + #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4) /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ #define CDC_TXRX_EPSIZE 16 diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile index 066fb8884..b449ff0c6 100644 --- a/Bootloaders/CDC/makefile +++ b/Bootloaders/CDC/makefile @@ -95,7 +95,7 @@ F_USB = $(F_CPU) # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 4 +BOOT_SECTION_SIZE_KB = 8 # Formulas used to calculate the starting address of the Bootloader section, and the User Application @@ -124,22 +124,7 @@ LUFA_PATH = ../.. # LUFA library compile-time options and predefined tokens -LUFA_OPTS = -D USB_DEVICE_ONLY -LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 -LUFA_OPTS += -D ORDERED_EP_CONFIG -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 -LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 -LUFA_OPTS += -D USE_RAM_DESCRIPTORS -LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -LUFA_OPTS += -D NO_INTERNAL_SERIAL -LUFA_OPTS += -D NO_DEVICE_SELF_POWER -LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP -LUFA_OPTS += -D NO_SOF_EVENTS - -#LUFA_OPTS += -D NO_BLOCK_SUPPORT -#LUFA_OPTS += -D NO_EEPROM_BYTE_SUPPORT -#LUFA_OPTS += -D NO_FLASH_BYTE_SUPPORT -#LUFA_OPTS += -D NO_LOCK_BYTE_WRITE_SUPPORT +LUFA_OPTS = -D USE_LUFA_CONFIG_HEADER # Create the LUFA source path variables by including the LUFA root makefile @@ -184,7 +169,7 @@ DEBUG = dwarf-2 # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ +EXTRAINCDIRS = $(LUFA_PATH)/ Config/ # Compiler flag to set the C Standard level. diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 3ce2a6285..233e145ae 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -92,6 +92,27 @@ static uint16_t StartAddr = 0x0000; */ 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. + */ +uint32_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) +{ + // If the reset source was the bootloader and the key is correct, clear it and jump to the application + if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) + { + MagicBootKey = 0; + AppStartPtr(); + } +} /** 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 @@ -695,6 +716,9 @@ static void ProcessWriteCommand(void) { 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); } diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index a80775348..46b70c0e9 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -66,6 +66,9 @@ /** Minor bootloader version number. */ #define BOOTLOADER_VERSION_REV 0 + + /** Magic bootloader key to unlock forced application start mode. */ + #define MAGIC_BOOT_KEY 0xDC42CACA /** Complete bootloader version number expressed as a packed byte, constructed from the * two individual bootloader version macros. @@ -206,6 +209,8 @@ static void ProcessWriteCommand(void); static void ProcessReadCommand(void); #endif + + void Application_Jump_Check(void) ATTR_INIT_SECTION(3); #endif diff --git a/Bootloaders/DFU/BootloaderDFU.txt b/Bootloaders/DFU/BootloaderDFU.txt index d0811b2aa..2c9eaf1de 100644 --- a/Bootloaders/DFU/BootloaderDFU.txt +++ b/Bootloaders/DFU/BootloaderDFU.txt @@ -47,9 +47,9 @@ * 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 USB1287, and should fit into 4KB of bootloader space. If - * you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU - * values in the accompanying makefile. + * 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. diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index d55159060..ff33b6b64 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -111,7 +111,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = .DetachTimeout = 0x0000, .TransferSize = 0x0C00, - .DFUSpecification = VERSION_BCD(01.01) + .DFUSpecification = VERSION_BCD(01.10) } }; diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index 608564ebe..f78ceb270 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -95,7 +95,7 @@ F_USB = $(F_CPU) # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 4 +BOOT_SECTION_SIZE_KB = 8 # Formulas used to calculate the starting address of the Bootloader section, and the User Application diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c index 928000f8b..acc351a30 100644 --- a/Bootloaders/HID/BootloaderHID.c +++ b/Bootloaders/HID/BootloaderHID.c @@ -41,6 +41,29 @@ */ static bool RunBootloader = true; +/** 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. + */ +uint32_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) +{ + /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */ + if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) + { + 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. */ @@ -58,6 +81,9 @@ int main(void) /* Disconnect from the host - USB interface will be reset later along with the AVR */ USB_Detach(); + /* Unlock the forced application start mode of the bootloader if it is restarted */ + MagicBootKey = MAGIC_BOOT_KEY; + /* Enable the watchdog and force a timeout to reset the AVR */ wdt_enable(WDTO_250MS); @@ -85,9 +111,7 @@ static void SetupHardware(void) void EVENT_USB_Device_ConfigurationChanged(void) { /* Setup HID Report Endpoint */ - Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT, - ENDPOINT_DIR_IN, HID_IN_EPSIZE, - ENDPOINT_BANK_SINGLE); + Endpoint_ConfigureEndpoint(HID_IN_EPADDR, EP_TYPE_INTERRUPT, HID_IN_EPSIZE, 1); } /** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to diff --git a/Bootloaders/HID/BootloaderHID.h b/Bootloaders/HID/BootloaderHID.h index ab5752d3c..af2812a7d 100644 --- a/Bootloaders/HID/BootloaderHID.h +++ b/Bootloaders/HID/BootloaderHID.h @@ -52,9 +52,14 @@ /** Bootloader special address to start the user application */ #define COMMAND_STARTAPPLICATION 0xFFFF + /** Magic bootloader key to unlock forced application start mode. */ + #define MAGIC_BOOT_KEY 0xDC42CACA + /* Function Prototypes: */ static void SetupHardware(void); + void Application_Jump_Check(void) ATTR_INIT_SECTION(3); + void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_UnhandledControlRequest(void); diff --git a/Bootloaders/HID/BootloaderHID.txt b/Bootloaders/HID/BootloaderHID.txt index a774ab485..f6c084d65 100644 --- a/Bootloaders/HID/BootloaderHID.txt +++ b/Bootloaders/HID/BootloaderHID.txt @@ -51,10 +51,10 @@ * from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC * HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it. * - * Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the - * Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to - * enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the - * accompanying makefile. + * Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit + * into 2KB of bootloader space for the Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for + * all other models. 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. * * \section Sec_Installation Driver Installation * diff --git a/Bootloaders/HID/Descriptors.c b/Bootloaders/HID/Descriptors.c index 5d4271e0c..c1ea8e30e 100644 --- a/Bootloaders/HID/Descriptors.c +++ b/Bootloaders/HID/Descriptors.c @@ -137,10 +137,10 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - .EndpointAddress = (ENDPOINT_DIR_IN | HID_IN_EPNUM), + .EndpointAddress = HID_IN_EPADDR, .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = HID_IN_EPSIZE, - .PollingIntervalMS = 0x01 + .PollingIntervalMS = 0x05 }, }; diff --git a/Bootloaders/HID/Descriptors.h b/Bootloaders/HID/Descriptors.h index 41c4ee402..ad216038a 100644 --- a/Bootloaders/HID/Descriptors.h +++ b/Bootloaders/HID/Descriptors.h @@ -55,8 +55,8 @@ } USB_Descriptor_Configuration_t; /* Macros: */ - /** Endpoint number of the HID data IN endpoint. */ - #define HID_IN_EPNUM 1 + /** Endpoint address of the HID data IN endpoint. */ + #define HID_IN_EPADDR (ENDPOINT_DIR_IN | 1) /** Size in bytes of the HID reporting IN endpoint. */ #define HID_IN_EPSIZE 64 diff --git a/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c index 6063e1981..c86b0da9c 100644 --- a/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c +++ b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c @@ -970,13 +970,9 @@ void parse_options(int argc, char **argv) } else if (strncmp(arg, "-mmcu=", 6) == 0) { arg += 6; - uint8_t valid_prefix = 0; - if (strncmp(arg, "at90usb", 7) == 0) { - valid_prefix = 1; arg += 7; } else if (strncmp(arg, "atmega", 6) == 0) { - valid_prefix = 1; arg += 6; } else { die("Unknown MCU type\n"); diff --git a/Bootloaders/HID/makefile b/Bootloaders/HID/makefile index efbb6a645..bfefbf695 100644 --- a/Bootloaders/HID/makefile +++ b/Bootloaders/HID/makefile @@ -95,7 +95,7 @@ F_USB = $(F_CPU) # Note that the bootloader size and start address given in AVRStudio is in words and not # bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. FLASH_SIZE_KB = 128 -BOOT_SECTION_SIZE_KB = 4 +BOOT_SECTION_SIZE_KB = 8 # Formulas used to calculate the starting address of the Bootloader section. These formulas -- cgit v1.2.3 From 74fb2d895e3197f9b0204366d7f6f52c9c41b2ff Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 10 May 2012 19:42:42 +0000 Subject: AppConfigHeaders: Update bootloaders to use configuration header files, rather than makefile defines. --- Bootloaders/CDC/BootloaderCDC.h | 1 + Bootloaders/CDC/BootloaderCDC.txt | 8 ++-- Bootloaders/CDC/Config/AppConfig.h | 17 ++++--- Bootloaders/CDC/Config/LUFAConfig.h | 6 +-- Bootloaders/CDC/Doxygen.conf | 3 +- Bootloaders/DFU/BootloaderDFU.txt | 2 +- Bootloaders/DFU/Config/LUFAConfig.h | 93 +++++++++++++++++++++++++++++++++++++ Bootloaders/DFU/Doxygen.conf | 3 +- Bootloaders/DFU/makefile | 14 +----- Bootloaders/HID/Config/LUFAConfig.h | 93 +++++++++++++++++++++++++++++++++++++ Bootloaders/HID/makefile | 14 +----- 11 files changed, 213 insertions(+), 41 deletions(-) create mode 100644 Bootloaders/DFU/Config/LUFAConfig.h create mode 100644 Bootloaders/HID/Config/LUFAConfig.h (limited to 'Bootloaders') diff --git a/Bootloaders/CDC/BootloaderCDC.h b/Bootloaders/CDC/BootloaderCDC.h index 257e884e6..36af96216 100644 --- a/Bootloaders/CDC/BootloaderCDC.h +++ b/Bootloaders/CDC/BootloaderCDC.h @@ -47,6 +47,7 @@ #include "Descriptors.h" #include "BootloaderAPI.h" + #include "Config/AppConfig.h" #include #include diff --git a/Bootloaders/CDC/BootloaderCDC.txt b/Bootloaders/CDC/BootloaderCDC.txt index 618b95d25..9abd7b2f8 100644 --- a/Bootloaders/CDC/BootloaderCDC.txt +++ b/Bootloaders/CDC/BootloaderCDC.txt @@ -133,25 +133,25 @@ * * * NO_BLOCK_SUPPORT - * Makefile LUFA_OPTS + * AppConfig.h * Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made * using the byte-level commands. * * * NO_EEPROM_BYTE_SUPPORT - * Makefile LUFA_OPTS + * AppConfig.h * Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes * to be made using the block-level commands. * * * NO_FLASH_BYTE_SUPPORT - * Makefile LUFA_OPTS + * AppConfig.h * Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes * to be made using the block-level commands. * * * NO_LOCK_BYTE_WRITE_SUPPORT - * Makefile LUFA_OPTS + * AppConfig.h * Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically. * * diff --git a/Bootloaders/CDC/Config/AppConfig.h b/Bootloaders/CDC/Config/AppConfig.h index ae3e50e1d..9f9b1ce25 100644 --- a/Bootloaders/CDC/Config/AppConfig.h +++ b/Bootloaders/CDC/Config/AppConfig.h @@ -29,22 +29,25 @@ */ /** \file - * \brief LUFA Library Configuration Header File + * \brief Application Configuration Header File * * This is a header file which is be 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". + * 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 NO_BLOCK_SUPPORT - #define NO_EEPROM_BYTE_SUPPORT - #define NO_FLASH_BYTE_SUPPORT - #define NO_LOCK_BYTE_WRITE_SUPPORT +// #define NO_BLOCK_SUPPORT + +// #define NO_EEPROM_BYTE_SUPPORT + +// #define NO_FLASH_BYTE_SUPPORT + +// #define NO_LOCK_BYTE_WRITE_SUPPORT #endif \ No newline at end of file diff --git a/Bootloaders/CDC/Config/LUFAConfig.h b/Bootloaders/CDC/Config/LUFAConfig.h index c5a01c2fa..15ab0599f 100644 --- a/Bootloaders/CDC/Config/LUFAConfig.h +++ b/Bootloaders/CDC/Config/LUFAConfig.h @@ -31,9 +31,9 @@ /** \file * \brief LUFA Library Configuration Header File * - * This is a header file which is be used to configure LUFA's - * compile time options, as an alternative to the compile time - * constants supplied through a makefile. + * 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". diff --git a/Bootloaders/CDC/Doxygen.conf b/Bootloaders/CDC/Doxygen.conf index a5b4bd683..2c655dcff 100644 --- a/Bootloaders/CDC/Doxygen.conf +++ b/Bootloaders/CDC/Doxygen.conf @@ -1531,7 +1531,8 @@ INCLUDE_FILE_PATTERNS = # instead of the = operator. PREDEFINED = __DOXYGEN__ \ - PROGMEM + PROGMEM \ + ATTR_NO_INIT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/Bootloaders/DFU/BootloaderDFU.txt b/Bootloaders/DFU/BootloaderDFU.txt index 2c9eaf1de..04f911617 100644 --- a/Bootloaders/DFU/BootloaderDFU.txt +++ b/Bootloaders/DFU/BootloaderDFU.txt @@ -139,7 +139,7 @@ * * SECURE_MODE * BootloaderDFU.h - * If defined to true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an + * If 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. * diff --git a/Bootloaders/DFU/Config/LUFAConfig.h b/Bootloaders/DFU/Config/LUFAConfig.h new file mode 100644 index 000000000..59f67596f --- /dev/null +++ b/Bootloaders/DFU/Config/LUFAConfig.h @@ -0,0 +1,93 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 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 disclaim 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/Bootloaders/DFU/Doxygen.conf b/Bootloaders/DFU/Doxygen.conf index 331b4b417..99c1769ba 100644 --- a/Bootloaders/DFU/Doxygen.conf +++ b/Bootloaders/DFU/Doxygen.conf @@ -1531,7 +1531,8 @@ INCLUDE_FILE_PATTERNS = # instead of the = operator. PREDEFINED = __DOXYGEN__ \ - PROGMEM + PROGMEM \ + ATTR_NO_INIT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index f78ceb270..a6db90089 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -124,17 +124,7 @@ LUFA_PATH = ../.. # LUFA library compile-time options and predefined tokens -LUFA_OPTS = -D USB_DEVICE_ONLY -LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 -LUFA_OPTS += -D CONTROL_ONLY_DEVICE -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=32 -LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 -LUFA_OPTS += -D USE_RAM_DESCRIPTORS -LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -LUFA_OPTS += -D NO_INTERNAL_SERIAL -LUFA_OPTS += -D NO_DEVICE_SELF_POWER -LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP -LUFA_OPTS += -D NO_SOF_EVENTS +LUFA_OPTS = -D USE_LUFA_CONFIG_HEADER # Create the LUFA source path variables by including the LUFA root makefile @@ -179,7 +169,7 @@ DEBUG = dwarf-2 # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ +EXTRAINCDIRS = $(LUFA_PATH)/ Config/ # Compiler flag to set the C Standard level. diff --git a/Bootloaders/HID/Config/LUFAConfig.h b/Bootloaders/HID/Config/LUFAConfig.h new file mode 100644 index 000000000..15ab0599f --- /dev/null +++ b/Bootloaders/HID/Config/LUFAConfig.h @@ -0,0 +1,93 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 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 disclaim 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 8 + #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/Bootloaders/HID/makefile b/Bootloaders/HID/makefile index bfefbf695..b0ae6d6d9 100644 --- a/Bootloaders/HID/makefile +++ b/Bootloaders/HID/makefile @@ -122,17 +122,7 @@ LUFA_PATH = ../.. # LUFA library compile-time options and predefined tokens -LUFA_OPTS = -D USB_DEVICE_ONLY -LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 -LUFA_OPTS += -D ORDERED_EP_CONFIG -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 -LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 -LUFA_OPTS += -D USE_RAM_DESCRIPTORS -LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -LUFA_OPTS += -D NO_INTERNAL_SERIAL -LUFA_OPTS += -D NO_DEVICE_SELF_POWER -LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP -LUFA_OPTS += -D NO_SOF_EVENTS +LUFA_OPTS = -D USE_LUFA_CONFIG_HEADER # Create the LUFA source path variables by including the LUFA root makefile @@ -176,7 +166,7 @@ DEBUG = dwarf-2 # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ +EXTRAINCDIRS = $(LUFA_PATH)/ Config/ # Compiler flag to set the C Standard level. -- cgit v1.2.3 From 926a83bbc12cc09e026a51b173007dc7cda16117 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 10 May 2012 20:11:47 +0000 Subject: AppConfigHeaders: Update several user projects to use configuration header files, rather than makefile defines. --- Bootloaders/CDC/Config/AppConfig.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'Bootloaders') diff --git a/Bootloaders/CDC/Config/AppConfig.h b/Bootloaders/CDC/Config/AppConfig.h index 9f9b1ce25..6baadf9ad 100644 --- a/Bootloaders/CDC/Config/AppConfig.h +++ b/Bootloaders/CDC/Config/AppConfig.h @@ -43,11 +43,8 @@ #define _APP_CONFIG_H_ // #define NO_BLOCK_SUPPORT - // #define NO_EEPROM_BYTE_SUPPORT - // #define NO_FLASH_BYTE_SUPPORT - // #define NO_LOCK_BYTE_WRITE_SUPPORT #endif \ No newline at end of file -- cgit v1.2.3 From e9e6730d4999bea6e0eaefc2fce062ef090388b8 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 13 May 2012 21:01:23 +0000 Subject: AppConfigHeaders: Move out the last of the demo/app configurations into new AppConfig.h header files. --- Bootloaders/DFU/BootloaderDFU.h | 8 +------ Bootloaders/DFU/BootloaderDFU.txt | 4 ++-- Bootloaders/DFU/Config/AppConfig.h | 48 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 Bootloaders/DFU/Config/AppConfig.h (limited to 'Bootloaders') diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index 46b70c0e9..ffd330d7f 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -49,18 +49,12 @@ #include "Descriptors.h" #include "BootloaderAPI.h" + #include "Config/AppConfig.h" #include #include /* Macros: */ - /** Configuration define. Define this token to true to case the bootloader to reject all memory commands - * until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this - * can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are - * allowed at any time. - */ - #define SECURE_MODE false - /** Major bootloader version number. */ #define BOOTLOADER_VERSION_MINOR 2 diff --git a/Bootloaders/DFU/BootloaderDFU.txt b/Bootloaders/DFU/BootloaderDFU.txt index c7e1b1ed4..a4cc6e201 100644 --- a/Bootloaders/DFU/BootloaderDFU.txt +++ b/Bootloaders/DFU/BootloaderDFU.txt @@ -140,10 +140,10 @@ * * * SECURE_MODE - * BootloaderDFU.h + * AppConfig.h * If 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. + * being dumped by unauthorized persons. When false, all memory operations are allowed at any time. * * */ diff --git a/Bootloaders/DFU/Config/AppConfig.h b/Bootloaders/DFU/Config/AppConfig.h new file mode 100644 index 000000000..26a79b42c --- /dev/null +++ b/Bootloaders/DFU/Config/AppConfig.h @@ -0,0 +1,48 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 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 disclaim 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 \ No newline at end of file -- cgit v1.2.3 From cb9e7392c5f9f1c51710df1b4bbe1aa11168576f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 15 May 2012 19:51:41 +0000 Subject: AppConfigHeaders: Make sure that in applications using an AppConfig.h configuration file, all application headers include the configuration file. --- Bootloaders/CDC/BootloaderAPI.h | 2 ++ Bootloaders/CDC/Descriptors.h | 2 ++ Bootloaders/DFU/BootloaderAPI.h | 2 ++ Bootloaders/DFU/Descriptors.h | 2 ++ 4 files changed, 8 insertions(+) (limited to 'Bootloaders') diff --git a/Bootloaders/CDC/BootloaderAPI.h b/Bootloaders/CDC/BootloaderAPI.h index bd7218421..d47c2efc7 100644 --- a/Bootloaders/CDC/BootloaderAPI.h +++ b/Bootloaders/CDC/BootloaderAPI.h @@ -43,6 +43,8 @@ #include + #include "Config/AppConfig.h" + /* Function Prototypes: */ void BootloaderAPI_ErasePage(const uint32_t Address); void BootloaderAPI_WritePage(const uint32_t Address); diff --git a/Bootloaders/CDC/Descriptors.h b/Bootloaders/CDC/Descriptors.h index 0010fc69b..6eec9d370 100644 --- a/Bootloaders/CDC/Descriptors.h +++ b/Bootloaders/CDC/Descriptors.h @@ -39,6 +39,8 @@ /* Includes: */ #include + #include "Config/AppConfig.h" + /* Macros: */ #if defined(__AVR_AT90USB1287__) #define AVR_SIGNATURE_1 0x1E diff --git a/Bootloaders/DFU/BootloaderAPI.h b/Bootloaders/DFU/BootloaderAPI.h index bd7218421..8d0404979 100644 --- a/Bootloaders/DFU/BootloaderAPI.h +++ b/Bootloaders/DFU/BootloaderAPI.h @@ -43,6 +43,8 @@ #include + #include "Config/AppConfig.h" + /* Function Prototypes: */ void BootloaderAPI_ErasePage(const uint32_t Address); void BootloaderAPI_WritePage(const uint32_t Address); diff --git a/Bootloaders/DFU/Descriptors.h b/Bootloaders/DFU/Descriptors.h index ce9cc9379..e1ad51a80 100644 --- a/Bootloaders/DFU/Descriptors.h +++ b/Bootloaders/DFU/Descriptors.h @@ -39,6 +39,8 @@ /* Includes: */ #include + #include "Config/AppConfig.h" + /* Macros: */ /** Descriptor type value for a DFU class functional descriptor. */ #define DTYPE_DFUFunctional 0x21 -- cgit v1.2.3