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.

101 lines
2.6KB

  1. CROSS_COMPILE ?= arm-none-eabi-
  2. SDK_PATH ?= ..
  3. CC := $(CROSS_COMPILE)gcc
  4. LD := $(CROSS_COMPILE)ld
  5. OBJCOPY := $(CROSS_COMPILE)objcopy
  6. SIZE := $(CROSS_COMPILE)size
  7. SRCS := \
  8. main.c \
  9. clock_config.c \
  10. $(SDK_PATH)/devices/MIMXRT1011/gcc/startup_MIMXRT1011.S \
  11. $(SDK_PATH)/boards/evkmimxrt1010/xip/evkmimxrt1010_flexspi_nor_config.c \
  12. $(SDK_PATH)/devices/MIMXRT1011/drivers/fsl_clock.c \
  13. $(SDK_PATH)/devices/MIMXRT1011/drivers/fsl_gpio.c \
  14. $(SDK_PATH)/devices/MIMXRT1011/drivers/fsl_lpuart.c \
  15. $(SDK_PATH)/devices/MIMXRT1011/system_MIMXRT1011.c \
  16. $(SDK_PATH)/devices/MIMXRT1011/xip/fsl_flexspi_nor_boot.c \
  17. INCS := \
  18. . \
  19. $(SDK_PATH)/devices/MIMXRT1011/drivers \
  20. $(SDK_PATH)/devices/MIMXRT1011 \
  21. $(SDK_PATH)/CMSIS/Include
  22. DEFS := \
  23. CPU_MIMXRT1011DAE5A \
  24. DEBUG \
  25. XIP_EXTERNAL_FLASH=1 \
  26. XIP_BOOT_HEADER_ENABLE=1
  27. LIBS := -lc -lgcc -lnosys
  28. OBJS := $(patsubst %.c,out/obj/%.c.o, $(filter %.c, $(SRCS))) $(patsubst %.S,out/obj/%.S.o, $(filter %.S, $(SRCS)))
  29. DEPS := $(patsubst %.o,%.d,$(OBJS))
  30. LDSCRIPT := $(SDK_PATH)/devices/MIMXRT1011/gcc/MIMXRT1011xxxxx_flexspi_nor.ld
  31. CFLAGS := \
  32. -mcpu=cortex-m7 -mthumb -mapcs \
  33. -mfloat-abi=hard -mfpu=fpv5-sp-d16 \
  34. -std=gnu99 -Os -g3 -Wall -Wextra -Wno-unused-parameter \
  35. -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -fstack-usage \
  36. $(addprefix -D, $(DEFS)) \
  37. $(addprefix -I, $(INCS))
  38. LDFLAGS := \
  39. -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mthumb -mapcs \
  40. -Xlinker --sort-section=alignment -Xlinker --cref \
  41. -Wl,--gc-sections --specs=nano.specs \
  42. -T$(LDSCRIPT) \
  43. $(LIBS)
  44. all: out/app.bin
  45. .PHONY: all
  46. out/obj/%.c.o: %.c
  47. @echo "CC $<"
  48. @mkdir -p $(dir $@)
  49. @$(CC) -MM -MF $(subst .o,.d,$@) -MP -MT "$@ $(subst .o,.d,$@)" $(CFLAGS) $<
  50. @$(CC) $(CFLAGS) -c -o $@ $<
  51. out/obj/%.S.o: %.S
  52. @echo "AS $<"
  53. @mkdir -p $(dir $@)
  54. @$(CC) -MM -MF $(subst .o,.d,$@) -MP -MT "$@ $(subst .o,.d,$@)" $(CFLAGS) $<
  55. @$(CC) -x assembler-with-cpp $(CFLAGS) -c -o $@ $<
  56. out/app.elf: $(OBJS)
  57. @echo "LD $@"
  58. @$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Xlinker -Map=$@.map
  59. @$(SIZE) $@
  60. %.bin: %.elf
  61. @$(OBJCOPY) -O binary $< $@
  62. clean:
  63. @echo "Removing the out directory"
  64. @rm -rf out/
  65. .PHONY: clean
  66. flash: out/app.elf
  67. @./tools/crt_emu_cm_redlink \
  68. -g \
  69. -p MIMXRT1011xxxxx \
  70. --flash-load-exec "$<" \
  71. --connectscript=RT1010_connect.scp \
  72. --debug 4 \
  73. --no-packed
  74. .PHONY: flash
  75. debug: out/app.elf
  76. @arm-none-eabi-gdb $< \
  77. -ex "set non-stop on" \
  78. -ex "target extended-remote | ./tools/crt_emu_cm_redlink -g -pMIMXRT1011xxxxx --connectscript=RT1010_connect.scp --no-packed" \
  79. -ex "load"
  80. .PHONY: debug
  81. ifneq ("$(MAKECMDGOALS)","clean")
  82. -include $(DEPS)
  83. endif