Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. PROJECT_NAME := secure_bootloader_ble_s132_pca10040_debug
  2. TARGETS := nrf52832_xxaa_s132
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../..
  5. PROJ_DIR := ../..
  6. $(OUTPUT_DIRECTORY)/nrf52832_xxaa_s132.out: \
  7. LINKER_SCRIPT := secure_bootloader_gcc_nrf52.ld
  8. # Source files common to all targets
  9. SRC_FILES += \
  10. $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
  11. $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52.c \
  12. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
  13. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
  14. $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
  15. $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
  16. $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
  17. $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
  18. $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \
  19. $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  20. $(SDK_ROOT)/components/libraries/crc32/crc32.c \
  21. $(SDK_ROOT)/components/libraries/mem_manager/mem_manager.c \
  22. $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
  23. $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \
  24. $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
  25. $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
  26. $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
  27. $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
  28. $(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage.c \
  29. $(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_nvmc.c \
  30. $(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_sd.c \
  31. $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
  32. $(SDK_ROOT)/components/libraries/queue/nrf_queue.c \
  33. $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
  34. $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
  35. $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
  36. $(SDK_ROOT)/components/libraries/sha256/sha256.c \
  37. $(SDK_ROOT)/modules/nrfx/hal/nrf_nvmc.c \
  38. $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \
  39. $(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c \
  40. $(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c \
  41. $(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c \
  42. $(SDK_ROOT)/components/boards/boards.c \
  43. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_svci.c \
  44. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c \
  45. $(SDK_ROOT)/components/libraries/svc/nrf_svc_handler.c \
  46. $(SDK_ROOT)/components/libraries/crypto/nrf_crypto_ecc.c \
  47. $(SDK_ROOT)/components/libraries/crypto/nrf_crypto_ecdsa.c \
  48. $(SDK_ROOT)/components/libraries/crypto/nrf_crypto_hash.c \
  49. $(SDK_ROOT)/components/libraries/crypto/nrf_crypto_init.c \
  50. $(SDK_ROOT)/components/libraries/crypto/nrf_crypto_shared.c \
  51. $(PROJ_DIR)/../dfu_public_key.c \
  52. $(PROJ_DIR)/main.c \
  53. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
  54. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
  55. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
  56. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader.c \
  57. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_app_start.c \
  58. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_app_start_final.c \
  59. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_dfu_timers.c \
  60. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_fw_activation.c \
  61. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_info.c \
  62. $(SDK_ROOT)/components/libraries/bootloader/nrf_bootloader_wdt.c \
  63. $(SDK_ROOT)/external/nano-pb/pb_common.c \
  64. $(SDK_ROOT)/external/nano-pb/pb_decode.c \
  65. $(SDK_ROOT)/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c \
  66. $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
  67. $(SDK_ROOT)/components/libraries/bootloader/dfu/dfu-cc.pb.c \
  68. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu.c \
  69. $(SDK_ROOT)/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c \
  70. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_flash.c \
  71. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c \
  72. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_mbr.c \
  73. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c \
  74. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_settings.c \
  75. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c \
  76. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_transport.c \
  77. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_utils.c \
  78. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_validation.c \
  79. $(SDK_ROOT)/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c \
  80. $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
  81. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
  82. $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
  83. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c \
  84. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c \
  85. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c \
  86. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c \
  87. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c \
  88. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_hash.c \
  89. $(SDK_ROOT)/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c \
  90. # Include folders common to all targets
  91. INC_FOLDERS += \
  92. $(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc \
  93. $(SDK_ROOT)/components/softdevice/s132/headers \
  94. $(SDK_ROOT)/components/libraries/memobj \
  95. $(SDK_ROOT)/components/libraries/sha256 \
  96. $(SDK_ROOT)/components/libraries/crc32 \
  97. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  98. $(SDK_ROOT)/components/libraries/mem_manager \
  99. $(SDK_ROOT)/components/libraries/fstorage \
  100. $(SDK_ROOT)/components/libraries/util \
  101. $(SDK_ROOT)/modules/nrfx \
  102. $(SDK_ROOT)/external/nrf_oberon/include \
  103. $(SDK_ROOT)/components/libraries/crypto/backend/oberon \
  104. $(SDK_ROOT)/components/libraries/crypto/backend/cifra \
  105. $(SDK_ROOT)/components/libraries/atomic \
  106. $(SDK_ROOT)/integration/nrfx \
  107. $(SDK_ROOT)/components/libraries/crypto/backend/cc310_bl \
  108. $(SDK_ROOT)/components/softdevice/s132/headers/nrf52 \
  109. $(SDK_ROOT)/components/libraries/log/src \
  110. $(SDK_ROOT)/components/libraries/bootloader/dfu \
  111. $(SDK_ROOT)/components/ble/common \
  112. $(SDK_ROOT)/components/libraries/delay \
  113. $(SDK_ROOT)/components/libraries/svc \
  114. $(SDK_ROOT)/components/libraries/stack_info \
  115. $(SDK_ROOT)/components/libraries/crypto/backend/nrf_hw \
  116. $(SDK_ROOT)/components/libraries/log \
  117. $(SDK_ROOT)/external/nrf_oberon \
  118. $(SDK_ROOT)/components/libraries/strerror \
  119. $(SDK_ROOT)/components/libraries/crypto/backend/mbedtls \
  120. $(SDK_ROOT)/components/boards \
  121. $(SDK_ROOT)/components/libraries/crypto/backend/cc310 \
  122. $(SDK_ROOT)/components/libraries/bootloader \
  123. $(SDK_ROOT)/external/fprintf \
  124. $(SDK_ROOT)/components/libraries/crypto \
  125. ../config \
  126. $(SDK_ROOT)/components/libraries/crypto/backend/optiga \
  127. $(SDK_ROOT)/components/libraries/scheduler \
  128. $(SDK_ROOT)/external/segger_rtt \
  129. $(SDK_ROOT)/modules/nrfx/hal \
  130. $(SDK_ROOT)/components/toolchain/cmsis/include \
  131. $(SDK_ROOT)/components/libraries/balloc \
  132. $(SDK_ROOT)/components/libraries/atomic_fifo \
  133. $(SDK_ROOT)/external/micro-ecc/micro-ecc \
  134. $(PROJ_DIR) \
  135. $(SDK_ROOT)/components/libraries/crypto/backend/nrf_sw \
  136. $(SDK_ROOT)/modules/nrfx/mdk \
  137. $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \
  138. $(SDK_ROOT)/components/softdevice/common \
  139. $(SDK_ROOT)/external/nano-pb \
  140. $(SDK_ROOT)/components/libraries/queue \
  141. $(SDK_ROOT)/components/libraries/ringbuf \
  142. # Libraries common to all targets
  143. LIB_FILES += \
  144. $(SDK_ROOT)/external/nrf_oberon/lib/cortex-m4/hard-float/liboberon_3.0.5.a \
  145. $(SDK_ROOT)/external/micro-ecc/nrf52hf_armgcc/armgcc/micro_ecc_lib_nrf52.a \
  146. # Optimization flags
  147. OPT = -Os -g3
  148. # Uncomment the line below to enable link time optimization
  149. #OPT += -flto
  150. # C flags common to all targets
  151. CFLAGS += $(OPT)
  152. CFLAGS += -DBLE_STACK_SUPPORT_REQD
  153. CFLAGS += -DBOARD_PCA10040
  154. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  155. CFLAGS += -DDEBUG_NRF
  156. CFLAGS += -DFLOAT_ABI_HARD
  157. CFLAGS += -DNRF52
  158. CFLAGS += -DNRF52832_XXAA
  159. CFLAGS += -DNRF52_PAN_74
  160. CFLAGS += -DNRF_DFU_DEBUG_VERSION
  161. CFLAGS += -DNRF_DFU_SETTINGS_VERSION=2
  162. CFLAGS += -DNRF_DFU_SVCI_ENABLED
  163. CFLAGS += -DNRF_SD_BLE_API_VERSION=7
  164. CFLAGS += -DS132
  165. CFLAGS += -DSOFTDEVICE_PRESENT
  166. CFLAGS += -DSVC_INTERFACE_CALL_AS_NORMAL_FUNCTION
  167. CFLAGS += -DuECC_ENABLE_VLI_API=0
  168. CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3
  169. CFLAGS += -DuECC_SQUARE_FUNC=0
  170. CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0
  171. CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1
  172. CFLAGS += -mcpu=cortex-m4
  173. CFLAGS += -mthumb -mabi=aapcs
  174. CFLAGS += -Wall -Werror
  175. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  176. # keep every function in a separate section, this allows linker to discard unused ones
  177. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  178. CFLAGS += -fno-builtin -fshort-enums
  179. # C++ flags common to all targets
  180. CXXFLAGS += $(OPT)
  181. # Assembler flags common to all targets
  182. ASMFLAGS += -g3
  183. ASMFLAGS += -mcpu=cortex-m4
  184. ASMFLAGS += -mthumb -mabi=aapcs
  185. ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  186. ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
  187. ASMFLAGS += -DBOARD_PCA10040
  188. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  189. ASMFLAGS += -DDEBUG_NRF
  190. ASMFLAGS += -DFLOAT_ABI_HARD
  191. ASMFLAGS += -DNRF52
  192. ASMFLAGS += -DNRF52832_XXAA
  193. ASMFLAGS += -DNRF52_PAN_74
  194. ASMFLAGS += -DNRF_DFU_DEBUG_VERSION
  195. ASMFLAGS += -DNRF_DFU_SETTINGS_VERSION=2
  196. ASMFLAGS += -DNRF_DFU_SVCI_ENABLED
  197. ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7
  198. ASMFLAGS += -DS132
  199. ASMFLAGS += -DSOFTDEVICE_PRESENT
  200. ASMFLAGS += -DSVC_INTERFACE_CALL_AS_NORMAL_FUNCTION
  201. ASMFLAGS += -DuECC_ENABLE_VLI_API=0
  202. ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3
  203. ASMFLAGS += -DuECC_SQUARE_FUNC=0
  204. ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0
  205. ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1
  206. # Linker flags
  207. LDFLAGS += $(OPT)
  208. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  209. LDFLAGS += -mcpu=cortex-m4
  210. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  211. # let linker dump unused sections
  212. LDFLAGS += -Wl,--gc-sections
  213. # use newlib in nano version
  214. LDFLAGS += --specs=nano.specs
  215. nrf52832_xxaa_s132: CFLAGS += -D__HEAP_SIZE=0
  216. nrf52832_xxaa_s132: ASMFLAGS += -D__HEAP_SIZE=0
  217. # Add standard libraries at the very end of the linker input, after all objects
  218. # that may need symbols provided by these libraries.
  219. LIB_FILES += -lc -lnosys -lm
  220. .PHONY: default help
  221. # Default target - first one defined
  222. default: nrf52832_xxaa_s132
  223. # Print all targets that can be built
  224. help:
  225. @echo following targets are available:
  226. @echo nrf52832_xxaa_s132
  227. @echo flash_softdevice
  228. @echo sdk_config - starting external tool for editing sdk_config.h
  229. @echo flash - flashing binary
  230. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  231. include $(TEMPLATE_PATH)/Makefile.common
  232. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  233. .PHONY: flash flash_softdevice erase
  234. # Flash the program
  235. flash: default
  236. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52832_xxaa_s132.hex
  237. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52832_xxaa_s132.hex --sectorerase
  238. nrfjprog -f nrf52 --reset
  239. # Flash softdevice
  240. flash_softdevice:
  241. @echo Flashing: s132_nrf52_7.0.1_softdevice.hex
  242. nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase
  243. nrfjprog -f nrf52 --reset
  244. erase:
  245. nrfjprog -f nrf52 --eraseall
  246. SDK_CONFIG_FILE := ../config/sdk_config.h
  247. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  248. sdk_config:
  249. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)