Makefile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. PROJECT_NAME := esb_prx_pca10100e
  2. TARGETS := nrf52820_xxaa
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../../..
  5. PROJ_DIR := ../../..
  6. $(OUTPUT_DIRECTORY)/nrf52820_xxaa.out: \
  7. LINKER_SCRIPT := esb_prx_gcc_nrf52.ld
  8. # Source files common to all targets
  9. SRC_FILES += \
  10. $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52820.S \
  11. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
  12. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
  13. $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.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/boards/boards.c \
  18. $(SDK_ROOT)/components/libraries/util/app_error.c \
  19. $(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
  20. $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
  21. $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  22. $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
  23. $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
  24. $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
  25. $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
  26. $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
  27. $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
  28. $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
  29. $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
  30. $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
  31. $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \
  32. $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
  33. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
  34. $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
  35. $(PROJ_DIR)/main.c \
  36. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
  37. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
  38. $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
  39. $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52820.c \
  40. $(SDK_ROOT)/components/proprietary_rf/esb/nrf_esb.c \
  41. # Include folders common to all targets
  42. INC_FOLDERS += \
  43. $(SDK_ROOT)/components \
  44. $(SDK_ROOT)/modules/nrfx/mdk \
  45. $(PROJ_DIR) \
  46. $(SDK_ROOT)/components/libraries/strerror \
  47. $(SDK_ROOT)/components/toolchain/cmsis/include \
  48. $(SDK_ROOT)/components/libraries/util \
  49. ../config \
  50. $(SDK_ROOT)/components/libraries/balloc \
  51. $(SDK_ROOT)/components/libraries/ringbuf \
  52. $(SDK_ROOT)/components/proprietary_rf/esb \
  53. $(SDK_ROOT)/modules/nrfx/hal \
  54. $(SDK_ROOT)/components/libraries/bsp \
  55. $(SDK_ROOT)/components/libraries/log \
  56. $(SDK_ROOT)/modules/nrfx \
  57. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  58. $(SDK_ROOT)/integration/nrfx/legacy \
  59. $(SDK_ROOT)/components/libraries/delay \
  60. $(SDK_ROOT)/integration/nrfx \
  61. $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
  62. $(SDK_ROOT)/external/segger_rtt \
  63. $(SDK_ROOT)/components/boards \
  64. $(SDK_ROOT)/components/libraries/memobj \
  65. $(SDK_ROOT)/modules/nrfx/drivers/include \
  66. $(SDK_ROOT)/components/libraries/log/src \
  67. $(SDK_ROOT)/external/fprintf \
  68. $(SDK_ROOT)/components/libraries/atomic \
  69. # Libraries common to all targets
  70. LIB_FILES += \
  71. # Optimization flags
  72. OPT = -O3 -g3
  73. # Uncomment the line below to enable link time optimization
  74. #OPT += -flto
  75. # C flags common to all targets
  76. CFLAGS += $(OPT)
  77. CFLAGS += -DBOARD_PCA10100
  78. CFLAGS += -DBSP_DEFINES_ONLY
  79. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  80. CFLAGS += -DDEVELOP_IN_NRF52833
  81. CFLAGS += -DESB_PRESENT
  82. CFLAGS += -DFLOAT_ABI_SOFT
  83. CFLAGS += -DNRF52820_XXAA
  84. CFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=3
  85. CFLAGS += -mcpu=cortex-m4
  86. CFLAGS += -mthumb -mabi=aapcs
  87. CFLAGS += -Wall -Werror
  88. CFLAGS += -mfloat-abi=soft
  89. # keep every function in a separate section, this allows linker to discard unused ones
  90. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  91. CFLAGS += -fno-builtin -fshort-enums
  92. # C++ flags common to all targets
  93. CXXFLAGS += $(OPT)
  94. # Assembler flags common to all targets
  95. ASMFLAGS += -g3
  96. ASMFLAGS += -mcpu=cortex-m4
  97. ASMFLAGS += -mthumb -mabi=aapcs
  98. ASMFLAGS += -mfloat-abi=soft
  99. ASMFLAGS += -DBOARD_PCA10100
  100. ASMFLAGS += -DBSP_DEFINES_ONLY
  101. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  102. ASMFLAGS += -DDEVELOP_IN_NRF52833
  103. ASMFLAGS += -DESB_PRESENT
  104. ASMFLAGS += -DFLOAT_ABI_SOFT
  105. ASMFLAGS += -DNRF52820_XXAA
  106. ASMFLAGS += -DNRFX_COREDEP_DELAY_US_LOOP_CYCLES=3
  107. # Linker flags
  108. LDFLAGS += $(OPT)
  109. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  110. LDFLAGS += -mcpu=cortex-m4
  111. # let linker dump unused sections
  112. LDFLAGS += -Wl,--gc-sections
  113. # use newlib in nano version
  114. LDFLAGS += --specs=nano.specs
  115. nrf52820_xxaa: CFLAGS += -D__HEAP_SIZE=4096
  116. nrf52820_xxaa: CFLAGS += -D__STACK_SIZE=4096
  117. nrf52820_xxaa: ASMFLAGS += -D__HEAP_SIZE=4096
  118. nrf52820_xxaa: ASMFLAGS += -D__STACK_SIZE=4096
  119. # Add standard libraries at the very end of the linker input, after all objects
  120. # that may need symbols provided by these libraries.
  121. LIB_FILES += -lc -lnosys -lm
  122. .PHONY: default help
  123. # Default target - first one defined
  124. default: nrf52820_xxaa
  125. # Print all targets that can be built
  126. help:
  127. @echo following targets are available:
  128. @echo nrf52820_xxaa
  129. @echo sdk_config - starting external tool for editing sdk_config.h
  130. @echo flash - flashing binary
  131. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  132. include $(TEMPLATE_PATH)/Makefile.common
  133. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  134. .PHONY: flash erase
  135. # Flash the program
  136. flash: default
  137. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52820_xxaa.hex
  138. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52820_xxaa.hex --sectorerase
  139. nrfjprog -f nrf52 --reset
  140. erase:
  141. nrfjprog -f nrf52 --eraseall
  142. SDK_CONFIG_FILE := ../config/sdk_config.h
  143. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  144. sdk_config:
  145. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)