Skip to content

Commit

Permalink
Tag for the LUFA-120730-BETA release.
Browse files Browse the repository at this point in the history
  • Loading branch information
abcminiuser committed Jul 16, 2012
1 parent 56e792c commit e34c771
Show file tree
Hide file tree
Showing 265 changed files with 12,253 additions and 18,233 deletions.
2 changes: 2 additions & 0 deletions Bootloaders/CDC/BootloaderAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
72 changes: 39 additions & 33 deletions Bootloaders/CDC/BootloaderAPITable.S
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2012.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
Expand Down Expand Up @@ -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
Expand All @@ -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 0xCDC1 ; Signature for the CDC class bootloader, V1
.word 0xDFB1 ; Signature for the DFU class bootloader, V1
.word 0xDCFB ; Signature for a LUFA class bootloader
23 changes: 22 additions & 1 deletion Bootloaders/CDC/BootloaderCDC.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static bool RunBootloader = true;
* 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
Expand All @@ -70,8 +70,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);
Expand Down
2 changes: 1 addition & 1 deletion Bootloaders/CDC/BootloaderCDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#define SOFTWARE_IDENTIFIER "LUFACDC"

/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42CACA
#define MAGIC_BOOT_KEY 0xDC42

/* Type Defines: */
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
Expand Down
84 changes: 19 additions & 65 deletions Bootloaders/CDC/LUFA CDC Bootloader.inf
Original file line number Diff line number Diff line change
@@ -1,78 +1,36 @@
;************************************************************
; Windows USB CDC ACM Setup File
; Copyright (c) 2000 Microsoft Corporation

;************************************************************

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%MFGNAME%
LayoutFile=layout.inf
CatalogFile=%MFGFILENAME%.cat
DriverVer=11/15/2007,5.1.2600.0
DriverVer=7/1/2012,10.0.0.0

[Manufacturer]
%MFGNAME%=DeviceList, NTamd64

[DestinationDirs]
DefaultDestDir=12


;------------------------------------------------------------------------------
; Windows 2000/XP/Vista-32bit Sections
;------------------------------------------------------------------------------

[DriverInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg

[DriverCopyFiles.nt]
usbser.sys,,,0x20

[DriverInstall.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64

[DriverInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt

[DriverService.nt]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys

;------------------------------------------------------------------------------
; Vista-64bit Sections
;------------------------------------------------------------------------------

[DriverInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg
[SourceDisksNames]

[DriverCopyFiles.NTamd64]
%DRIVERFILENAME%.sys,,,0x20
[SourceDisksFiles]

[DriverInstall.NTamd64.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
[DestinationDirs]
DefaultDestDir=12

[DriverInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64
[DriverInstall]
Include=mdmcpq.inf
CopyFiles=FakeModemCopyFileSection
AddReg=DriverInstall.AddReg

[DriverService.NTamd64]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys
[DriverInstall.Services]
Include=mdmcpq.inf
AddService=usbser, 0x00000002, LowerFilter_Service_Inst

[DriverInstall.AddReg]
HKR,,EnumPropPages32,,"msports.dll,SerialPortPropPageProvider"

;------------------------------------------------------------------------------
; Vendor and Product ID Definitions
Expand All @@ -83,24 +41,20 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
;------------------------------------------------------------------------------
[SourceDisksFiles]
[SourceDisksNames]
[DeviceList]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A

[DeviceList.NTamd64]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A

[DeviceList.NTia64]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A

;------------------------------------------------------------------------------
; String Definitions
;------------------------------------------------------------------------------
;Modify these strings to customize your device
;------------------------------------------------------------------------------
[Strings]
MFGFILENAME="CDC_vista"
DRIVERFILENAME ="usbser"
MFGNAME="http://www.lufa-lib.org"
INSTDISK="LUFA CDC Bootloader Driver Installer"
DESCRIPTION="Communications Port"
SERVICE="USB RS-232 Emulation Driver"
DESCRIPTION="LUFA CDC Class Bootloader"
50 changes: 28 additions & 22 deletions Bootloaders/CDC/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,16 +17,36 @@ F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderCDC
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
2 changes: 2 additions & 0 deletions Bootloaders/DFU/BootloaderAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Loading

0 comments on commit e34c771

Please sign in to comment.