Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. PROJECT_NAME := ble_app_uart_c_pca10100e_s140
  2. TARGETS := nrf52820_xxaa
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../../..
  5. PROJ_DIR := ../../..
  6. $(OUTPUT_DIRECTORY)/nrf52820_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_nrf52820.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_nrf52820.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/ble/ble_services/ble_ancs_c \
  71. $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
  72. $(SDK_ROOT)/components/libraries/pwm \
  73. $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
  74. $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
  75. $(SDK_ROOT)/components/libraries/usbd/class/msc \
  76. $(SDK_ROOT)/components/libraries/usbd/class/hid \
  77. $(SDK_ROOT)/modules/nrfx/hal \
  78. $(SDK_ROOT)/components/libraries/log \
  79. $(SDK_ROOT)/components/ble/ble_services/ble_gls \
  80. $(SDK_ROOT)/components/libraries/fstorage \
  81. $(SDK_ROOT)/components/libraries/mutex \
  82. $(SDK_ROOT)/components/libraries/gfx \
  83. $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \
  84. $(SDK_ROOT)/components/libraries/fifo \
  85. $(SDK_ROOT)/components/boards \
  86. $(SDK_ROOT)/components/ble/ble_advertising \
  87. $(SDK_ROOT)/external/utf_converter \
  88. $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
  89. $(SDK_ROOT)/modules/nrfx/drivers/include \
  90. $(SDK_ROOT)/components/libraries/experimental_task_manager \
  91. $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
  92. $(SDK_ROOT)/components/libraries/queue \
  93. $(SDK_ROOT)/components/libraries/pwr_mgmt \
  94. $(SDK_ROOT)/components/ble/ble_dtm \
  95. $(SDK_ROOT)/components/toolchain/cmsis/include \
  96. $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
  97. $(SDK_ROOT)/components/ble/common \
  98. $(SDK_ROOT)/components/ble/ble_services/ble_lls \
  99. $(SDK_ROOT)/components/libraries/bsp \
  100. $(SDK_ROOT)/components/ble/ble_db_discovery \
  101. $(SDK_ROOT)/components/ble/ble_services/ble_bas \
  102. $(SDK_ROOT)/components/libraries/mpu \
  103. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  104. $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
  105. $(SDK_ROOT)/components/libraries/slip \
  106. $(SDK_ROOT)/components/libraries/delay \
  107. $(SDK_ROOT)/components/libraries/csense_drv \
  108. $(SDK_ROOT)/components/libraries/memobj \
  109. $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
  110. $(SDK_ROOT)/components/softdevice/common \
  111. $(SDK_ROOT)/components/ble/ble_services/ble_ias \
  112. $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
  113. $(SDK_ROOT)/components/libraries/ecc \
  114. $(SDK_ROOT)/components/ble/nrf_ble_scan \
  115. $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
  116. $(SDK_ROOT)/external/fprintf \
  117. $(SDK_ROOT)/components/libraries/svc \
  118. $(SDK_ROOT)/components/libraries/atomic \
  119. $(SDK_ROOT)/components \
  120. $(SDK_ROOT)/components/libraries/scheduler \
  121. $(SDK_ROOT)/components/libraries/cli \
  122. $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
  123. $(SDK_ROOT)/components/ble/ble_services/ble_hts \
  124. $(SDK_ROOT)/components/libraries/crc16 \
  125. $(SDK_ROOT)/components/libraries/util \
  126. ../config \
  127. $(SDK_ROOT)/components/libraries/usbd/class/cdc \
  128. $(SDK_ROOT)/components/libraries/csense \
  129. $(SDK_ROOT)/components/libraries/balloc \
  130. $(SDK_ROOT)/components/libraries/low_power_pwm \
  131. $(SDK_ROOT)/components/libraries/hardfault \
  132. $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
  133. $(SDK_ROOT)/components/libraries/uart \
  134. $(SDK_ROOT)/components/libraries/hci \
  135. $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
  136. $(SDK_ROOT)/components/libraries/timer \
  137. $(SDK_ROOT)/components/softdevice/s140/headers \
  138. $(SDK_ROOT)/integration/nrfx \
  139. $(SDK_ROOT)/components/libraries/sortlist \
  140. $(SDK_ROOT)/components/libraries/spi_mngr \
  141. $(SDK_ROOT)/components/libraries/led_softblink \
  142. $(SDK_ROOT)/components/libraries/sdcard \
  143. $(SDK_ROOT)/modules/nrfx/mdk \
  144. $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
  145. $(SDK_ROOT)/components/ble/ble_services/ble_nus \
  146. $(SDK_ROOT)/components/libraries/twi_mngr \
  147. $(SDK_ROOT)/components/ble/ble_services/ble_hids \
  148. $(SDK_ROOT)/components/libraries/strerror \
  149. $(SDK_ROOT)/components/libraries/crc32 \
  150. $(SDK_ROOT)/components/libraries/usbd/class/audio \
  151. $(SDK_ROOT)/components/softdevice/s140/headers/nrf52 \
  152. $(SDK_ROOT)/components/ble/peer_manager \
  153. $(SDK_ROOT)/components/libraries/mem_manager \
  154. $(SDK_ROOT)/components/libraries/ringbuf \
  155. $(SDK_ROOT)/components/ble/ble_services/ble_tps \
  156. $(SDK_ROOT)/components/ble/ble_services/ble_dis \
  157. $(SDK_ROOT)/components/ble/nrf_ble_gatt \
  158. $(SDK_ROOT)/components/ble/nrf_ble_qwr \
  159. $(SDK_ROOT)/components/libraries/gpiote \
  160. $(SDK_ROOT)/components/libraries/button \
  161. $(SDK_ROOT)/modules/nrfx \
  162. $(SDK_ROOT)/components/libraries/twi_sensor \
  163. $(SDK_ROOT)/integration/nrfx/legacy \
  164. $(SDK_ROOT)/components/libraries/usbd \
  165. $(SDK_ROOT)/external/segger_rtt \
  166. $(SDK_ROOT)/components/libraries/atomic_fifo \
  167. $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
  168. $(SDK_ROOT)/components/libraries/crypto \
  169. $(SDK_ROOT)/components/ble/ble_racp \
  170. $(SDK_ROOT)/components/libraries/fds \
  171. $(SDK_ROOT)/components/ble/nrf_ble_gq \
  172. $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
  173. $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
  174. $(SDK_ROOT)/components/libraries/stack_guard \
  175. $(SDK_ROOT)/components/libraries/log/src \
  176. # Libraries common to all targets
  177. LIB_FILES += \
  178. # Optimization flags
  179. OPT = -O3 -g3
  180. # Uncomment the line below to enable link time optimization
  181. #OPT += -flto
  182. # C flags common to all targets
  183. CFLAGS += $(OPT)
  184. CFLAGS += -DAPP_TIMER_V2
  185. CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  186. CFLAGS += -DBOARD_PCA10100
  187. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  188. CFLAGS += -DDEVELOP_IN_NRF52833
  189. CFLAGS += -DFLOAT_ABI_SOFT
  190. CFLAGS += -DNRF52820_XXAA
  191. CFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=3
  192. CFLAGS += -DNRF_SD_BLE_API_VERSION=7
  193. CFLAGS += -DS140
  194. CFLAGS += -DSOFTDEVICE_PRESENT
  195. CFLAGS += -mcpu=cortex-m4
  196. CFLAGS += -mthumb -mabi=aapcs
  197. CFLAGS += -Wall -Werror
  198. CFLAGS += -mfloat-abi=soft
  199. # keep every function in a separate section, this allows linker to discard unused ones
  200. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  201. CFLAGS += -fno-builtin -fshort-enums
  202. # C++ flags common to all targets
  203. CXXFLAGS += $(OPT)
  204. # Assembler flags common to all targets
  205. ASMFLAGS += -g3
  206. ASMFLAGS += -mcpu=cortex-m4
  207. ASMFLAGS += -mthumb -mabi=aapcs
  208. ASMFLAGS += -mfloat-abi=soft
  209. ASMFLAGS += -DAPP_TIMER_V2
  210. ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  211. ASMFLAGS += -DBOARD_PCA10100
  212. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  213. ASMFLAGS += -DDEVELOP_IN_NRF52833
  214. ASMFLAGS += -DFLOAT_ABI_SOFT
  215. ASMFLAGS += -DNRF52820_XXAA
  216. ASMFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=3
  217. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7
  218. ASMFLAGS += -DS140
  219. ASMFLAGS += -DSOFTDEVICE_PRESENT
  220. # Linker flags
  221. LDFLAGS += $(OPT)
  222. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  223. LDFLAGS += -mcpu=cortex-m4
  224. # let linker dump unused sections
  225. LDFLAGS += -Wl,--gc-sections
  226. # use newlib in nano version
  227. LDFLAGS += --specs=nano.specs
  228. nrf52820_xxaa: CFLAGS += -D__HEAP_SIZE=2048
  229. nrf52820_xxaa: CFLAGS += -D__STACK_SIZE=2048
  230. nrf52820_xxaa: ASMFLAGS += -D__HEAP_SIZE=2048
  231. nrf52820_xxaa: ASMFLAGS += -D__STACK_SIZE=2048
  232. # Add standard libraries at the very end of the linker input, after all objects
  233. # that may need symbols provided by these libraries.
  234. LIB_FILES += -lc -lnosys -lm
  235. .PHONY: default help
  236. # Default target - first one defined
  237. default: nrf52820_xxaa
  238. # Print all targets that can be built
  239. help:
  240. @echo following targets are available:
  241. @echo nrf52820_xxaa
  242. @echo flash_softdevice
  243. @echo sdk_config - starting external tool for editing sdk_config.h
  244. @echo flash - flashing binary
  245. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  246. include $(TEMPLATE_PATH)/Makefile.common
  247. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  248. .PHONY: flash flash_softdevice erase
  249. # Flash the program
  250. flash: default
  251. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52820_xxaa.hex
  252. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52820_xxaa.hex --sectorerase
  253. nrfjprog -f nrf52 --reset
  254. # Flash softdevice
  255. flash_softdevice:
  256. @echo Flashing: s140_nrf52_7.0.1_softdevice.hex
  257. nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s140/hex/s140_nrf52_7.0.1_softdevice.hex --sectorerase
  258. nrfjprog -f nrf52 --reset
  259. erase:
  260. nrfjprog -f nrf52 --eraseall
  261. SDK_CONFIG_FILE := ../config/sdk_config.h
  262. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  263. sdk_config:
  264. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)