Makefile 8.7 KB

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