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 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. ##############################################################################
  2. # Build global options
  3. # NOTE: Can be overridden externally.
  4. #
  5. # Compiler options here.
  6. ifeq ($(USE_OPT),)
  7. USE_OPT = -O2 -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 = no
  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)/tool/chibios/chibios
  70. CHIBIOS_CONTRIB ?= $(TMK_DIR)/tool/chibios/chibios-contrib
  71. # Startup files. Try a few different locations, for compability with old versions and
  72. # for things hardware in the contrib repository
  73. STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
  74. ifeq ("$(wildcard $(STARTUP_MK))","")
  75. STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
  76. ifeq ("$(wildcard $(STARTUP_MK))","")
  77. STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
  78. endif
  79. endif
  80. include $(STARTUP_MK)
  81. # HAL-OSAL files (optional).
  82. include $(CHIBIOS)/os/hal/hal.mk
  83. PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
  84. ifeq ("$(wildcard $(PLATFORM_MK))","")
  85. PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
  86. endif
  87. include $(PLATFORM_MK)
  88. BOARD_MK = $(TARGET_DIR)/boards/$(BOARD)/board.mk
  89. ifeq ("$(wildcard $(BOARD_MK))","")
  90. BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
  91. ifeq ("$(wildcard $(BOARD_MK))","")
  92. BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk
  93. endif
  94. endif
  95. include $(BOARD_MK)
  96. include $(CHIBIOS)/os/hal/osal/rt/osal.mk
  97. # RTOS files (optional).
  98. include $(CHIBIOS)/os/rt/rt.mk
  99. # Compability with old version
  100. PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
  101. ifeq ("$(wildcard $(PORT_V))","")
  102. PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
  103. endif
  104. include $(PORT_V)
  105. # Other files (optional).
  106. include $(CHIBIOS)/os/hal/lib/streams/streams.mk
  107. # Define linker script file here
  108. ifneq ("$(wildcard $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld)","")
  109. LDSCRIPT = $(TARGET_DIR)/ld/$(MCU_LDSCRIPT).ld
  110. else
  111. LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld
  112. endif
  113. # C sources that can be compiled in ARM or THUMB mode depending on the global
  114. # setting.
  115. CSRC = $(STARTUPSRC) \
  116. $(KERNSRC) \
  117. $(PORTSRC) \
  118. $(OSALSRC) \
  119. $(HALSRC) \
  120. $(PLATFORMSRC) \
  121. $(BOARDSRC) \
  122. $(STREAMSSRC) \
  123. $(TMK_DIR)/protocol/chibios/usb_main.c \
  124. $(TMK_DIR)/protocol/chibios/main.c \
  125. $(SRC)
  126. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  127. # setting.
  128. CPPSRC =
  129. # C sources to be compiled in ARM mode regardless of the global setting.
  130. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  131. # option that results in lower performance and larger code size.
  132. ACSRC =
  133. # C++ sources to be compiled in ARM mode regardless of the global setting.
  134. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  135. # option that results in lower performance and larger code size.
  136. ACPPSRC =
  137. # C sources to be compiled in THUMB mode regardless of the global setting.
  138. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  139. # option that results in lower performance and larger code size.
  140. TCSRC =
  141. # C sources to be compiled in THUMB mode regardless of the global setting.
  142. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  143. # option that results in lower performance and larger code size.
  144. TCPPSRC =
  145. # List ASM source files here
  146. ASMSRC =
  147. ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
  148. INCDIR = $(CHIBIOS)/os/license \
  149. $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
  150. $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
  151. $(STREAMSINC) $(CHIBIOS)/os/various \
  152. $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \
  153. $(TMK_DIR)/protocol $(TARGET_DIR)
  154. #
  155. # Project, sources and paths
  156. ##############################################################################
  157. ##############################################################################
  158. # Compiler settings
  159. #
  160. #TRGT = arm-elf-
  161. TRGT = arm-none-eabi-
  162. CC = $(TRGT)gcc
  163. CPPC = $(TRGT)g++
  164. # Enable loading with g++ only if you need C++ runtime support.
  165. # NOTE: You can use C++ even without C++ support if you are careful. C++
  166. # runtime support makes code size explode.
  167. LD = $(TRGT)gcc
  168. #LD = $(TRGT)g++
  169. CP = $(TRGT)objcopy
  170. AS = $(TRGT)gcc -x assembler-with-cpp
  171. AR = $(TRGT)ar
  172. OD = $(TRGT)objdump
  173. SZ = $(TRGT)size -A
  174. HEX = $(CP) -O ihex
  175. BIN = $(CP) -O binary
  176. # ARM-specific options here
  177. AOPT =
  178. # THUMB-specific options here
  179. TOPT = -mthumb -DTHUMB
  180. # Define C warning options here
  181. CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wno-missing-field-initializers
  182. # Define C++ warning options here
  183. CPPWARN = -Wall -Wextra -Wundef
  184. #
  185. # Compiler settings
  186. ##############################################################################
  187. ##############################################################################
  188. # Start of user section
  189. #
  190. # List all user C define here, like -D_DEBUG=1
  191. ## Select which interfaces to include here!
  192. UDEFS += $(OPT_DEFS)
  193. # Define ASM defines here
  194. UADEFS += $(OPT_DEFS)
  195. # bootloader definitions may be used in the startup .s file
  196. ifneq ("$(wildcard $(TARGET_DIR)/bootloader_defs.h)","")
  197. UADEFS += -include $(TARGET_DIR)/bootloader_defs.h
  198. UDEFS += -include $(TARGET_DIR)/bootloader_defs.h
  199. else ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h)","")
  200. UADEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
  201. UDEFS += -include $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h
  202. endif
  203. # List all user directories here
  204. #UINCDIR =
  205. # List the user directory to look for the libraries here
  206. #ULIBDIR =
  207. # List all user libraries here
  208. #ULIBS =
  209. #
  210. # End of user defines
  211. ##############################################################################
  212. RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
  213. ifeq ("$(wildcard $(RULESPATH)/rules.mk)","")
  214. RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
  215. endif
  216. include $(RULESPATH)/rules.mk