summaryrefslogtreecommitdiff
path: root/Bootloaders/DFU
diff options
context:
space:
mode:
authorDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2012-07-30 17:17:40 +0000
committerDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2012-07-30 17:17:40 +0000
commit9b57f660aeb9f8b94893d546d703b95928cb3640 (patch)
treebf545cc06c1f18a9eaf5927ab1f42c4059ff83f4 /Bootloaders/DFU
parenta0a30d5afb506b55655de244f1c7f6b1857279d8 (diff)
Tag the LUFA 120730 release.LUFA-120730
git-svn-id: http://lufa-lib.googlecode.com/svn/tags/LUFA-120730@2428 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'Bootloaders/DFU')
-rw-r--r--Bootloaders/DFU/BootloaderAPI.c2
-rw-r--r--Bootloaders/DFU/BootloaderAPITable.S70
-rw-r--r--Bootloaders/DFU/BootloaderDFU.c40
-rw-r--r--Bootloaders/DFU/BootloaderDFU.h2
-rw-r--r--Bootloaders/DFU/BootloaderDFU.txt3
-rw-r--r--Bootloaders/DFU/Descriptors.c26
-rw-r--r--Bootloaders/DFU/Doxygen.conf10
-rw-r--r--Bootloaders/DFU/makefile50
8 files changed, 118 insertions, 85 deletions
diff --git a/Bootloaders/DFU/BootloaderAPI.c b/Bootloaders/DFU/BootloaderAPI.c
index f161bad9..dadab3d7 100644
--- a/Bootloaders/DFU/BootloaderAPI.c
+++ b/Bootloaders/DFU/BootloaderAPI.c
@@ -38,12 +38,14 @@
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();
}
diff --git a/Bootloaders/DFU/BootloaderAPITable.S b/Bootloaders/DFU/BootloaderAPITable.S
index 18ae390f..9d1e2fc0 100644
--- a/Bootloaders/DFU/BootloaderAPITable.S
+++ b/Bootloaders/DFU/BootloaderAPITable.S
@@ -7,7 +7,7 @@
*/
/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ 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
@@ -28,41 +28,44 @@
this software.
*/
-; Bootloader API Jump Table
-.section .apitable, "ax"
-
; Trampolines to actual API implementations if the target address is outside the
; range of a rjmp instruction (can happen with large bootloader sections)
-.org 0
-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
-BootloaderAPU_UNUSED1:
- ret
-BootloaderAPU_UNUSED2:
- ret
-BootloaderAPU_UNUSED3:
- ret
-BootloaderAPU_UNUSED4:
- ret
-BootloaderAPU_UNUSED5:
- ret
+.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
+ BootloaderAPU_UNUSED1:
+ ret
+ BootloaderAPU_UNUSED2:
+ ret
+ BootloaderAPU_UNUSED3:
+ ret
+ BootloaderAPU_UNUSED4:
+ ret
+ BootloaderAPU_UNUSED5:
+ ret
+
+
; API function jump table
-.org (96 - 32)
+.section .apitable_jumptable, "ax"
.global BootloaderAPI_JumpTable
BootloaderAPI_JumpTable:
+
rjmp BootloaderAPI_ErasePage_Trampoline
rjmp BootloaderAPI_WritePage_Trampoline
rjmp BootloaderAPI_FillWord_Trampoline
@@ -76,10 +79,13 @@ BootloaderAPI_JumpTable:
rjmp BootloaderAPU_UNUSED4 ; UNUSED ENTRY 4
rjmp BootloaderAPU_UNUSED5 ; UNUSED ENTRY 5
+
+
; Bootloader table signatures and information
-.org (96 - 8)
-BootloaderAPI_Signatures:
+.section .apitable_signatures, "ax"
.global BootloaderAPI_Signatures
+BootloaderAPI_Signatures:
+
.long BOOT_START_ADDR ; Start address of the bootloader
.word 0xDFB1 ; Signature for the DFU class bootloader, V1
.word 0xDCFB ; Signature for a LUFA class bootloader
diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c
index f5c8d170..fcacf76c 100644
--- a/Bootloaders/DFU/BootloaderDFU.c
+++ b/Bootloaders/DFU/BootloaderDFU.c
@@ -97,7 +97,7 @@ static uint16_t EndAddr = 0x0000;
* 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;
+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
@@ -106,8 +106,29 @@ uint32_t MagicBootKey ATTR_NO_INIT;
*/
void Application_Jump_Check(void)
{
+ bool JumpToApplication = false;
+
+ #if ((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();
+ #endif
+
/* 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))
+ JumpToApplication |= true;
+
+ /* If a request has been made to jump to the user application, honor it */
+ if (JumpToApplication)
{
/* Turn off the watchdog */
MCUSR &= ~(1<<WDRF);
@@ -130,23 +151,6 @@ int main(void)
/* Configure hardware required by the bootloader */
SetupHardware();
- #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
- /* Disable JTAG debugging */
- MCUCR |= (1 << JTD);
- MCUCR |= (1 << JTD);
-
- /* 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 */
- RunBootloader = (!(PINF & (1 << 4)));
-
- /* Re-enable JTAG debugging */
- MCUCR &= ~(1 << JTD);
- MCUCR &= ~(1 << JTD);
- #endif
-
/* Turn on first LED on the board to indicate that the bootloader has started */
LEDs_SetAllLEDs(LEDS_LED1);
diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h
index ffd330d7..8a826f53 100644
--- a/Bootloaders/DFU/BootloaderDFU.h
+++ b/Bootloaders/DFU/BootloaderDFU.h
@@ -62,7 +62,7 @@
#define BOOTLOADER_VERSION_REV 0
/** Magic bootloader key to unlock forced application start mode. */
- #define MAGIC_BOOT_KEY 0xDC42CACA
+ #define MAGIC_BOOT_KEY 0xDC42
/** Complete bootloader version number expressed as a packed byte, constructed from the
* two individual bootloader version macros.
diff --git a/Bootloaders/DFU/BootloaderDFU.txt b/Bootloaders/DFU/BootloaderDFU.txt
index 538214e9..aefe344e 100644
--- a/Bootloaders/DFU/BootloaderDFU.txt
+++ b/Bootloaders/DFU/BootloaderDFU.txt
@@ -38,7 +38,8 @@
* </tr>
* <tr>
* <td><b>Supported USB Speeds:</b></td>
- * <td>Full Speed Mode</td>
+ * <td>Low Speed Mode \n
+ * Full Speed Mode</td>
* </tr>
* </table>
*
diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c
index ff33b6b6..1d358a39 100644
--- a/Bootloaders/DFU/Descriptors.c
+++ b/Bootloaders/DFU/Descriptors.c
@@ -57,8 +57,8 @@ const USB_Descriptor_Device_t DeviceDescriptor =
.ProductID = PRODUCT_ID_CODE,
.ReleaseNumber = VERSION_BCD(00.00),
- .ManufacturerStrIndex = NO_DESCRIPTOR,
- .ProductStrIndex = 0x01,
+ .ManufacturerStrIndex = 0x01,
+ .ProductStrIndex = 0x02,
.SerialNumStrIndex = NO_DESCRIPTOR,
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
@@ -126,15 +126,26 @@ const USB_Descriptor_String_t LanguageString =
.UnicodeString = {LANGUAGE_ID_ENG}
};
+/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
+ * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
+ * Descriptor.
+ */
+const USB_Descriptor_String_t PROGMEM ManufacturerString =
+{
+ .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
+
+ .UnicodeString = L"Dean Camera"
+};
+
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
* Descriptor.
*/
const USB_Descriptor_String_t ProductString =
{
- .Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
+ .Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String},
- .UnicodeString = L"AVR DFU Bootloader"
+ .UnicodeString = L"LUFA DFU Bootloader"
};
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
@@ -169,7 +180,12 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &LanguageString;
Size = LanguageString.Header.Size;
}
- else
+ else if (DescriptorNumber == 0x01)
+ {
+ Address = &ManufacturerString;
+ Size = ManufacturerString.Header.Size;
+ }
+ else if (DescriptorNumber == 0x02)
{
Address = &ProductString;
Size = ProductString.Header.Size;
diff --git a/Bootloaders/DFU/Doxygen.conf b/Bootloaders/DFU/Doxygen.conf
index 9aec702f..d36ebbdc 100644
--- a/Bootloaders/DFU/Doxygen.conf
+++ b/Bootloaders/DFU/Doxygen.conf
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.1
+# Doxyfile 1.8.1.2
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -588,7 +588,7 @@ FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
-# output files in an output format independent way. The create the layout file
+# output files in an output format independent way. To create the layout file
# that represents doxygen's defaults, run doxygen with the -l option.
# You can optionally specify a file name after the option, if omitted
# DoxygenLayout.xml will be used as the name of the layout file.
@@ -804,7 +804,7 @@ INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
STRIP_CODE_COMMENTS = YES
@@ -956,9 +956,7 @@ HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+# page has loaded.
HTML_DYNAMIC_SECTIONS = YES
diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile
index 22ae1d67..8a9a5adf 100644
--- a/Bootloaders/DFU/makefile
+++ b/Bootloaders/DFU/makefile
@@ -9,20 +9,6 @@
# LUFA Project Makefile.
# --------------------------------------
-# Starting byte address of the bootloader, as a byte address - computed via the formula
-# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024)
-#
-# 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 = 8
-
-# Formulas used to calculate the starting address of the Bootloader section, and the User Application
-# API jump table (for more information on the latter, see the bootloader documentation). These formulas
-# should not need to be altered - modify the FLASH_SIZE_KB and BOOT_SECTION_KB values above instead.
-BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
-BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc)
-
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
@@ -31,16 +17,36 @@ F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderDFU
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
-LUFA_PATH = ../../LUFA/
-CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START)
-LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START) -Wl,--section-start=.apitable=$(BOOT_API_TABLESTART) -Wl,--undefined=BootloaderAPI_JumpTable
+LUFA_PATH = ../../LUFA
+CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
+LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
+
+# Flash size and bootloader section sizes of the target, in KB. These must
+# match the target's total FLASH size and the bootloader size set in the
+# device's fuses.
+FLASH_SIZE_KB = 128
+BOOT_SECTION_SIZE_KB = 8
+
+# Bootloader address calculation formulas (requires the "bc" unix utility)
+# Do not modify these macros, but rather modify the depedant values above.
+BOOT_START_OFFSET = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
+BOOT_SEC_OFFSET = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - $(strip $(1)))" | bc)
+
+# Bootloader linker section flags for relocating the API table sections to
+# known FLASH addresses - these should not normally be user-edited.
+BOOT_SECTION_LD_FLAG = -Wl,--section-start=.apitable_$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=BootloaderAPI_$(strip $(2))
+BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, trampolines, Trampolines, 96)
+BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, jumptable, JumpTable, 32)
+BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, signatures, Signatures, 8)
# Default target
all:
# Include LUFA build script makefiles
-include $(LUFA_PATH)/Build/lufa.core.in
-include $(LUFA_PATH)/Build/lufa.sources.in
-include $(LUFA_PATH)/Build/lufa.build.in
-include $(LUFA_PATH)/Build/lufa.doxygen.in
-include $(LUFA_PATH)/Build/lufa.avrdude.in
+include $(LUFA_PATH)/Build/lufa_core.mk
+include $(LUFA_PATH)/Build/lufa_sources.mk
+include $(LUFA_PATH)/Build/lufa_build.mk
+include $(LUFA_PATH)/Build/lufa_cppcheck.mk
+include $(LUFA_PATH)/Build/lufa_doxygen.mk
+include $(LUFA_PATH)/Build/lufa_avrdude.mk
+include $(LUFA_PATH)/Build/lufa_atprogram.mk