-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
58 lines (45 loc) · 2.18 KB
/
makefile
File metadata and controls
58 lines (45 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# LUFA Library
# Copyright (C) Dean Camera, 2014.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = atmega32u4
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000UL
TARGET = BootloaderHID
SRC = $(TARGET).c
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
# 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 := 16
BOOT_SECTION_SIZE_KB := 2
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
# Default target
all: gcc lnk objcpy objdmp nm size
gcc: $(TARGET).c
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -DARCH=ARCH_$(ARCH) -DBOARD=$(BOARD) -DF_CPU=$(F_CPU) -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -MMD -MP -MF $(TARGET).d $(TARGET).c -o $(TARGET).o
lnk: $(TARGET).o
avr-gcc $(TARGET).o -o $(TARGET).elf -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -Wl,--relax -mmcu=$(MCU) $(LD_FLAGS)
objcpy: $(TARGET).elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $(TARGET).elf $(TARGET).hex
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings $(TARGET).elf $(TARGET).eep || exit 0
avr-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature $(TARGET).elf $(TARGET).bin
objdmp: $(TARGET).elf
avr-objdump -h -d -S -z $(TARGET).elf > $(TARGET).lss
nm: $(TARGET).elf
avr-nm -n $(TARGET).elf > $(TARGET).sym
size: $(TARGET).elf
avr-size --mcu=$(MCU) --format=avr $(TARGET).elf
clean:
rm -f *.d *.eep *.elf *.lss *.map *.hex *.bin *.o *.sym