AVR Bootloader for MK-FlightCtrl
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4KB

  1. PRG = fc_boot
  2. OBJ = main.o
  3. MCU_TARGET = atmega644p
  4. OPTIMIZE = -Os
  5. DEFS =
  6. LIBS =
  7. LDSCRIPT_SRC := /usr/lib/ldscripts/avr5.x
  8. LDSCRIPT_DST := ldscript-no-vectors.x
  9. # Override is only needed by avr-lib build system.
  10. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
  11. override LDFLAGS = -Wl,-Map,$(PRG).map,--section-start=.text=0xF800,-T$(LDSCRIPT_DST)
  12. CC = avr-gcc
  13. OBJCOPY = avr-objcopy
  14. OBJDUMP = avr-objdump
  15. SIZE = avr-size
  16. #LDSCRIPT_SRC := $(shell LANG=C $(CC) $(CFLAGS) -Wl,--verbose 2> /dev/null | awk '/^opened script file (.*)$$/{ print $$4 }')
  17. all: $(PRG).elf lst text
  18. $(SIZE) -x -A $(PRG).elf
  19. $(PRG).elf: $(OBJ) | $(LDSCRIPT_DST)
  20. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  21. $(LDSCRIPT_DST): $(LDSCRIPT_SRC)
  22. # remove all lines with *vectors* and insert DISCARD line above .text declaration
  23. sed -e '/.*vectors.*/d' -e 's/\(^[ \t]*\)\(.text[ \t]*\:\)$$/\1\/DISCARD\/ : { *(.vectors) }\n\1\2/g' $^ > $@
  24. # -diff -uNr $^ $@ > $@.diff
  25. clean:
  26. rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin $(LDSCRIPT_DST)
  27. lst: $(PRG).lst
  28. %.lst: %.elf
  29. $(OBJDUMP) -h -S $< > $@
  30. text: hex bin
  31. hex: $(PRG).hex
  32. bin: $(PRG).bin
  33. %.hex: %.elf
  34. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  35. %.bin: %.elf
  36. $(OBJCOPY) -j .text -j .data -O binary $< $@
  37. install: text
  38. avrdude -c dragon_isp -P usb -p m644p -V -U flash:w:$(PRG).hex