From 96fd39eda86e963177cb7895f6c2216ecb9c732a Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 13 May 2012 10:13:24 +0000 Subject: [PATCH 1/3] Fixed CDC and DFU bootloaders API function offsets incorrect on some devices (thanks to Rod DeMay). --- Bootloaders/CDC/BootloaderAPITable.S | 20 ++++++++++++++------ Bootloaders/CDC/BootloaderCDC.txt | 10 ++++++---- Bootloaders/DFU/BootloaderAPITable.S | 20 ++++++++++++++------ Bootloaders/DFU/BootloaderDFU.txt | 12 +++++++----- LUFA/DoxygenPages/ChangeLog.txt | 1 + 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Bootloaders/CDC/BootloaderAPITable.S b/Bootloaders/CDC/BootloaderAPITable.S index fc1e2e99fc..a8e38861d5 100644 --- a/Bootloaders/CDC/BootloaderAPITable.S +++ b/Bootloaders/CDC/BootloaderAPITable.S @@ -48,7 +48,15 @@ BootloaderAPI_ReadLock_Trampoline: jmp BootloaderAPI_ReadLock BootloaderAPI_WriteLock_Trampoline: jmp BootloaderAPI_WriteLock -BootloaderAPU_UNUSED: +BootloaderAPU_UNUSED1: + ret +BootloaderAPU_UNUSED2: + ret +BootloaderAPU_UNUSED3: + ret +BootloaderAPU_UNUSED4: + ret +BootloaderAPU_UNUSED5: ret ; API function jump table @@ -62,11 +70,11 @@ BootloaderAPI_JumpTable: rjmp BootloaderAPI_ReadFuse_Trampoline rjmp BootloaderAPI_ReadLock_Trampoline rjmp BootloaderAPI_WriteLock_Trampoline - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED1 ; UNUSED ENTRY 1 + rjmp BootloaderAPU_UNUSED2 ; UNUSED ENTRY 2 + rjmp BootloaderAPU_UNUSED3 ; UNUSED ENTRY 3 + rjmp BootloaderAPU_UNUSED4 ; UNUSED ENTRY 4 + rjmp BootloaderAPU_UNUSED5 ; UNUSED ENTRY 5 ; Bootloader table signatures and information .org (96 - 8) diff --git a/Bootloaders/CDC/BootloaderCDC.txt b/Bootloaders/CDC/BootloaderCDC.txt index 618b95d257..50748e5960 100644 --- a/Bootloaders/CDC/BootloaderCDC.txt +++ b/Bootloaders/CDC/BootloaderCDC.txt @@ -95,7 +95,9 @@ * following layout: * * \code - * #define BOOTLOADER_API_CALL(Index) (void*)(((FLASHEND - 32) + (2 * Index)) / 2) + * #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); @@ -105,13 +107,13 @@ * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5); * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6); * - * #define BOOTLOADER_MAGIC_SIGNATURE_START (FLASHEND - 2) + * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2)) * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB * - * #define BOOTLOADER_CLASS_SIGNATURE_START (FLASHEND - 4) + * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4)) * #define BOOTLOADER_CDC_SIGNATURE 0xCDC1 * - * #define BOOTLOADER_ADDRESS_START (FLASHEND - 8) + * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8)) * #define BOOTLOADER_ADDRESS_LENGTH 4 * \endcode * diff --git a/Bootloaders/DFU/BootloaderAPITable.S b/Bootloaders/DFU/BootloaderAPITable.S index 0935aca775..18ae390fc7 100644 --- a/Bootloaders/DFU/BootloaderAPITable.S +++ b/Bootloaders/DFU/BootloaderAPITable.S @@ -48,7 +48,15 @@ BootloaderAPI_ReadLock_Trampoline: jmp BootloaderAPI_ReadLock BootloaderAPI_WriteLock_Trampoline: jmp BootloaderAPI_WriteLock -BootloaderAPU_UNUSED: +BootloaderAPU_UNUSED1: + ret +BootloaderAPU_UNUSED2: + ret +BootloaderAPU_UNUSED3: + ret +BootloaderAPU_UNUSED4: + ret +BootloaderAPU_UNUSED5: ret ; API function jump table @@ -62,11 +70,11 @@ BootloaderAPI_JumpTable: rjmp BootloaderAPI_ReadFuse_Trampoline rjmp BootloaderAPI_ReadLock_Trampoline rjmp BootloaderAPI_WriteLock_Trampoline - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY - rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED1 ; UNUSED ENTRY 1 + rjmp BootloaderAPU_UNUSED2 ; UNUSED ENTRY 2 + rjmp BootloaderAPU_UNUSED3 ; UNUSED ENTRY 3 + rjmp BootloaderAPU_UNUSED4 ; UNUSED ENTRY 4 + rjmp BootloaderAPU_UNUSED5 ; UNUSED ENTRY 5 ; Bootloader table signatures and information .org (96 - 8) diff --git a/Bootloaders/DFU/BootloaderDFU.txt b/Bootloaders/DFU/BootloaderDFU.txt index 2c9eaf1de5..0ef8aba673 100644 --- a/Bootloaders/DFU/BootloaderDFU.txt +++ b/Bootloaders/DFU/BootloaderDFU.txt @@ -100,7 +100,9 @@ * following layout: * * \code - * #define BOOTLOADER_API_CALL(Index) (void*)(((FLASHEND - 32) + (2 * Index)) / 2) + * #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); @@ -110,13 +112,13 @@ * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5); * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6); * - * #define BOOTLOADER_MAGIC_SIGNATURE_START (FLASHEND - 2) + * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2)) * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB * - * #define BOOTLOADER_CLASS_SIGNATURE_START (FLASHEND - 4) - * #define BOOTLOADER_DFU_SIGNATURE 0xDFB1 + * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4)) + * #define BOOTLOADER_CDC_SIGNATURE 0xDFB1 * - * #define BOOTLOADER_ADDRESS_START (FLASHEND - 8) + * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8)) * #define BOOTLOADER_ADDRESS_LENGTH 4 * \endcode * diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt index f8e1b8f48e..79d70ad270 100644 --- a/LUFA/DoxygenPages/ChangeLog.txt +++ b/LUFA/DoxygenPages/ChangeLog.txt @@ -66,6 +66,7 @@ * defined (thanks to Steven Morehouse) * - Fixed AVRISP-MKII programmer project reset line polarity inverted when the generated EEP file is loaded into the USB AVR's EEPROM and avr-dude is used * - Fixed CDC and DFU bootloaders failing to compile when the bootloader section size is 8KB or more (thanks to Georg Glock) + * - Fixed CDC and DFU bootloaders API function offsets incorrect on some devices (thanks to Rod DeMay) * - Fixed incorrect DFU version number reported to the host in the DFU bootloader descriptors (thanks to Georg Glock) * - Fixed incorrect version hundredths value encoding in VERSION_BCD() macro (thanks to Georg Glock) * From 380f014c4c7b3e317181654577b24c41c266bf8f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 13 May 2012 13:06:11 +0000 Subject: [PATCH 2/3] Added build test to verify correct compilation of all bootloaders using all supported devices. Fixed compile error with the unreleased ATMEGA32U6 device. --- BuildTests/BoardDriverTest/BoardDeviceMap.cfg | 3 +- BuildTests/BoardDriverTest/makefile | 4 +- .../BootloaderTest/BootloaderDeviceMap.cfg | 42 ++++++++++++++ BuildTests/BootloaderTest/makefile | 56 +++++++++++++++++++ BuildTests/makefile | 1 + LUFA.pnproj | 2 +- LUFA/DoxygenPages/ChangeLog.txt | 3 + LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h | 4 +- 8 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 BuildTests/BootloaderTest/BootloaderDeviceMap.cfg create mode 100644 BuildTests/BootloaderTest/makefile diff --git a/BuildTests/BoardDriverTest/BoardDeviceMap.cfg b/BuildTests/BoardDriverTest/BoardDeviceMap.cfg index 683b1819dc..b566ce6bf8 100644 --- a/BuildTests/BoardDriverTest/BoardDeviceMap.cfg +++ b/BuildTests/BoardDriverTest/BoardDeviceMap.cfg @@ -1,4 +1,5 @@ # BOARD DEFINE = {ARCH} : {MCU} : + BOARD_USER = avr8 : at90usb1287 : BOARD_NONE = avr8 : at90usb1287 : BOARD_USBKEY = avr8 : at90usb1287 : @@ -48,4 +49,4 @@ BOARD_MULTIO = avr8 : at90usb162 : BOARD_BIGMULTIO = avr8 : atmega32u4 : BOARD_DUCE = avr8 : atmega32u2 : BOARD_OLIMEX32U4 = avr8 : atmega32u4 : -BOARD_OLIMEXT32U4 = avr8 : atmega32u4 : \ No newline at end of file +BOARD_OLIMEXT32U4 = avr8 : atmega32u4 : diff --git a/BuildTests/BoardDriverTest/makefile b/BuildTests/BoardDriverTest/makefile index 598d953b6e..bc4d55977a 100644 --- a/BuildTests/BoardDriverTest/makefile +++ b/BuildTests/BoardDriverTest/makefile @@ -29,11 +29,11 @@ makeboardlist: @grep "BOARD_" $(LUFA_ROOT_PATH)/LUFA/Common/BoardTypes.h | cut -d'#' -f2 | cut -d' ' -f2 | grep "BOARD_" > BoardList.txt testboards: - echo "buildtest:" > BuildMakefile + @echo "buildtest:" > BuildMakefile @while read line; \ do \ - build_cfg=`grep "$$line " BoardDeviceMap.cfg | sed 's/ //g' | cut -d'=' -f2-`; \ + build_cfg=`grep "$$line " BoardDeviceMap.cfg | sed 's/ //g' | grep -v "#" | cut -d'=' -f2-`; \ \ build_board=$$line; \ build_arch=`echo $$build_cfg | cut -d':' -f1`; \ diff --git a/BuildTests/BootloaderTest/BootloaderDeviceMap.cfg b/BuildTests/BootloaderTest/BootloaderDeviceMap.cfg new file mode 100644 index 0000000000..4d6bbd7b87 --- /dev/null +++ b/BuildTests/BootloaderTest/BootloaderDeviceMap.cfg @@ -0,0 +1,42 @@ +# BOOTLOADER = {ARCH} : {MCU} : {BOARD} : {FLASH SIZE KB} : {BOOT SIZE KB} : + +# ------------ CDC Bootloader ------------- +CDC = avr8 : at90usb1287 : NONE : 128 : 8 : +CDC = avr8 : at90usb647 : NONE : 64 : 4 : +CDC = avr8 : at90usb1286 : NONE : 128 : 8 : +CDC = avr8 : at90usb646 : NONE : 64 : 4 : +CDC = avr8 : atmega32u4 : NONE : 32 : 4 : +CDC = avr8 : atmega16u4 : NONE : 16 : 4 : +CDC = avr8 : atmega32u2 : NONE : 32 : 4 : +CDC = avr8 : atmega16u2 : NONE : 16 : 4 : +CDC = avr8 : atmega8u2 : NONE : 8 : 4 : +CDC = avr8 : at90usb162 : NONE : 16 : 4 : +CDC = avr8 : at90usb82 : NONE : 8 : 4 : + +# ------------ DFU Bootloader ------------- +DFU = avr8 : at90usb1287 : NONE : 128 : 8 : +DFU = avr8 : at90usb647 : NONE : 64 : 4 : +DFU = avr8 : at90usb1286 : NONE : 128 : 8 : +DFU = avr8 : at90usb646 : NONE : 64 : 4 : +DFU = avr8 : atmega32u6 : NONE : 32 : 4 : +DFU = avr8 : atmega32u4 : NONE : 32 : 4 : +DFU = avr8 : atmega16u4 : NONE : 16 : 4 : +DFU = avr8 : atmega32u2 : NONE : 32 : 4 : +DFU = avr8 : atmega16u2 : NONE : 16 : 4 : +DFU = avr8 : atmega8u2 : NONE : 8 : 4 : +DFU = avr8 : at90usb162 : NONE : 16 : 4 : +DFU = avr8 : at90usb82 : NONE : 8 : 4 : + +# ------------ HID Bootloader ------------- +HID = avr8 : at90usb1287 : NONE : 128 : 4 : +HID = avr8 : at90usb647 : NONE : 64 : 4 : +HID = avr8 : at90usb1286 : NONE : 128 : 4 : +HID = avr8 : at90usb646 : NONE : 64 : 4 : +HID = avr8 : atmega32u6 : NONE : 32 : 4 : +HID = avr8 : atmega32u4 : NONE : 32 : 4 : +HID = avr8 : atmega16u4 : NONE : 16 : 4 : +HID = avr8 : atmega32u2 : NONE : 32 : 2 : +HID = avr8 : atmega16u2 : NONE : 16 : 2 : +HID = avr8 : atmega8u2 : NONE : 8 : 2 : +HID = avr8 : at90usb162 : NONE : 16 : 2 : +HID = avr8 : at90usb82 : NONE : 8 : 2 : diff --git a/BuildTests/BootloaderTest/makefile b/BuildTests/BootloaderTest/makefile new file mode 100644 index 0000000000..3a6e5574c5 --- /dev/null +++ b/BuildTests/BootloaderTest/makefile @@ -0,0 +1,56 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2011. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +# Makefile for the bootloader build test. This +# test attempts to build all the bootloaders +# with all supported device configurations. + +# Path to the root of the LUFA tree to scan +LUFA_ROOT_PATH = ../.. + + +all: begin testbootloaders clean end + +begin: + @echo Executing build test "BootloaderTest". + @echo + +end: + @echo Build test "BootloaderTest" complete. + @echo + +testbootloaders: + @echo "buildtest:" > BuildMakefile + + @while read line; \ + do \ + build_cfg=`echo $$line | sed 's/ //g' | grep -v "#"`; \ + \ + if ( ! test -z "$$build_cfg" ); then \ + build_bootloader=`echo $$build_cfg | cut -d'=' -f1`; \ + build_arch=`echo $$build_cfg | cut -d'=' -f2- | cut -d':' -f1`; \ + build_mcu=`echo $$build_cfg | cut -d'=' -f2- | cut -d':' -f2`; \ + build_board=`echo $$build_cfg | cut -d'=' -f2- | cut -d':' -f3`; \ + build_flashsize=`echo $$build_cfg | cut -d'=' -f2- | cut -d':' -f4`; \ + build_bootsize=`echo $$build_cfg | cut -d'=' -f2- | cut -d':' -f5`; \ + \ + printf "Found bootloader configuration for bootloader '%s' (FLASH: %3s KB | BOOT: %3s KB | MCU: %12s / %4s)\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_arch; \ + \ + printf "\t@echo Building bootloader %s - %s - FLASH: %s KB, BOOT: %s KB\n" $$build_bootloader $$build_mcu $$build_flashsize $$build_bootsize >> BuildMakefile; \ + printf "\tmake -s -C $(LUFA_ROOT_PATH)/Bootloaders/%s/ clean\n" $$build_bootloader >> BuildMakefile; \ + printf "\tmake -s -C $(LUFA_ROOT_PATH)/Bootloaders/%s/ MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s elf\n\n" $$build_bootloader $$build_mcu $$build_board $$build_flashsize $$build_bootsize >> BuildMakefile; \ + fi; \ + done < BootloaderDeviceMap.cfg + + $(MAKE) -f BuildMakefile buildtest + +clean: + rm -f BuildMakefile + +%: + \ No newline at end of file diff --git a/BuildTests/makefile b/BuildTests/makefile index ac0cde2603..3f3ca5a03c 100644 --- a/BuildTests/makefile +++ b/BuildTests/makefile @@ -13,6 +13,7 @@ all: %: $(MAKE) -C BoardDriverTest $@ + $(MAKE) -C BootloaderBuildTest $@ $(MAKE) -C ModuleTest $@ $(MAKE) -C SingleUSBModeTest $@ $(MAKE) -C StaticAnalysisTest $@ diff --git a/LUFA.pnproj b/LUFA.pnproj index c01b16461f..86ec6e0ef0 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt index 79d70ad270..ffc4dfee7e 100644 --- a/LUFA/DoxygenPages/ChangeLog.txt +++ b/LUFA/DoxygenPages/ChangeLog.txt @@ -15,6 +15,9 @@ * - Added support for the Olimex AVR-USB-T32U4 board * - Added new Endpoint_ConfigureEndpointTable() function * - Added new Pipe_ConfigurePipeTable() function + * - Added build test to verify correct compilation of all board drivers using all driver APIs + * - Added build test to verify correct compilation of all bootloaders using all supported devices + * - Added build test to verify that there are no detectable errors in the codebase via static analysis * - Library Applications: * - Modified the CDC Host demos to set a default CDC Line Encoding on enumerated devices * - Added Dataflash operational checks and aborts to all projects using the Dataflash to ensure it is working correctly before use diff --git a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h index 37ff220e30..056981a277 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h @@ -216,9 +216,9 @@ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Endpoint_BytesInEndpoint(void) { - #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) && !defined(__AVR_ATmega32U6__) return UEBCX; - #elif defined(USB_SERIES_4_AVR) + #elif defined(USB_SERIES_4_AVR) || defined(__AVR_ATmega32U6__) return (((uint16_t)UEBCHX << 8) | UEBCLX); #elif defined(USB_SERIES_2_AVR) return UEBCLX; From 998009c490409ed4419d3f3d6e43313826bc1796 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 13 May 2012 13:11:04 +0000 Subject: [PATCH 3/3] Fix incorrectly names build test directory references. --- BuildTests/makefile | 2 +- LUFA.pnproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BuildTests/makefile b/BuildTests/makefile index 3f3ca5a03c..bb76edd8c4 100644 --- a/BuildTests/makefile +++ b/BuildTests/makefile @@ -13,7 +13,7 @@ all: %: $(MAKE) -C BoardDriverTest $@ - $(MAKE) -C BootloaderBuildTest $@ + $(MAKE) -C BootloaderTest $@ $(MAKE) -C ModuleTest $@ $(MAKE) -C SingleUSBModeTest $@ $(MAKE) -C StaticAnalysisTest $@ diff --git a/LUFA.pnproj b/LUFA.pnproj index 86ec6e0ef0..363774145a 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file