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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

chibios.mk 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. ##############################################################################
  2. # Build global options
  3. # NOTE: Can be overridden externally.
  4. #
  5. # Compiler options here.
  6. ifeq ($(USE_OPT),)
  7. USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -DPROTOCOL_CHIBIOS
  8. endif
  9. # C specific options here (added to USE_OPT).
  10. ifeq ($(USE_COPT),)
  11. USE_COPT =
  12. endif
  13. # include specific config.h?
  14. ifdef CONFIG_H
  15. USE_COPT += -include $(CONFIG_H)
  16. endif
  17. # C++ specific options here (added to USE_OPT).
  18. ifeq ($(USE_CPPOPT),)
  19. USE_CPPOPT = -fno-rtti
  20. endif
  21. # Enable this if you want the linker to remove unused code and data
  22. ifeq ($(USE_LINK_GC),)
  23. USE_LINK_GC = yes
  24. endif
  25. # Linker extra options here.
  26. ifeq ($(USE_LDOPT),)
  27. USE_LDOPT =
  28. endif
  29. # Enable this if you want link time optimizations (LTO)
  30. ifeq ($(USE_LTO),)
  31. USE_LTO = yes
  32. endif
  33. # If enabled, this option allows to compile the application in THUMB mode.
  34. ifeq ($(USE_THUMB),)
  35. USE_THUMB = yes
  36. endif
  37. # Enable this if you want to see the full log while compiling.
  38. ifeq ($(USE_VERBOSE_COMPILE),)
  39. USE_VERBOSE_COMPILE = no
  40. endif
  41. # If enabled, this option makes the build process faster by not compiling
  42. # modules not used in the current configuration.
  43. ifeq ($(USE_SMART_BUILD),)
  44. USE_SMART_BUILD = yes
  45. endif
  46. #
  47. # Build global options
  48. ##############################################################################
  49. ##############################################################################
  50. # Architecture or project specific options
  51. #
  52. # Stack size to be allocated to the Cortex-M process stack. This stack is
  53. # the stack used by the main() thread.
  54. ifeq ($(USE_PROCESS_STACKSIZE),)
  55. USE_PROCESS_STACKSIZE = 0x200
  56. endif
  57. # Stack size to the allocated to the Cortex-M main/exceptions stack. This
  58. # stack is used for processing interrupts and exceptions.
  59. ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
  60. USE_EXCEPTIONS_STACKSIZE = 0x400
  61. endif
  62. #
  63. # Architecture or project specific options
  64. ##############################################################################
  65. ##############################################################################
  66. # Project, sources and paths
  67. #
  68. # Imported source files and paths
  69. CHIBIOS = $(TMK_DIR)/protocol/chibios/chibios
  70. # Startup files.
  71. include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]').mk
  72. # HAL-OSAL files (optional).
  73. include $(CHIBIOS)/os/hal/hal.mk
  74. include $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
  75. ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD))","")
  76. include $(TARGET_DIR)/boards/$(BOARD)/board.mk
  77. else
  78. include $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
  79. endif
  80. include $(CHIBIOS)/os/hal/osal/rt/osal.mk
  81. # RTOS files (optional).
  82. include $(CHIBIOS)/os/rt/rt.mk
  83. include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
  84. # Other files (optional).
  85. # Define linker script file here
  86. ifneq ("$(wildcard $(TARGET_DIR)/ld/$(MCU_MODEL_FAMILY).ld)","")
  87. LDSCRIPT = $(TARGET_DIR)/ld/$(MCU_MODEL_FAMILY).ld
  88. else
  89. LDSCRIPT = $(STARTUPLD)/$(MCU_MODEL_FAMILY).ld
  90. endif
  91. # C sources that can be compiled in ARM or THUMB mode depending on the global
  92. # setting.
  93. CSRC = $(STARTUPSRC) \
  94. $(KERNSRC) \
  95. $(PORTSRC) \
  96. $(OSALSRC) \
  97. $(HALSRC) \
  98. $(PLATFORMSRC) \
  99. $(BOARDSRC) \
  100. $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
  101. $(TMK_DIR)/protocol/chibios/usb_main.c \
  102. $(TMK_DIR)/protocol/chibios/main.c \
  103. $(SRC)
  104. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  105. # setting.
  106. CPPSRC =
  107. # C sources to be compiled in ARM mode regardless of the global setting.
  108. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  109. # option that results in lower performance and larger code size.
  110. ACSRC =
  111. # C++ sources to be compiled in ARM mode regardless of the global setting.
  112. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  113. # option that results in lower performance and larger code size.
  114. ACPPSRC =
  115. # C sources to be compiled in THUMB mode regardless of the global setting.
  116. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  117. # option that results in lower performance and larger code size.
  118. TCSRC =
  119. # C sources to be compiled in THUMB mode regardless of the global setting.
  120. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  121. # option that results in lower performance and larger code size.
  122. TCPPSRC =
  123. # List ASM source files here
  124. ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
  125. INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
  126. $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
  127. $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various \
  128. $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \
  129. $(TARGET_DIR)
  130. #
  131. # Project, sources and paths
  132. ##############################################################################
  133. ##############################################################################
  134. # Compiler settings
  135. #
  136. MCU = cortex-m0
  137. #TRGT = arm-elf-
  138. TRGT = arm-none-eabi-
  139. CC = $(TRGT)gcc
  140. CPPC = $(TRGT)g++
  141. # Enable loading with g++ only if you need C++ runtime support.
  142. # NOTE: You can use C++ even without C++ support if you are careful. C++
  143. # runtime support makes code size explode.
  144. LD = $(TRGT)gcc
  145. #LD = $(TRGT)g++
  146. CP = $(TRGT)objcopy
  147. AS = $(TRGT)gcc -x assembler-with-cpp
  148. AR = $(TRGT)ar
  149. OD = $(TRGT)objdump
  150. SZ = $(TRGT)size
  151. HEX = $(CP) -O ihex
  152. BIN = $(CP) -O binary
  153. # ARM-specific options here
  154. AOPT =
  155. # THUMB-specific options here
  156. TOPT = -mthumb -DTHUMB
  157. # Define C warning options here
  158. CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-missing-field-initializers
  159. # Define C++ warning options here
  160. CPPWARN = -Wall -Wextra -Wundef
  161. #
  162. # Compiler settings
  163. ##############################################################################
  164. ##############################################################################
  165. # Start of user section
  166. #
  167. # List all user C define here, like -D_DEBUG=1
  168. ## Select which interfaces to include here!
  169. UDEFS = $(OPT_DEFS)
  170. # Define ASM defines here
  171. UADEFS =
  172. # List all user directories here
  173. UINCDIR =
  174. # List the user directory to look for the libraries here
  175. ULIBDIR =
  176. # List all user libraries here
  177. ULIBS =
  178. #
  179. # End of user defines
  180. ##############################################################################
  181. RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
  182. include $(RULESPATH)/rules.mk