Skip to content

Commit

Permalink
Expand bootloader target to support most AVR boards (#6255)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drashna authored and skullydazed committed Jul 16, 2019
1 parent f665142 commit f859375
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/lufa/Bootloaders/DFU/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

# Run "make help" for target help.

MCU = atmega32u4
ARCH = AVR8
BOARD = QMK
F_CPU = 16000000
F_USB = $(F_CPU)
MCU ?= atmega32u4
ARCH ?= AVR8
BOARD ?= QMK
F_CPU ?= 16000000
F_USB ?= $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderDFU
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
Expand All @@ -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
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB = 32
BOOT_SECTION_SIZE_KB = 4
FLASH_SIZE_KB ?= 32
BOOT_SECTION_SIZE_KB ?= 4

# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
Expand Down
6 changes: 5 additions & 1 deletion tmk_core/avr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean
$(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"
cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex

Expand Down

0 comments on commit f859375

Please sign in to comment.