Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. PROJECT_NAME := ble_app_uart_c_pca10100_s122
  2. TARGETS := nrf52833_xxaa
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../../..
  5. PROJ_DIR := ../../..
  6. $(OUTPUT_DIRECTORY)/nrf52833_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_nrf52833.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_nrf52833.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/libraries/usbd/class/cdc/acm \
  77. $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
  78. $(SDK_ROOT)/components/libraries/usbd/class/msc \
  79. $(SDK_ROOT)/components/softdevice/s122/headers/nrf52 \
  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/ble/ble_services/ble_ans_c \
  117. $(SDK_ROOT)/components/libraries/slip \
  118. $(SDK_ROOT)/components/libraries/delay \
  119. $(SDK_ROOT)/components/libraries/csense_drv \
  120. $(SDK_ROOT)/components/libraries/memobj \
  121. $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
  122. $(SDK_ROOT)/components/softdevice/common \
  123. $(SDK_ROOT)/components/ble/ble_services/ble_ias \
  124. $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
  125. $(SDK_ROOT)/components/libraries/ecc \
  126. $(SDK_ROOT)/components/ble/nrf_ble_scan \
  127. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser \
  128. $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
  129. $(SDK_ROOT)/external/fprintf \
  130. $(SDK_ROOT)/components/libraries/svc \
  131. $(SDK_ROOT)/components/libraries/atomic \
  132. $(SDK_ROOT)/components \
  133. $(SDK_ROOT)/components/libraries/scheduler \
  134. $(SDK_ROOT)/components/libraries/cli \
  135. $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
  136. $(SDK_ROOT)/components/ble/ble_services/ble_hts \
  137. $(SDK_ROOT)/components/libraries/crc16 \
  138. $(SDK_ROOT)/components/nfc/t4t_parser/apdu \
  139. $(SDK_ROOT)/components/libraries/util \
  140. ../config \
  141. $(SDK_ROOT)/components/libraries/usbd/class/cdc \
  142. $(SDK_ROOT)/components/libraries/csense \
  143. $(SDK_ROOT)/components/libraries/balloc \
  144. $(SDK_ROOT)/components/libraries/low_power_pwm \
  145. $(SDK_ROOT)/components/libraries/hardfault \
  146. $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
  147. $(SDK_ROOT)/components/libraries/uart \
  148. $(SDK_ROOT)/components/libraries/hci \
  149. $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
  150. $(SDK_ROOT)/components/libraries/timer \
  151. $(SDK_ROOT)/integration/nrfx \
  152. $(SDK_ROOT)/components/nfc/t4t_parser/tlv \
  153. $(SDK_ROOT)/components/libraries/sortlist \
  154. $(SDK_ROOT)/components/libraries/spi_mngr \
  155. $(SDK_ROOT)/components/libraries/led_softblink \
  156. $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser \
  157. $(SDK_ROOT)/components/libraries/sdcard \
  158. $(SDK_ROOT)/components/nfc/ndef/parser/record \
  159. $(SDK_ROOT)/modules/nrfx/mdk \
  160. $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
  161. $(SDK_ROOT)/components/ble/ble_services/ble_nus \
  162. $(SDK_ROOT)/components/libraries/twi_mngr \
  163. $(SDK_ROOT)/components/ble/ble_services/ble_hids \
  164. $(SDK_ROOT)/components/libraries/strerror \
  165. $(SDK_ROOT)/components/libraries/crc32 \
  166. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_oob_advdata \
  167. $(SDK_ROOT)/components/nfc/t2t_parser \
  168. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_msg \
  169. $(SDK_ROOT)/components/libraries/usbd/class/audio \
  170. $(SDK_ROOT)/components/nfc/t4t_lib \
  171. $(SDK_ROOT)/components/ble/peer_manager \
  172. $(SDK_ROOT)/components/libraries/mem_manager \
  173. $(SDK_ROOT)/components/libraries/ringbuf \
  174. $(SDK_ROOT)/components/ble/ble_services/ble_tps \
  175. $(SDK_ROOT)/components/nfc/ndef/parser/message \
  176. $(SDK_ROOT)/components/ble/ble_services/ble_dis \
  177. $(SDK_ROOT)/components/nfc/ndef/uri \
  178. $(SDK_ROOT)/components/ble/nrf_ble_gatt \
  179. $(SDK_ROOT)/components/ble/nrf_ble_qwr \
  180. $(SDK_ROOT)/components/libraries/gpiote \
  181. $(SDK_ROOT)/components/libraries/button \
  182. $(SDK_ROOT)/modules/nrfx \
  183. $(SDK_ROOT)/components/libraries/twi_sensor \
  184. $(SDK_ROOT)/integration/nrfx/legacy \
  185. $(SDK_ROOT)/components/libraries/usbd \
  186. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ep_oob_rec \
  187. $(SDK_ROOT)/external/segger_rtt \
  188. $(SDK_ROOT)/components/libraries/atomic_fifo \
  189. $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
  190. $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_lib \
  191. $(SDK_ROOT)/components/libraries/crypto \
  192. $(SDK_ROOT)/components/ble/ble_racp \
  193. $(SDK_ROOT)/components/libraries/fds \
  194. $(SDK_ROOT)/components/nfc/ndef/launchapp \
  195. $(SDK_ROOT)/components/softdevice/s122/headers \
  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_PCA10100
  214. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  215. CFLAGS += -DFLOAT_ABI_HARD
  216. CFLAGS += -DNRF52833_XXAA
  217. CFLAGS += -DNRF_SD_BLE_API_VERSION=8
  218. CFLAGS += -DS122
  219. CFLAGS += -DSOFTDEVICE_PRESENT
  220. CFLAGS += -mcpu=cortex-m4
  221. CFLAGS += -mthumb -mabi=aapcs
  222. CFLAGS += -Wall -Werror
  223. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  224. # keep every function in a separate section, this allows linker to discard unused ones
  225. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  226. CFLAGS += -fno-builtin -fshort-enums
  227. # C++ flags common to all targets
  228. CXXFLAGS += $(OPT)
  229. # Assembler flags common to all targets
  230. ASMFLAGS += -g3
  231. ASMFLAGS += -mcpu=cortex-m4
  232. ASMFLAGS += -mthumb -mabi=aapcs
  233. ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  234. ASMFLAGS += -DAPP_TIMER_V2
  235. ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  236. ASMFLAGS += -DBOARD_PCA10100
  237. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  238. ASMFLAGS += -DFLOAT_ABI_HARD
  239. ASMFLAGS += -DNRF52833_XXAA
  240. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=8
  241. ASMFLAGS += -DS122
  242. ASMFLAGS += -DSOFTDEVICE_PRESENT
  243. # Linker flags
  244. LDFLAGS += $(OPT)
  245. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  246. LDFLAGS += -mcpu=cortex-m4
  247. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  248. # let linker dump unused sections
  249. LDFLAGS += -Wl,--gc-sections
  250. # use newlib in nano version
  251. LDFLAGS += --specs=nano.specs
  252. nrf52833_xxaa: CFLAGS += -D__HEAP_SIZE=2048
  253. nrf52833_xxaa: CFLAGS += -D__STACK_SIZE=2048
  254. nrf52833_xxaa: ASMFLAGS += -D__HEAP_SIZE=2048
  255. nrf52833_xxaa: ASMFLAGS += -D__STACK_SIZE=2048
  256. # Add standard libraries at the very end of the linker input, after all objects
  257. # that may need symbols provided by these libraries.
  258. LIB_FILES += -lc -lnosys -lm
  259. .PHONY: default help
  260. # Default target - first one defined
  261. default: nrf52833_xxaa
  262. # Print all targets that can be built
  263. help:
  264. @echo following targets are available:
  265. @echo nrf52833_xxaa
  266. @echo flash_softdevice
  267. @echo sdk_config - starting external tool for editing sdk_config.h
  268. @echo flash - flashing binary
  269. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  270. include $(TEMPLATE_PATH)/Makefile.common
  271. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  272. .PHONY: flash flash_softdevice erase
  273. # Flash the program
  274. flash: default
  275. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52833_xxaa.hex
  276. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52833_xxaa.hex --sectorerase
  277. nrfjprog -f nrf52 --reset
  278. # Flash softdevice
  279. flash_softdevice:
  280. @echo Flashing: s122_nrf52_8.0.0_softdevice.hex
  281. nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s122/hex/s122_nrf52_8.0.0_softdevice.hex --sectorerase
  282. nrfjprog -f nrf52 --reset
  283. erase:
  284. nrfjprog -f nrf52 --eraseall
  285. SDK_CONFIG_FILE := ../config/sdk_config.h
  286. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  287. sdk_config:
  288. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)