Makefile 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. PROJECT_NAME := generic_nrf52811_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_nrf52811.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)/modules/nrfx/mdk/system_nrf52811.c \
  34. $(SDK_ROOT)/external/utf_converter/utf.c \
  35. $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
  36. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
  37. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
  38. # Include folders common to all targets
  39. INC_FOLDERS += \
  40. $(SDK_ROOT)/components/libraries/sdcard \
  41. $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \
  42. $(SDK_ROOT)/components/ble/ble_services/ble_tps \
  43. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  44. $(SDK_ROOT)/components/libraries/crc32 \
  45. $(SDK_ROOT)/components/libraries/csense_drv \
  46. $(SDK_ROOT)/components/libraries/fstorage \
  47. $(SDK_ROOT)/components/libraries/cli \
  48. $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
  49. $(SDK_ROOT)/components/libraries/atomic_fifo \
  50. $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
  51. $(SDK_ROOT)/components/softdevice/s112/headers/nrf52 \
  52. $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
  53. $(SDK_ROOT)/components/libraries/scheduler \
  54. $(SDK_ROOT)/components/libraries/memobj \
  55. $(SDK_ROOT)/components/ble/ble_services/ble_nus \
  56. $(SDK_ROOT)/components/libraries/hci \
  57. $(SDK_ROOT)/components/libraries/queue \
  58. $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
  59. $(SDK_ROOT)/components/libraries/mem_manager \
  60. $(SDK_ROOT)/components/libraries/usbd/class/hid \
  61. $(SDK_ROOT)/components/libraries/mutex \
  62. $(SDK_ROOT)/components/ble/peer_manager \
  63. $(SDK_ROOT)/components/ble/ble_services/ble_bas \
  64. $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
  65. $(SDK_ROOT)/components/softdevice/common \
  66. $(SDK_ROOT)/components/libraries/mpu \
  67. $(SDK_ROOT)/components/libraries/twi_mngr \
  68. $(SDK_ROOT)/components/libraries/usbd/class/audio \
  69. $(SDK_ROOT)/components/libraries/experimental_task_manager \
  70. $(SDK_ROOT)/components/libraries/stack_guard \
  71. $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
  72. $(SDK_ROOT)/components/libraries/util \
  73. $(SDK_ROOT)/components/libraries/timer \
  74. $(SDK_ROOT)/integration/nrfx \
  75. $(SDK_ROOT)/components/libraries/spi_mngr \
  76. $(SDK_ROOT)/components/libraries/usbd/class/cdc \
  77. $(SDK_ROOT)/components/libraries/gfx \
  78. $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
  79. $(SDK_ROOT)/components/ble/ble_dtm \
  80. $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
  81. $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
  82. $(SDK_ROOT)/modules/nrfx/drivers/include \
  83. $(SDK_ROOT)/components/toolchain/cmsis/include \
  84. $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
  85. $(SDK_ROOT)/components/libraries/balloc \
  86. $(SDK_ROOT)/components/libraries/sortlist \
  87. $(SDK_ROOT)/components/ble/nrf_ble_qwr \
  88. $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
  89. $(SDK_ROOT)/components/libraries/pwm \
  90. $(SDK_ROOT)/components/libraries/ringbuf \
  91. $(SDK_ROOT)/components/libraries/slip \
  92. $(SDK_ROOT)/components/ble/ble_services/ble_hids \
  93. $(SDK_ROOT)/components/ble/ble_advertising \
  94. ../config \
  95. $(SDK_ROOT)/modules/nrfx/hal \
  96. $(SDK_ROOT)/components/libraries/pwr_mgmt \
  97. $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
  98. $(SDK_ROOT)/modules/nrfx \
  99. $(SDK_ROOT)/components/libraries/csense \
  100. $(SDK_ROOT)/components/libraries/fds \
  101. $(SDK_ROOT)/components/libraries/delay \
  102. $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
  103. $(SDK_ROOT)/integration/nrfx/legacy \
  104. $(SDK_ROOT)/components/libraries/usbd \
  105. $(SDK_ROOT)/components/libraries/log \
  106. $(SDK_ROOT)/components/ble/common \
  107. $(SDK_ROOT)/components/libraries/usbd/class/msc \
  108. $(SDK_ROOT)/external/fprintf \
  109. $(SDK_ROOT)/components/libraries/crypto \
  110. $(SDK_ROOT)/components \
  111. $(SDK_ROOT)/external/utf_converter \
  112. $(SDK_ROOT)/components/libraries/log/src \
  113. $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
  114. $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
  115. $(SDK_ROOT)/components/libraries/ecc \
  116. $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
  117. $(SDK_ROOT)/components/ble/ble_services/ble_dis \
  118. $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
  119. $(SDK_ROOT)/components/libraries/crc16 \
  120. $(SDK_ROOT)/components/libraries/low_power_pwm \
  121. $(SDK_ROOT)/components/softdevice/s112/headers \
  122. $(SDK_ROOT)/components/libraries/led_softblink \
  123. $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
  124. $(SDK_ROOT)/modules/nrfx/mdk \
  125. $(SDK_ROOT)/components/libraries/atomic \
  126. $(SDK_ROOT)/components/ble/ble_services/ble_gls \
  127. $(SDK_ROOT)/components/ble/ble_racp \
  128. $(SDK_ROOT)/components/ble/ble_services/ble_hts \
  129. $(SDK_ROOT)/components/ble/ble_services/ble_ias \
  130. $(SDK_ROOT)/components/libraries/svc \
  131. $(SDK_ROOT)/components/libraries/twi_sensor \
  132. $(SDK_ROOT)/components/libraries/button \
  133. $(SDK_ROOT)/components/libraries/strerror \
  134. $(SDK_ROOT)/components/ble/ble_services/ble_lls \
  135. $(SDK_ROOT)/components/libraries/gpiote \
  136. $(SDK_ROOT)/components/libraries/hardfault \
  137. # Libraries common to all targets
  138. LIB_FILES += \
  139. # Optimization flags
  140. OPT = -O3 -g3
  141. # Uncomment the line below to enable link time optimization
  142. #OPT += -flto
  143. # C flags common to all targets
  144. CFLAGS += $(OPT)
  145. CFLAGS += -DAPP_TIMER_V2
  146. CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  147. CFLAGS += -DFLOAT_ABI_SOFT
  148. CFLAGS += -DNRF52811_XXAA
  149. CFLAGS += -DNRF_SD_BLE_API_VERSION=7
  150. CFLAGS += -DS112
  151. CFLAGS += -DSOFTDEVICE_PRESENT
  152. CFLAGS += -mcpu=cortex-m4
  153. CFLAGS += -mthumb -mabi=aapcs
  154. CFLAGS += -Wall -Werror
  155. CFLAGS += -mfloat-abi=soft
  156. # keep every function in a separate section, this allows linker to discard unused ones
  157. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  158. CFLAGS += -fno-builtin -fshort-enums
  159. # C++ flags common to all targets
  160. CXXFLAGS += $(OPT)
  161. # Assembler flags common to all targets
  162. ASMFLAGS += -g3
  163. ASMFLAGS += -mcpu=cortex-m4
  164. ASMFLAGS += -mthumb -mabi=aapcs
  165. ASMFLAGS += -mfloat-abi=soft
  166. ASMFLAGS += -DAPP_TIMER_V2
  167. ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
  168. ASMFLAGS += -DFLOAT_ABI_SOFT
  169. ASMFLAGS += -DNRF52811_XXAA
  170. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7
  171. ASMFLAGS += -DS112
  172. ASMFLAGS += -DSOFTDEVICE_PRESENT
  173. # Linker flags
  174. LDFLAGS += $(OPT)
  175. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  176. LDFLAGS += -mcpu=cortex-m4
  177. # let linker dump unused sections
  178. LDFLAGS += -Wl,--gc-sections
  179. # use newlib in nano version
  180. LDFLAGS += --specs=nano.specs
  181. toxophilite: CFLAGS += -D__HEAP_SIZE=4096
  182. toxophilite: CFLAGS += -D__STACK_SIZE=4096
  183. toxophilite: ASMFLAGS += -D__HEAP_SIZE=4096
  184. toxophilite: ASMFLAGS += -D__STACK_SIZE=4096
  185. # Add standard libraries at the very end of the linker input, after all objects
  186. # that may need symbols provided by these libraries.
  187. LIB_FILES += -lc -lnosys -lm
  188. .PHONY: default help
  189. # Default target - first one defined
  190. default: toxophilite
  191. # Print all targets that can be built
  192. help:
  193. @echo following targets are available:
  194. @echo toxophilite
  195. @echo sdk_config - starting external tool for editing sdk_config.h
  196. @echo flash - flashing binary
  197. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  198. include $(TEMPLATE_PATH)/Makefile.common
  199. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  200. .PHONY: flash erase
  201. # Flash the program
  202. flash: default
  203. @echo Flashing: $(OUTPUT_DIRECTORY)/toxophilite.hex
  204. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/toxophilite.hex --sectorerase
  205. nrfjprog -f nrf52 --reset
  206. erase:
  207. nrfjprog -f nrf52 --eraseall
  208. SDK_CONFIG_FILE := ../config/sdk_config.h
  209. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  210. sdk_config:
  211. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)