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

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