Makefile 11 KB

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