Makefile 11 KB

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