defines.mk 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. ################################################################################
  2. # \file defines.mk
  3. # \version 1.0
  4. #
  5. # \brief
  6. # Defines, needed for the PSoC 6 build recipe.
  7. #
  8. ################################################################################
  9. # \copyright
  10. # Copyright 2018-2019 Cypress Semiconductor Corporation
  11. # SPDX-License-Identifier: Apache-2.0
  12. #
  13. # Licensed under the Apache License, Version 2.0 (the "License");
  14. # you may not use this file except in compliance with the License.
  15. # You may obtain a copy of the License at
  16. #
  17. # http://www.apache.org/licenses/LICENSE-2.0
  18. #
  19. # Unless required by applicable law or agreed to in writing, software
  20. # distributed under the License is distributed on an "AS IS" BASIS,
  21. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. # See the License for the specific language governing permissions and
  23. # limitations under the License.
  24. ################################################################################
  25. ifeq ($(WHICHFILE),true)
  26. $(info Processing $(lastword $(MAKEFILE_LIST)))
  27. endif
  28. #
  29. # List the supported toolchains
  30. #
  31. CY_SUPPORTED_TOOLCHAINS=GCC_ARM IAR ARM A_Clang
  32. #
  33. # Define the default core
  34. #
  35. CORE?=CM4
  36. CY_START_FLASH=0x10000000
  37. CY_START_SRAM=0x08000000
  38. CY_OPEN_bt_configurator_DEVICE=--device PSoC6
  39. CY_OPENOCD_CHIP_NAME=psoc6
  40. CY_OPENOCD_SECOND_RESET_TYPE=run
  41. CY_OPENOCD_OTHER_RUN_CMD=mon psoc6 reset_halt sysresetreq
  42. CY_OPENOCD_OTHER_RUN_CMD_ECLIPSE=$(CY_OPENOCD_OTHER_RUN_CMD)\&\#13;\&\#10;
  43. #
  44. # Core specifics
  45. #
  46. ifeq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_M0P)))
  47. ifeq ($(CORE),CM0P)
  48. $(call CY_MACRO_ERROR,$(DEVICE) does not have a CM0+ core)
  49. endif
  50. CY_LINKERSCRIPT_SUFFIX=cm4
  51. CY_OPENOCD_EXTRA_PORT_FLAG=
  52. CY_OPENOCD_EXTRA_PORT_ECLIPSE=
  53. CY_OPENOCD_CM0_DISABLE_FLAG=set ENABLE_CM0 0
  54. CY_OPENOCD_CM0_DISABLE_ECLIPSE=-c \"$(CY_OPENOCD_CM0_DISABLE_FLAG)\"\&\#13;\&\#10;
  55. else
  56. ifeq ($(CORE),CM0P)
  57. CY_LINKERSCRIPT_SUFFIX=cm0plus
  58. else
  59. CY_LINKERSCRIPT_SUFFIX=cm4_dual
  60. CY_OPENOCD_EXTRA_PORT_FLAG=gdb_port 3332
  61. CY_OPENOCD_EXTRA_PORT_ECLIPSE=-c \"$(CY_OPENOCD_EXTRA_PORT_FLAG)\"\&\#13;\&\#10;
  62. CY_OPENOCD_CM0_DISABLE_FLAG=
  63. CY_OPENOCD_CM0_DISABLE_ECLIPSE=
  64. endif
  65. endif
  66. #
  67. # Architecure specifics
  68. #
  69. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6ABLE2)))
  70. CY_PSOC_ARCH=psoc6_01
  71. CY_PSOC_DIE_NAME=PSoC6ABLE2
  72. CY_OPENOCD_DEVICE_CFG=psoc6.cfg
  73. CY_JLINK_DEVICE_CFG_PROGRAM=CY8C6xx7_CM0p_sect256KB_tm
  74. CY_JLINK_DEVICE_CFG_DEBUG=CY8C6xx7_CM4_sect256KB
  75. ifeq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_M0P)))
  76. CY_JLINK_DEVICE_CFG_PROGRAM=CY8C6xx6_CM4_sect256KB
  77. CY_JLINK_DEVICE_CFG_DEBUG=CY8C6xx6_CM4_sect256KB
  78. endif
  79. ifneq (,$(findstring CYB0,$(DEVICE)))
  80. CY_PSOC_ARCH=psoc6_secure
  81. CY_PSOC_DIE_NAME=PSoC6ABLE2Secure
  82. CY_OPENOCD_CHIP_NAME=psoc64
  83. CY_OPENOCD_DEVICE_CFG=psoc6_secure.cfg
  84. CY_OPENOCD_CM0_DISABLE_FLAG=set TARGET_AP cm4_ap
  85. CY_OPENOCD_EXTRA_PORT_FLAG=
  86. CY_OPENOCD_CM0_DISABLE_ECLIPSE=-c \"$(CY_OPENOCD_CM0_DISABLE_FLAG)\"\&\#13;\&\#10;
  87. CY_OPENOCD_EXTRA_PORT_ECLIPSE=
  88. CY_OPENOCD_SECOND_RESET_TYPE=init
  89. CY_OPENOCD_OTHER_RUN_CMD=
  90. CY_OPENOCD_OTHER_RUN_CMD_ECLIPSE=
  91. CY_OPENOCD_SMIF_DISABLE=set DISABLE_SMIF 1
  92. CY_OPENOCD_SMIF_DISABLE_ECLIPSE=-c \"$(CY_OPENOCD_SMIF_DISABLE)\"\&\#13;\&\#10;
  93. endif
  94. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6A2M)))
  95. CY_PSOC_ARCH=psoc6_02
  96. CY_PSOC_DIE_NAME=PSoC6A2M
  97. CY_OPENOCD_DEVICE_CFG=psoc6_2m.cfg
  98. CY_JLINK_DEVICE_CFG_PROGRAM=CY8C6xxA_CM0p_sect256KB_tm
  99. CY_JLINK_DEVICE_CFG_DEBUG=CY8C6xxA_CM4_sect256KB
  100. ifneq (,$(findstring CYB0,$(DEVICE)))
  101. CY_PSOC_ARCH=psoc6_2m_secure
  102. CY_PSOC_DIE_NAME=PSoC6A2MSecure
  103. CY_OPENOCD_CHIP_NAME=psoc64_2m
  104. CY_OPENOCD_DEVICE_CFG=psoc6_2m_secure.cfg
  105. CY_OPENOCD_CM0_DISABLE_FLAG=set TARGET_AP cm4_ap
  106. CY_OPENOCD_EXTRA_PORT_FLAG=
  107. CY_OPENOCD_CM0_DISABLE_ECLIPSE=-c \"$(CY_OPENOCD_CM0_DISABLE_FLAG)\"\&\#13;\&\#10;
  108. CY_OPENOCD_EXTRA_PORT_ECLIPSE=
  109. CY_OPENOCD_SECOND_RESET_TYPE=init
  110. CY_OPENOCD_OTHER_RUN_CMD=
  111. CY_OPENOCD_OTHER_RUN_CMD_ECLIPSE=
  112. CY_OPENOCD_SMIF_DISABLE=set DISABLE_SMIF 1
  113. CY_OPENOCD_SMIF_DISABLE_ECLIPSE=-c \"$(CY_OPENOCD_SMIF_DISABLE)\"\&\#13;\&\#10;
  114. endif
  115. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6A512K)))
  116. CY_PSOC_ARCH=psoc6_03
  117. CY_PSOC_DIE_NAME=PSoC6A512K
  118. CY_OPENOCD_DEVICE_CFG=psoc6_512k.cfg
  119. CY_JLINK_DEVICE_CFG_PROGRAM=CY8C6xx5_CM0p_sect256KB_tm
  120. CY_JLINK_DEVICE_CFG_DEBUG=CY8C6xx5_CM4_sect256KB
  121. else
  122. $(call CY_MACRO_ERROR,Incorrect part number $(DEVICE). Check DEVICE variable.)
  123. endif
  124. #
  125. # Flash memory specifics
  126. #
  127. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_512)))
  128. CY_MEMORY_FLASH=524288
  129. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_832)))
  130. CY_MEMORY_FLASH=850944
  131. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_1024)))
  132. CY_MEMORY_FLASH=1048576
  133. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_1856)))
  134. CY_MEMORY_FLASH=1899520
  135. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_2048)))
  136. CY_MEMORY_FLASH=2097152
  137. else
  138. $(call CY_MACRO_ERROR,No Flash memory size defined for $(DEVICE))
  139. endif
  140. #
  141. # SRAM memory specifics
  142. #
  143. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_SRAM_KB_128)))
  144. CY_MEMORY_SRAM=129024
  145. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_SRAM_KB_256)))
  146. CY_MEMORY_SRAM=260096
  147. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_SRAM_KB_288)))
  148. CY_MEMORY_SRAM=292864
  149. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_SRAM_KB_512)))
  150. CY_MEMORY_SRAM=522240
  151. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_SRAM_KB_1024)))
  152. CY_MEMORY_SRAM=1046528
  153. else
  154. $(call CY_MACRO_ERROR,No SRAM memory size defined for $(DEVICE))
  155. endif
  156. #
  157. # linker scripts
  158. #
  159. # Secure parts
  160. ifneq (,$(findstring CYB06,$(DEVICE)))
  161. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6ABLE2)))
  162. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_832)))
  163. CY_LINKER_SCRIPT_NAME=cyb06xx7
  164. endif
  165. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6A2M)))
  166. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_1856)))
  167. CY_LINKER_SCRIPT_NAME=cyb06xxa
  168. endif
  169. endif
  170. # Non-secure part
  171. else
  172. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6A512K)))
  173. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_512)))
  174. CY_LINKER_SCRIPT_NAME=cy8c6xx5
  175. endif
  176. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6ABLE2)))
  177. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_512)))
  178. CY_LINKER_SCRIPT_NAME=cy8c6xx6
  179. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_1024)))
  180. CY_LINKER_SCRIPT_NAME=cy8c6xx7
  181. endif
  182. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_DIE_PSOC6A2M)))
  183. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_1024)))
  184. CY_LINKER_SCRIPT_NAME=cy8c6xx8
  185. else ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FLASH_KB_2048)))
  186. CY_LINKER_SCRIPT_NAME=cy8c6xxa
  187. endif
  188. endif
  189. endif
  190. ifeq ($(CY_LINKER_SCRIPT_NAME),)
  191. $(call CY_MACRO_ERROR,Could not resolve device series for linker script)
  192. endif
  193. #
  194. # Paths used in program/debug
  195. #
  196. ifeq ($(CY_DEVICESUPPORT_PATH),)
  197. CY_OPENOCD_SVD_PATH?=
  198. else
  199. CY_OPENOCD_SVD_PATH?=
  200. endif
  201. CY_OPENOCD_QSPI_CFG_PATH=$(CY_TARGET_DIR)/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource
  202. #
  203. # Set the output file paths
  204. #
  205. ifneq ($(CY_BUILD_LOCATION),)
  206. CY_SYM_FILE?=$(CY_INTERNAL_BUILD_LOCATION)/$(APPNAME)/$(TARGET)/$(CONFIG)/$(APPNAME).elf
  207. CY_PROG_FILE?=$(CY_INTERNAL_BUILD_LOCATION)/$(APPNAME)/$(TARGET)/$(CONFIG)/$(APPNAME).hex
  208. else
  209. CY_SYM_FILE?=\$$\{cy_prj_path\}/$(notdir $(CY_INTERNAL_BUILD_LOC))/$(TARGET)/$(CONFIG)/$(APPNAME).elf
  210. CY_PROG_FILE?=\$$\{cy_prj_path\}/$(notdir $(CY_INTERNAL_BUILD_LOC))/$(TARGET)/$(CONFIG)/$(APPNAME).hex
  211. endif
  212. #
  213. # IDE specifics
  214. #
  215. ifneq (,$(findstring CYB0,$(DEVICE)))
  216. CY_ECLIPSE_TEMPLATES_WILDCARD=*KitProg3*
  217. endif
  218. CY_VSCODE_ARGS="s|&&RELEASETARGET&&|build/$(TARGET)/Release/$(APPNAME).elf|g;"\
  219. "s|&&DEBUGTARGET&&|build/$(TARGET)/Debug/$(APPNAME).elf|g;"\
  220. "s|&&PSOCFAMILY&&|$(CY_PSOC_ARCH)|g;"\
  221. "s|&&MODUSSHELL&&|$(CY_MODUS_SHELL_DIR)|g;"\
  222. "s|&&OPENOCDFILE&&|$(CY_OPENOCD_DEVICE_CFG)|g;"\
  223. "s|&&SVDFILENAME&&|$(CY_OPENOCD_SVD_PATH)|g;"\
  224. "s|&&MODUSTOOLCHAIN&&|$(CY_COMPILER_DIR)|g;"\
  225. "s|&&MODUSTOOLCHAINVERSION&&|$(notdir $(CY_COMPILER_DIR))|g;"\
  226. "s|&&MODUSOPENCOD&&|$(CY_OPENOCD_DIR)|g;"\
  227. "s|&&MODUSLIBMANAGER&&|$(CY_LIBRARY_MANAGER_DIR)|g;"\
  228. CY_ECLIPSE_ARGS="s|&&CY_OPENOCD_CFG&&|$(CY_OPENOCD_DEVICE_CFG)|;"\
  229. "s|&&CY_OPENOCD_CHIP&&|$(CY_OPENOCD_CHIP_NAME)|;"\
  230. "s|&&CY_OPENOCD_SECOND_RESET&&|$(CY_OPENOCD_SECOND_RESET_TYPE)|;"\
  231. "s|&&CY_OPENOCD_OTHER_RUN_CMD&&|$(CY_OPENOCD_OTHER_RUN_CMD_ECLIPSE)|;"\
  232. "s|&&CY_JLINK_CFG_PROGRAM&&|$(CY_JLINK_DEVICE_CFG_PROGRAM)|;"\
  233. "s|&&CY_JLINK_CFG_DEBUG&&|$(CY_JLINK_DEVICE_CFG_DEBUG)|;"\
  234. "s|&&CY_OPENOCD_PORT_SELECT&&|$(CY_OPENOCD_EXTRA_PORT_ECLIPSE)|;"\
  235. "s|&&CY_OPENOCD_CM0_FLAG&&|$(CY_OPENOCD_CM0_DISABLE_ECLIPSE)|;"\
  236. "s|&&CY_OPENOCD_SMIF_DISABLE&&|$(CY_OPENOCD_SMIF_DISABLE_ECLIPSE)|;"\
  237. "s|&&CY_APPNAME&&|$(CY_IDE_PRJNAME)|;"\
  238. "s|&&CY_CONFIG&&|$(CONFIG)|;"\
  239. "s|&&CY_QSPI_CFG_PATH&&|$(CY_OPENOCD_QSPI_CFG_PATH)|;"\
  240. "s|&&CY_SVD_PATH&&|$(CY_OPENOCD_SVD_PATH)|;"\
  241. "s|&&CY_SYM_FILE&&|$(CY_SYM_FILE)|;"\
  242. "s|&&CY_PROG_FILE&&|$(CY_PROG_FILE)|;"
  243. #
  244. # Tools specifics
  245. #
  246. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_CAPSENSE)))
  247. CY_SUPPORTED_TOOL_TYPES+=capsense-configurator capsense-tuner
  248. endif
  249. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_BLE)))
  250. CY_SUPPORTED_TOOL_TYPES+=bt-configurator
  251. endif
  252. ifneq (,$(findstring $(DEVICE),$(CY_DEVICES_WITH_FS_USB)))
  253. CY_SUPPORTED_TOOL_TYPES+=usbdev-configurator
  254. endif
  255. CY_SUPPORTED_TOOL_TYPES+=\
  256. device-configurator\
  257. qspi-configurator\
  258. seglcd-configurator\
  259. smartio-configurator\
  260. cype-tool\
  261. dfuh-tool
  262. # PSoC 6 smartio also uses the .modus extension
  263. modus_DEFAULT_TYPE+=device-configurator smartio-configurator
  264. # PSoC 6 capsense-tuner shares its existence with capsense-configurator
  265. CY_OPEN_NEWCFG_XML_TYPES+=capsense-tuner