Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #
  2. # Generic and Simple GNU ARM Makefile
  3. #
  4. # Desinged for the gnu-arm-none-eabi tool chain
  5. #
  6. # Features
  7. # - create hex file
  8. # - create assembler listing (.dis)
  9. #
  10. # Limitations
  11. # - only C-files supported
  12. # - no automatic dependency checking (call 'make clean' if any .h files are changed)
  13. #
  14. # Targets:
  15. # make
  16. # create hex file, no upload
  17. # make upload
  18. # create and upload hex file
  19. # make clean
  20. # delete all generated files
  21. #
  22. # Note:
  23. # Display list make database: make -p -f/dev/null | less
  24. #
  25. #================================================
  26. # External tools
  27. # The base directory of gcc-arm-none-eabi
  28. # Can be empty on Ubuntu and installed gcc-arm-none-eabi
  29. # If set, GCCBINPATH must contain a "/" at the end.
  30. GCCBINPATH:=/usr/bin/
  31. #================================================
  32. # Project Information
  33. # The name for the project
  34. TARGETNAME:=u8g2_logo
  35. # The source files of the project
  36. SRC:=$(wildcard *.c)
  37. # The CPU architecture (will be used for -mcpu)
  38. # for the LPC824, can we use "cortex-m0plus"?
  39. MCPU:=cortex-m0
  40. # Include directory for the system include files
  41. SYSINC:=../lpc_chip_82x/inc
  42. SYSSRC:=$(wildcard ../lpc_chip_82x/src/*.c)
  43. # Include directory for the u8g2 include files
  44. U8G2INC:=../../../../csrc/
  45. U8G2SRC:=$(wildcard ../../../../csrc/*.c)
  46. # directory for FatFS
  47. #FFINC:=../fatfs
  48. #FFSRC:=$(wildcard ../fatfs/*.c)
  49. # Directory for the linker script
  50. LDSCRIPTDIR:=.
  51. # Name of the linker script (must be the "keep" script, because the other script is not always working)
  52. LDSCRIPT:=lpc824.ld
  53. #================================================
  54. # Main part of the Makefile starts here. Usually no changes are needed.
  55. # Internal Variable Names
  56. LIBNAME:=$(TARGETNAME).a
  57. ELFNAME:=$(TARGETNAME).elf
  58. HEXNAME:=$(TARGETNAME).hex
  59. BINNAME:=firmware.bin
  60. DISNAME:=$(TARGETNAME).dis
  61. MAPNAME:=$(TARGETNAME).map
  62. OBJ:=$(SRC:.c=.o) $(SYSSRC:.c=.o) $(U8G2SRC:.c=.o) $(FFSRC:.c=.o)
  63. # Replace standard build tools by avr tools
  64. CC:=$(GCCBINPATH)arm-none-eabi-gcc
  65. AR:=$(GCCBINPATH)arm-none-eabi-ar
  66. OBJCOPY:=$(GCCBINPATH)arm-none-eabi-objcopy
  67. OBJDUMP:=$(GCCBINPATH)arm-none-eabi-objdump
  68. SIZE:=$(GCCBINPATH)arm-none-eabi-size
  69. # Common flags
  70. COMMON_FLAGS = -mthumb -mcpu=$(MCPU)
  71. COMMON_FLAGS += -Wall -I. -I$(SYSINC) -I$(U8G2INC)
  72. # define stack size (defaults to 0x0100)
  73. # COMMON_FLAGS += -D__STACK_SIZE=0x0100
  74. # define constant for lpcopen library
  75. COMMON_FLAGS += -DCORE_M0PLUS
  76. # instruct LPC8xx lib procedures to use the ROM API
  77. COMMON_FLAGS += -DUSE_ROM_API
  78. # do not make a call to SystemInit()
  79. # COMMON_FLAGS += -Os -flto
  80. COMMON_FLAGS += -Os
  81. # COMMON_FLAGS += -fstack-protector
  82. # COMMON_FLAGS += -finstrument-functions
  83. # Do not use stand libs startup code. Uncomment this for gcclib procedures
  84. # memcpy still works, but might be required for __aeabi_uidiv
  85. # COMMON_FLAGS += -nostdlib
  86. # remove unused data and function
  87. COMMON_FLAGS += -ffunction-sections -fdata-sections
  88. # COMMON_FLAGS += -fshort-wchar
  89. # C flags
  90. CFLAGS:=$(COMMON_FLAGS) -std=gnu99
  91. # LD flags
  92. # remove unreferenced procedures and variables, but keep "arm_stack_area" and __isr_vector
  93. GC:=-Wl,--gc-sections -Wl,--undefined=arm_stack_area -Wl,--undefined=__isr_vector
  94. MAP:=-Wl,-Map=$(MAPNAME)
  95. LFLAGS:=$(COMMON_FLAGS) $(GC) $(MAP)
  96. #LDLIBS:=--specs=nano.specs -lc -lc -lnosys -L$(LDSCRIPTDIR) -T $(LDSCRIPT)
  97. LDLIBS:=--specs=nosys.specs -lc -lc -lnosys -L$(LDSCRIPTDIR) -T $(LDSCRIPT)
  98. # Additional Suffixes
  99. .SUFFIXES: .elf .hex .bin .dis
  100. # Targets
  101. .PHONY: all
  102. all: $(DISNAME) $(HEXNAME) $(BINNAME)
  103. $(SIZE) $(ELFNAME)
  104. .PHONY: upload
  105. upload: $(DISNAME) $(HEXNAME) $(ELFNAME) $(BINNAME)
  106. #dd bs=1024 conv=nocreat,notrunc if=$(BINNAME) of="/media/$(shell echo $$USER)/CRP DISABLD/firmware.bin"
  107. ../hex2lpc/hex2lpc -s 2 -f $(HEXNAME) -x
  108. $(SIZE) $(ELFNAME)
  109. .PHONY: clean
  110. clean:
  111. $(RM) $(OBJ) $(HEXNAME) $(ELFNAME) $(LIBNAME) $(DISNAME) $(MAPNAME) $(BINNAME) libssp.a libssp_nonshared.a
  112. # implicit rules
  113. .elf.hex:
  114. $(OBJCOPY) -O ihex $< $@
  115. # explicit rules
  116. $(ELFNAME): $(LIBNAME)($(OBJ)) libssp.a libssp_nonshared.a
  117. $(LINK.o) $(LFLAGS) $(LIBNAME) $(LDLIBS) -o $@
  118. $(DISNAME): $(ELFNAME)
  119. $(OBJDUMP) -D -S $< > $@
  120. # not required for this project
  121. $(BINNAME): $(ELFNAME)
  122. $(OBJCOPY) -O binary --gap-fill 255 --pad-to 32768 $< $@
  123. # create empty ssp libs for -fstack-protector-all -fstack-protector
  124. libssp.a:
  125. $(AR) rcs $@
  126. libssp_nonshared.a:
  127. $(AR) rcs $@