Makefile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. PROJECT_NAME := esb_prx_pca10056
  2. TARGETS := nrf52840_xxaa
  3. OUTPUT_DIRECTORY := _build
  4. SDK_ROOT := ../../../../../..
  5. PROJ_DIR := ../../..
  6. $(OUTPUT_DIRECTORY)/nrf52840_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_nrf52840.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_nrf52840.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_PCA10056
  78. CFLAGS += -DBSP_DEFINES_ONLY
  79. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  80. CFLAGS += -DESB_PRESENT
  81. CFLAGS += -DFLOAT_ABI_HARD
  82. CFLAGS += -DNRF52840_XXAA
  83. CFLAGS += -mcpu=cortex-m4
  84. CFLAGS += -mthumb -mabi=aapcs
  85. CFLAGS += -Wall -Werror
  86. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  87. # keep every function in a separate section, this allows linker to discard unused ones
  88. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  89. CFLAGS += -fno-builtin -fshort-enums
  90. # C++ flags common to all targets
  91. CXXFLAGS += $(OPT)
  92. # Assembler flags common to all targets
  93. ASMFLAGS += -g3
  94. ASMFLAGS += -mcpu=cortex-m4
  95. ASMFLAGS += -mthumb -mabi=aapcs
  96. ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  97. ASMFLAGS += -DBOARD_PCA10056
  98. ASMFLAGS += -DBSP_DEFINES_ONLY
  99. ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
  100. ASMFLAGS += -DESB_PRESENT
  101. ASMFLAGS += -DFLOAT_ABI_HARD
  102. ASMFLAGS += -DNRF52840_XXAA
  103. # Linker flags
  104. LDFLAGS += $(OPT)
  105. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  106. LDFLAGS += -mcpu=cortex-m4
  107. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  108. # let linker dump unused sections
  109. LDFLAGS += -Wl,--gc-sections
  110. # use newlib in nano version
  111. LDFLAGS += --specs=nano.specs
  112. nrf52840_xxaa: CFLAGS += -D__HEAP_SIZE=8192
  113. nrf52840_xxaa: CFLAGS += -D__STACK_SIZE=8192
  114. nrf52840_xxaa: ASMFLAGS += -D__HEAP_SIZE=8192
  115. nrf52840_xxaa: ASMFLAGS += -D__STACK_SIZE=8192
  116. # Add standard libraries at the very end of the linker input, after all objects
  117. # that may need symbols provided by these libraries.
  118. LIB_FILES += -lc -lnosys -lm
  119. .PHONY: default help
  120. # Default target - first one defined
  121. default: nrf52840_xxaa
  122. # Print all targets that can be built
  123. help:
  124. @echo following targets are available:
  125. @echo nrf52840_xxaa
  126. @echo sdk_config - starting external tool for editing sdk_config.h
  127. @echo flash - flashing binary
  128. TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
  129. include $(TEMPLATE_PATH)/Makefile.common
  130. $(foreach target, $(TARGETS), $(call define_target, $(target)))
  131. .PHONY: flash erase
  132. # Flash the program
  133. flash: default
  134. @echo Flashing: $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex
  135. nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex --sectorerase
  136. nrfjprog -f nrf52 --reset
  137. erase:
  138. nrfjprog -f nrf52 --eraseall
  139. SDK_CONFIG_FILE := ../config/sdk_config.h
  140. CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
  141. sdk_config:
  142. java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)