Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. PROJECT_NAME := ble_app_uart_c_pca10040_s132
  2. TARGETS := nrf52832_xxaa
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../../..
  5. PROJ_DIR := ../../..
  6. $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
  7. LINKER_SCRIPT := ble_app_uart_c_gcc_nrf52.ld
  8. # Source files common to all targets
  9. SRC_FILES += \
  10. $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
  11. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
  12. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
  13. $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
  14. $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
  15. $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
  16. $(SDK_ROOT)/components/libraries/button/app_button.c \
  17. $(SDK_ROOT)/components/libraries/util/app_error.c \
  18. $(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
  19. $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
  20. $(SDK_ROOT)/components/libraries/fifo/app_fifo.c \
  21. $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \
  22. $(SDK_ROOT)/components/libraries/timer/app_timer2.c \
  23. $(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \
  24. $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  25. $(SDK_ROOT)/components/libraries/timer/drv_rtc.c \
  26. $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
  27. $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
  28. $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \
  29. $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
  30. $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
  31. $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
  32. $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
  33. $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
  34. $(SDK_ROOT)/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c \
  35. $(SDK_ROOT)/components/libraries/queue/nrf_queue.c \
  36. $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
  37. $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
  38. $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \
  39. $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
  40. $(SDK_ROOT)/components/libraries/uart/retarget.c \
  41. $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52.c \
  42. $(SDK_ROOT)/components/boards/boards.c \
  43. $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \
  44. $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
  45. $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \
  46. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
  47. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \
  48. $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
  49. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
  50. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
  51. $(SDK_ROOT)/components/libraries/bsp/bsp.c \
  52. $(SDK_ROOT)/components/libraries/bsp/bsp_btn_ble.c \
  53. $(PROJ_DIR)/main.c \
  54. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
  55. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
  56. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
  57. $(SDK_ROOT)/components/ble/common/ble_advdata.c \
  58. $(SDK_ROOT)/components/ble/ble_db_discovery/ble_db_discovery.c \
  59. $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
  60. $(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
  61. $(SDK_ROOT)/components/ble/nrf_ble_gq/nrf_ble_gq.c \
  62. $(SDK_ROOT)/components/ble/nrf_ble_scan/nrf_ble_scan.c \
  63. $(SDK_ROOT)/external/utf_converter/utf.c \
  64. $(SDK_ROOT)/components/ble/ble_services/ble_nus_c/ble_nus_c.c \
  65. $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
  66. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
  67. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
  68. # Include folders common to all targets
  69. INC_FOLDERS += \
  70. $(SDK_ROOT)/components/nfc/ndef/generic/message \
  71. $(SDK_ROOT)/components/nfc/t2t_lib \
  72. $(SDK_ROOT)/components/nfc/t4t_parser/hl_detection_procedure \
  73. $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
  74. $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
  75. $(SDK_ROOT)/components/libraries/pwm \
  76. $(SDK_ROOT)/components/softdevice/s132/headers/nrf52 \
  77. $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
  78. $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
  79. $(SDK_ROOT)/components/libraries/usbd/class/msc \
  80. $(SDK_ROOT)/components/libraries/usbd/class/hid \
  81. $(SDK_ROOT)/modules/nrfx/hal \
  82. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser \
  83. $(SDK_ROOT)/components/libraries/log \
  84. $(SDK_ROOT)/components/ble/ble_services/ble_gls \
  85. $(SDK_ROOT)/components/libraries/fstorage \
  86. $(SDK_ROOT)/components/nfc/ndef/text \
  87. $(SDK_ROOT)/components/libraries/mutex \
  88. $(SDK_ROOT)/components/libraries/gfx \
  89. $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \
  90. $(SDK_ROOT)/components/nfc/ndef/connection_handover/common \
  91. $(SDK_ROOT)/components/libraries/fifo \
  92. $(SDK_ROOT)/components/boards \
  93. $(SDK_ROOT)/components/nfc/ndef/generic/record \
  94. $(SDK_ROOT)/components/nfc/t4t_parser/cc_file \
  95. $(SDK_ROOT)/components/ble/ble_advertising \
  96. $(SDK_ROOT)/external/utf_converter \
  97. $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
  98. $(SDK_ROOT)/modules/nrfx/drivers/include \
  99. $(SDK_ROOT)/components/libraries/experimental_task_manager \
  100. $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
  101. $(SDK_ROOT)/components/nfc/ndef/connection_handover/le_oob_rec \
  102. $(SDK_ROOT)/components/libraries/queue \
  103. $(SDK_ROOT)/components/libraries/pwr_mgmt \
  104. $(SDK_ROOT)/components/ble/ble_dtm \
  105. $(SDK_ROOT)/components/toolchain/cmsis/include \
  106. $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
  107. $(SDK_ROOT)/components/ble/common \
  108. $(SDK_ROOT)/components/ble/ble_services/ble_lls \
  109. $(SDK_ROOT)/components/nfc/platform \
  110. $(SDK_ROOT)/components/libraries/bsp \
  111. $(SDK_ROOT)/components/ble/ble_db_discovery \
  112. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ac_rec \
  113. $(SDK_ROOT)/components/ble/ble_services/ble_bas \
  114. $(SDK_ROOT)/components/libraries/mpu \
  115. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  116. $(SDK_ROOT)/components/softdevice/s132/headers \
  117. $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
  118. $(SDK_ROOT)/components/libraries/slip \
  119. $(SDK_ROOT)/components/libraries/delay \
  120. $(SDK_ROOT)/components/libraries/csense_drv \
  121. $(SDK_ROOT)/components/libraries/memobj \
  122. $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
  123. $(SDK_ROOT)/components/softdevice/common \
  124. $(SDK_ROOT)/components/ble/ble_services/ble_ias \
  125. $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
  126. $(SDK_ROOT)/components/libraries/ecc \
  127. $(SDK_ROOT)/components/ble/nrf_ble_scan \
  128. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser \
  129. $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
  130. $(SDK_ROOT)/external/fprintf \
  131. $(SDK_ROOT)/components/libraries/svc \
  132. $(SDK_ROOT)/components/libraries/atomic \
  133. $(SDK_ROOT)/components \
  134. $(SDK_ROOT)/components/libraries/scheduler \
  135. $(SDK_ROOT)/components/libraries/cli \
  136. $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
  137. $(SDK_ROOT)/components/ble/ble_services/ble_hts \
  138. $(SDK_ROOT)/components/libraries/crc16 \
  139. $(SDK_ROOT)/components/nfc/t4t_parser/apdu \
  140. $(SDK_ROOT)/components/libraries/util \
  141. ../config \
  142. $(SDK_ROOT)/components/libraries/usbd/class/cdc \
  143. $(SDK_ROOT)/components/libraries/csense \
  144. $(SDK_ROOT)/components/libraries/balloc \
  145. $(SDK_ROOT)/components/libraries/low_power_pwm \
  146. $(SDK_ROOT)/components/libraries/hardfault \
  147. $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
  148. $(SDK_ROOT)/components/libraries/uart \
  149. $(SDK_ROOT)/components/libraries/hci \
  150. $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
  151. $(SDK_ROOT)/components/libraries/timer \
  152. $(SDK_ROOT)/integration/nrfx \
  153. $(SDK_ROOT)/components/nfc/t4t_parser/tlv \
  154. $(SDK_ROOT)/components/libraries/sortlist \
  155. $(SDK_ROOT)/components/libraries/spi_mngr \
  156. $(SDK_ROOT)/components/libraries/led_softblink \
  157. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser \
  158. $(SDK_ROOT)/components/libraries/sdcard \
  159. $(SDK_ROOT)/components/nfc/ndef/parser/record \
  160. $(SDK_ROOT)/modules/nrfx/mdk \
  161. $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
  162. $(SDK_ROOT)/components/ble/ble_services/ble_nus \
  163. $(SDK_ROOT)/components/libraries/twi_mngr \
  164. $(SDK_ROOT)/components/ble/ble_services/ble_hids \
  165. $(SDK_ROOT)/components/libraries/strerror \
  166. $(SDK_ROOT)/components/libraries/crc32 \
  167. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_oob_advdata \
  168. $(SDK_ROOT)/components/nfc/t2t_parser \
  169. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_msg \
  170. $(SDK_ROOT)/components/libraries/usbd/class/audio \
  171. $(SDK_ROOT)/components/nfc/t4t_lib \
  172. $(SDK_ROOT)/components/ble/peer_manager \
  173. $(SDK_ROOT)/components/libraries/mem_manager \
  174. $(SDK_ROOT)/components/libraries/ringbuf \
  175. $(SDK_ROOT)/components/ble/ble_services/ble_tps \
  176. $(SDK_ROOT)/components/nfc/ndef/parser/message \
  177. $(SDK_ROOT)/components/ble/ble_services/ble_dis \
  178. $(SDK_ROOT)/components/nfc/ndef/uri \
  179. $(SDK_ROOT)/components/ble/nrf_ble_gatt \
  180. $(SDK_ROOT)/components/ble/nrf_ble_qwr \
  181. $(SDK_ROOT)/components/libraries/gpiote \
  182. $(SDK_ROOT)/components/libraries/button \
  183. $(SDK_ROOT)/modules/nrfx \
  184. $(SDK_ROOT)/components/libraries/twi_sensor \
  185. $(SDK_ROOT)/integration/nrfx/legacy \
  186. $(SDK_ROOT)/components/libraries/usbd \
  187. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ep_oob_rec \
  188. $(SDK_ROOT)/external/segger_rtt \
  189. $(SDK_ROOT)/components/libraries/atomic_fifo \
  190. $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
  191. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_lib \
  192. $(SDK_ROOT)/components/libraries/crypto \
  193. $(SDK_ROOT)/components/ble/ble_racp \
  194. $(SDK_ROOT)/components/libraries/fds \
  195. $(SDK_ROOT)/components/nfc/ndef/launchapp \
  196. $(SDK_ROOT)/components/ble/nrf_ble_gq \
  197. $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
  198. $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
  199. $(SDK_ROOT)/components/nfc/ndef/connection_handover/hs_rec \
  200. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ac_rec_parser \
  201. $(SDK_ROOT)/components/libraries/stack_guard \
  202. $(SDK_ROOT)/components/libraries/log/src \
  203. # Libraries common to all targets
  204. LIB_FILES += \
  205. # Optimization flags
  206. OPT = -O3 -g3
  207. # Uncomment the line below to enable link time optimization
  208. #OPT += -flto
  209. # C flags common to all targets
  210. CFLAGS += $(OPT)
  211. CFLAGS += -DAPP_TIMER_V2
  212. CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  213. CFLAGS += -DBOARD_PCA10040
  214. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  215. CFLAGS += -DFLOAT_ABI_HARD
  216. CFLAGS += -DNRF52
  217. CFLAGS += -DNRF52832_XXAA
  218. CFLAGS += -DNRF52_PAN_74
  219. CFLAGS += -DNRF_SD_BLE_API_VERSION=7
  220. CFLAGS += -DS132
  221. CFLAGS += -DSOFTDEVICE_PRESENT
  222. CFLAGS += -mcpu=cortex-m4
  223. CFLAGS += -mthumb -mabi=aapcs
  224. CFLAGS += -Wall -Werror
  225. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  226. # keep every function in a separate section, this allows linker to discard unused ones
  227. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  228. CFLAGS += -fno-builtin -fshort-enums
  229. # C++ flags common to all targets
  230. CXXFLAGS += $(OPT)
  231. # Assembler flags common to all targets
  232. ASMFLAGS += -g3
  233. ASMFLAGS += -mcpu=cortex-m4
  234. ASMFLAGS += -mthumb -mabi=aapcs
  235. ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  236. ASMFLAGS += -DAPP_TIMER_V2
  237. ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  238. ASMFLAGS += -DBOARD_PCA10040
  239. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  240. ASMFLAGS += -DFLOAT_ABI_HARD
  241. ASMFLAGS += -DNRF52
  242. ASMFLAGS += -DNRF52832_XXAA
  243. ASMFLAGS += -DNRF52_PAN_74
  244. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7
  245. ASMFLAGS += -DS132
  246. ASMFLAGS += -DSOFTDEVICE_PRESENT
  247. # Linker flags
  248. LDFLAGS += $(OPT)
  249. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  250. LDFLAGS += -mcpu=cortex-m4
  251. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  252. # let linker dump unused sections
  253. LDFLAGS += -Wl,--gc-sections
  254. # use newlib in nano version
  255. LDFLAGS += --specs=nano.specs
  256. nrf52832_xxaa: CFLAGS += -D__HEAP_SIZE=8192
  257. nrf52832_xxaa: CFLAGS += -D__STACK_SIZE=8192
  258. nrf52832_xxaa: ASMFLAGS += -D__HEAP_SIZE=8192
  259. nrf52832_xxaa: ASMFLAGS += -D__STACK_SIZE=8192
  260. # Add standard libraries at the very end of the linker input, after all objects
  261. # that may need symbols provided by these libraries.
  262. LIB_FILES += -lc -lnosys -lm
  263. .PHONY: default help
  264. # Default target - first one defined
  265. default: nrf52832_xxaa
  266. # Print all targets that can be built
  267. help:
  268. @echo following targets are available:
  269. @echo nrf52832_xxaa
  270. @echo flash_softdevice
  271. @echo sdk_config - starting external tool for editing sdk_config.h
  272. @echo flash - flashing binary
  273. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  274. include $(TEMPLATE_PATH)/Makefile.common
  275. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  276. .PHONY: flash flash_softdevice erase
  277. # Flash the program
  278. flash: default
  279. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
  280. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --sectorerase
  281. nrfjprog -f nrf52 --reset
  282. # Flash softdevice
  283. flash_softdevice:
  284. @echo Flashing: s132_nrf52_7.0.1_softdevice.hex
  285. nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase
  286. nrfjprog -f nrf52 --reset
  287. erase:
  288. nrfjprog -f nrf52 --eraseall
  289. SDK_CONFIG_FILE := ../config/sdk_config.h
  290. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  291. sdk_config:
  292. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)