1
0
Fork 0

Expand bootloader target to support most AVR boards (#6255)

* Update the :bootloader target to pass along correct hardware info

* Update make scripts to properly grab the settings (a big thanks to @yanfali)

* Remove LUFA debug warnings
This commit is contained in:
Drashna Jaelre 2019-07-16 01:28:23 -07:00 committed by skullydazed
parent f6651424a0
commit f859375284
2 changed files with 12 additions and 8 deletions

View file

@ -11,11 +11,11 @@
# Run "make help" for target help. # Run "make help" for target help.
MCU = atmega32u4 MCU ?= atmega32u4
ARCH = AVR8 ARCH ?= AVR8
BOARD = QMK BOARD ?= QMK
F_CPU = 16000000 F_CPU ?= 16000000
F_USB = $(F_CPU) F_USB ?= $(F_CPU)
OPTIMIZATION = s OPTIMIZATION = s
TARGET = BootloaderDFU TARGET = BootloaderDFU
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB) SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
@ -26,8 +26,8 @@ LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAG
# Flash size and bootloader section sizes of the target, in KB. These must # 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 # match the target's total FLASH size and the bootloader size set in the
# device's fuses. # device's fuses.
FLASH_SIZE_KB = 32 FLASH_SIZE_KB ?= 32
BOOT_SECTION_SIZE_KB = 4 BOOT_SECTION_SIZE_KB ?= 4
# Bootloader address calculation formulas # Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above. # Do not modify these macros, but rather modify the dependent values above.

View file

@ -310,7 +310,11 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader: bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean make -C lib/lufa/Bootloaders/DFU/ clean
$(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS) $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
make -C lib/lufa/Bootloaders/DFU/ $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
make -C lib/lufa/Bootloaders/DFU/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB)
printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n" printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n"
cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex