ARM7 based quadrocopter
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.
 
 
 
 
 

80 lines
2.2 KiB

  1. TOOLCHAIN = /opt/arm-toolchain
  2. OPENOCD = /opt/arm-toolchain/openocd
  3. AS = $(TOOLCHAIN)/bin/arm-elf-as
  4. CC = $(TOOLCHAIN)/bin/arm-elf-gcc
  5. LD = $(TOOLCHAIN)/bin/arm-elf-ld
  6. NM = $(TOOLCHAIN)/bin/arm-elf-nm
  7. SIZE = $(TOOLCHAIN)/bin/arm-elf-size
  8. OBJCOPY = $(TOOLCHAIN)/bin/arm-elf-objcopy
  9. OBJDUMP = $(TOOLCHAIN)/bin/arm-elf-objdump
  10. INCDIRS = include $(TOOLCHAIN)/lib/gcc/arm-elf/4.3.3/include $(TOOLCHAIN)/arm-elf/include
  11. LIBDIRS = $(TOOLCHAIN)/arm-elf/lib $(TOOLCHAIN)/lib/gcc/arm-elf/4.3.3
  12. # ------
  13. BUILD = build
  14. TARGET = sam7fc
  15. ASFLAGS = -mcpu=arm7tdmi -Wa,-adhlns=$(BUILD)/$(*D)/$(*F).lst,--gdwarf-2 -Iinclude
  16. CFLAGS = -gdwarf-2 -mcpu=arm7tdmi -Os -std=gnu99
  17. CFLAGS += -Wa,-adhlns=$(BUILD)/$(*D)/$(*F).lst
  18. CFLAGS += -nostdinc $(patsubst %,-I%,$(INCDIRS))
  19. CFLAGS += -MD -MP -MF $(BUILD)/$(*D)/$(*F).d
  20. CFLAGS += -Wall
  21. #CFLAGS += -Wextra
  22. #CFLAGS += -Wcast-align -Wimplicit -Wunused
  23. CFLAGS += -Wpointer-arith -Wswitch
  24. CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow
  25. CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return
  26. #CFLAGS += -Wcast-qual -Wnested-externs
  27. #CFLAGS += -Wmissing-prototypes -Wmissing-declarations
  28. CFLAGS += -Wstrict-prototypes
  29. LDFLAGS = -nostartfiles -t ldscript.ld -Wl,-Map=$@.map,--cref
  30. LDFLAGS += $(patsubst %,-L%,$(LIBDIRS))
  31. LDFLAGS += -lc -lgcc
  32. # ------
  33. SRC := $(wildcard *.c) $(wildcard src/*.c) $(wildcard src/*/*.c)
  34. AS_SRC := $(wildcard *.s) $(wildcard src/*.s)
  35. all: $(BUILD)/$(TARGET).elf
  36. @$(SIZE) -x $<
  37. $(BUILD)/$(TARGET).elf: $(patsubst %,$(BUILD)/%,$(AS_SRC:.s=.o) $(SRC:.c=.o))
  38. @echo " Linking file: $@"
  39. @$(shell mkdir -p $(BUILD)/$(*D))
  40. @$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) > /dev/null
  41. @$(OBJCOPY) -O binary $@ $@.bin
  42. @$(OBJCOPY) -O ihex $@ $@.hex
  43. @$(OBJDUMP) -h -S -C $@ > $@.lss
  44. @$(NM) -n $@ > $@.sym
  45. $(BUILD)/%.o: %.c
  46. @echo " Building file: $<"
  47. @$(shell mkdir -p $(BUILD)/$(*D))
  48. @$(CC) -c $(CFLAGS) $< -o $@
  49. $(BUILD)/%.o: %.s
  50. @echo " Building file: $<"
  51. @$(shell mkdir -p $(BUILD)/$(*D))
  52. @$(CC) -c $(ASFLAGS) $< -o $@
  53. clean:
  54. rm -rf $(BUILD)
  55. openocd:
  56. $(shell $(OPENOCD) -f scripts/openocd.cfg)
  57. install: all
  58. # ./scripts/download.sh
  59. $(TOOLCHAIN)/dfu-util -i 0 -D $(BUILD)/$(TARGET).elf.bin
  60. -include $(shell find $(BUILD) -name *.d 2> /dev/null)