From e8570c4a37e41117e3fd1e989e0b41f1e9608f3c Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 14 Apr 2012 10:09:45 +0000 Subject: Fixed CDC and DFU bootloaders failing to compile when the bootloader section size is 8KB or more (thanks to Georg Glock). --- Bootloaders/CDC/BootloaderAPITable.S | 48 +++++++++++++++++++++++++----------- Bootloaders/CDC/makefile | 2 +- Bootloaders/DFU/BootloaderAPITable.S | 48 +++++++++++++++++++++++++----------- Bootloaders/DFU/makefile | 2 +- 4 files changed, 70 insertions(+), 30 deletions(-) (limited to 'Bootloaders') diff --git a/Bootloaders/CDC/BootloaderAPITable.S b/Bootloaders/CDC/BootloaderAPITable.S index 50b7a5d38..fc1e2e99f 100644 --- a/Bootloaders/CDC/BootloaderAPITable.S +++ b/Bootloaders/CDC/BootloaderAPITable.S @@ -31,25 +31,45 @@ ; Bootloader API Jump Table .section .apitable, "ax" -; API function jump table +; 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_UNUSED: + ret + +; API function jump table +.org (96 - 32) .global BootloaderAPI_JumpTable BootloaderAPI_JumpTable: - rjmp BootloaderAPI_ErasePage - rjmp BootloaderAPI_WritePage - rjmp BootloaderAPI_FillWord - rjmp BootloaderAPI_ReadSignature - rjmp BootloaderAPI_ReadFuse - rjmp BootloaderAPI_ReadLock - rjmp BootloaderAPI_WriteLock - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - ret + rjmp BootloaderAPI_ErasePage_Trampoline + rjmp BootloaderAPI_WritePage_Trampoline + rjmp BootloaderAPI_FillWord_Trampoline + rjmp BootloaderAPI_ReadSignature_Trampoline + rjmp BootloaderAPI_ReadFuse_Trampoline + rjmp BootloaderAPI_ReadLock_Trampoline + rjmp BootloaderAPI_WriteLock_Trampoline + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY ; Bootloader table signatures and information -.org (32 - 8) +.org (96 - 8) BootloaderAPI_Signatures: .global BootloaderAPI_Signatures .long BOOT_START_ADDR ; Start address of the bootloader diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile index ca04b6bca..066fb8884 100644 --- a/Bootloaders/CDC/makefile +++ b/Bootloaders/CDC/makefile @@ -102,7 +102,7 @@ BOOT_SECTION_SIZE_KB = 4 # 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) - 32)" | bc) +BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) # Output format. (can be srec, ihex, binary) diff --git a/Bootloaders/DFU/BootloaderAPITable.S b/Bootloaders/DFU/BootloaderAPITable.S index 1ce125e21..0935aca77 100644 --- a/Bootloaders/DFU/BootloaderAPITable.S +++ b/Bootloaders/DFU/BootloaderAPITable.S @@ -31,25 +31,45 @@ ; Bootloader API Jump Table .section .apitable, "ax" -; API function jump table +; 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_UNUSED: + ret + +; API function jump table +.org (96 - 32) .global BootloaderAPI_JumpTable BootloaderAPI_JumpTable: - rjmp BootloaderAPI_ErasePage - rjmp BootloaderAPI_WritePage - rjmp BootloaderAPI_FillWord - rjmp BootloaderAPI_ReadSignature - rjmp BootloaderAPI_ReadFuse - rjmp BootloaderAPI_ReadLock - rjmp BootloaderAPI_WriteLock - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - nop ; UNUSED ENTRY - ret + rjmp BootloaderAPI_ErasePage_Trampoline + rjmp BootloaderAPI_WritePage_Trampoline + rjmp BootloaderAPI_FillWord_Trampoline + rjmp BootloaderAPI_ReadSignature_Trampoline + rjmp BootloaderAPI_ReadFuse_Trampoline + rjmp BootloaderAPI_ReadLock_Trampoline + rjmp BootloaderAPI_WriteLock_Trampoline + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY + rjmp BootloaderAPU_UNUSED ; UNUSED ENTRY ; Bootloader table signatures and information -.org (32 - 8) +.org (96 - 8) BootloaderAPI_Signatures: .global BootloaderAPI_Signatures .long BOOT_START_ADDR ; Start address of the bootloader diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index d23c53ab0..608564ebe 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -102,7 +102,7 @@ BOOT_SECTION_SIZE_KB = 4 # 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) - 32)" | bc) +BOOT_API_TABLESTART = 0x$(shell echo "obase=16; (($(FLASH_SIZE_KB) * 1024) - 96)" | bc) # Output format. (can be srec, ihex, binary) -- cgit v1.2.3