Makefile.nrf52840 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #VPATH += :$(HALPATH)/k24f
  2. #TMPSRC += $(wildcard $(HALPATH)/k24f/*.c)
  3. #DVRSRC += $(wildcard $(HALPATH)/k24f/Drivers/*.c)
  4. #SRC += $(subst $(HALPATH)/k24f/,,$(TMPSRC))
  5. #$(info SRC is $(SRC))
  6. #EXTRAINCDIRS += $(HALPATH)/k24f $(HALPATH)/k24f/CMSIS $(HALPATH)/k24f/Drivers
  7. EXTRAINCDIRS +=
  8. #ASRC += startup_MK24F12.S
  9. #MCU_FLAGS = -mcpu=cortex-m4
  10. CC = arm-none-eabi-gcc
  11. OBJCOPY = arm-none-eabi-objcopy
  12. OBJDUMP = arm-none-eabi-objdump
  13. SIZE = arm-none-eabi-size
  14. AR = arm-none-eabi-ar rcs
  15. NM = arm-none-eabi-nm
  16. #Output Format = Binary for this target
  17. FORMAT = binary
  18. TARGETS := nrf52840_xxaa
  19. OUTPUT_DIRECTORY := _build
  20. SDK_ROOT := ../hal/nrf52840/nrf_sdk_15.0.0
  21. PROJ_DIR := ../hal/nrf52840/nrf_sdk_15.0.0/examples/peripheral/serial/ufo/blank/config
  22. LINKER_SCRIPT := $(PROJ_DIR)/../armgcc/serial_gcc_nrf52.ld
  23. VPATH += :$(SDK_ROOT):../hal/nrf52840
  24. # Source files common to all targets
  25. ASRC += \
  26. modules/nrfx/mdk/gcc_startup_nrf52840.S
  27. SRC += \
  28. nrf52840_hal.c \
  29. components/boards/boards.c \
  30. components/libraries/button/app_button.c \
  31. components/libraries/util/app_error.c \
  32. components/libraries/util/app_error_handler_gcc.c \
  33. components/libraries/util/app_error_weak.c \
  34. components/libraries/scheduler/app_scheduler.c \
  35. components/libraries/timer/app_timer.c \
  36. components/libraries/util/app_util_platform.c \
  37. components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c \
  38. components/libraries/hardfault/hardfault_implementation.c \
  39. components/libraries/util/nrf_assert.c \
  40. components/libraries/atomic/nrf_atomic.c \
  41. components/libraries/queue/nrf_queue.c \
  42. components/libraries/serial/nrf_serial.c \
  43. components/libraries/strerror/nrf_strerror.c \
  44. integration/nrfx/legacy/nrf_drv_clock.c \
  45. integration/nrfx/legacy/nrf_drv_power.c \
  46. integration/nrfx/legacy/nrf_drv_uart.c \
  47. components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c \
  48. components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \
  49. modules/nrfx/drivers/src/nrfx_clock.c \
  50. modules/nrfx/drivers/src/nrfx_gpiote.c \
  51. modules/nrfx/drivers/src/nrfx_power.c \
  52. modules/nrfx/drivers/src/nrfx_power_clock.c \
  53. modules/nrfx/drivers/src/prs/nrfx_prs.c \
  54. modules/nrfx/drivers/src/nrfx_uart.c \
  55. modules/nrfx/drivers/src/nrfx_uarte.c \
  56. components/libraries/bsp/bsp.c \
  57. modules/nrfx/mdk/system_nrf52840.c \
  58. # This is a bit of a hack, used to make build directory.
  59. # As windows mkdir does't have -p option you need to build out
  60. # this list in order of depth
  61. MKDIR_LIST = components \
  62. components/boards \
  63. components/libraries \
  64. components/libraries/button \
  65. components/libraries/util \
  66. components/libraries/scheduler \
  67. components/libraries/timer \
  68. components/libraries/hardfault \
  69. components/libraries/hardfault/nrf52 \
  70. components/libraries/hardfault/nrf52/handler \
  71. components/libraries/atomic \
  72. components/libraries/queue \
  73. components/libraries/serial \
  74. components/libraries/strerror \
  75. components/libraries/bsp \
  76. integration \
  77. integration/nrfx \
  78. integration/nrfx/legacy \
  79. components/drivers_nrf \
  80. components/drivers_nrf/nrf_soc_nosd \
  81. modules \
  82. modules/nrfx \
  83. modules/nrfx/drivers \
  84. modules/nrfx/drivers/src \
  85. modules/nrfx/drivers/src/prs \
  86. modules/nrfx/mdk
  87. # Include folders common to all targets
  88. EXTRAINCDIRS += \
  89. $(SDK_ROOT)/components \
  90. $(SDK_ROOT)/modules/nrfx/mdk \
  91. $(SDK_ROOT)/components/libraries/scheduler \
  92. $(SDK_ROOT)/components/libraries/experimental_log \
  93. $(SDK_ROOT)/components/libraries/queue \
  94. $(SDK_ROOT)/components/libraries/timer \
  95. $(SDK_ROOT)/components/libraries/strerror \
  96. $(SDK_ROOT)/components/libraries/serial \
  97. $(SDK_ROOT)/components/toolchain/cmsis/include \
  98. $(SDK_ROOT)/components/libraries/util \
  99. $(SDK_ROOT)/components/libraries/bsp \
  100. ../config \
  101. $(SDK_ROOT)/components/libraries/balloc \
  102. $(SDK_ROOT)/components/libraries/hardfault/nrf52 \
  103. $(SDK_ROOT)/modules/nrfx/hal \
  104. $(SDK_ROOT)/components/libraries/hardfault \
  105. $(SDK_ROOT)/components/libraries/button \
  106. $(SDK_ROOT)/modules/nrfx \
  107. $(SDK_ROOT)/components/libraries/experimental_section_vars \
  108. $(SDK_ROOT)/integration/nrfx/legacy \
  109. $(SDK_ROOT)/components/libraries/mutex \
  110. $(PROJ_DIR) \
  111. $(SDK_ROOT)/components/libraries/experimental_log/src \
  112. $(SDK_ROOT)/components/libraries/delay \
  113. $(SDK_ROOT)/integration/nrfx \
  114. $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
  115. $(SDK_ROOT)/components/libraries/atomic \
  116. $(SDK_ROOT)/components/boards \
  117. $(SDK_ROOT)/components/libraries/experimental_memobj \
  118. $(SDK_ROOT)/modules/nrfx/drivers/include \
  119. $(SDK_ROOT)/external/nrf_cc310/include \
  120. $(SDK_ROOT)/external/nrf_cc310/common \
  121. # Optimization flags
  122. OPT = 3
  123. # Uncomment the line below to enable link time optimization
  124. #CFLAGS += -flto
  125. # C flags common to all targets
  126. CFLAGS += -O$(OPT)
  127. CFLAGS += -DBOARD_CW308T_NRF52840
  128. CFLAGS += -DCONFIG_GPIO_AS_PINRESET
  129. CFLAGS += -DDEBUG
  130. CFLAGS += -DDEBUG_NRF
  131. CFLAGS += -DFLOAT_ABI_HARD
  132. CFLAGS += -DNRF52840_XXAA
  133. #CFLAGS += -DSWI_DISABLE0
  134. CFLAGS += -mcpu=cortex-m4
  135. CFLAGS += -mthumb -mabi=aapcs
  136. CFLAGS += -Wall
  137. CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  138. # keep every function in a separate section, this allows linker to discard unused ones
  139. CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
  140. CFLAGS += -fno-builtin -fshort-enums
  141. # C++ flags common to all targets
  142. CXXFLAGS += -O$(OPT)
  143. # Assembler flags common to all targets
  144. ASFLAGS += -g3
  145. ASFLAGS += -mcpu=cortex-m4
  146. ASFLAGS += -mthumb -mabi=aapcs
  147. ASFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  148. ASFLAGS += -DBOARD_CW308T_NRF52840
  149. ASFLAGS += -DCONFIG_GPIO_AS_PINRESET
  150. ASFLAGS += -DDEBUG
  151. ASFLAGS += -DDEBUG_NRF
  152. ASFLAGS += -DFLOAT_ABI_HARD
  153. ASFLAGS += -DNRF52840_XXAA
  154. ASFLAGS += -DSWI_DISABLE0
  155. # Linker flags
  156. LDFLAGS += -O$(OPT)
  157. LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
  158. LDFLAGS += -mcpu=cortex-m4
  159. LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  160. # let linker dump unused sections
  161. LDFLAGS += -Wl,--gc-sections
  162. # use newlib in nano version
  163. LDFLAGS += --specs=nano.specs
  164. nrf52840_xxaa: CFLAGS += -D__HEAP_SIZE=8192
  165. nrf52840_xxaa: CFLAGS += -D__STACK_SIZE=8192
  166. nrf52840_xxaa: ASMFLAGS += -D__HEAP_SIZE=8192
  167. nrf52840_xxaa: ASMFLAGS += -D__STACK_SIZE=8192
  168. LDFLAGS += -L $(SDK_ROOT)/external/nrf_cc310/lib/ -l:libnrf_cc310_0.9.9.a
  169. # Add standard libraries at the very end of the linker input, after all objects
  170. # that may need symbols provided by these libraries.
  171. LDFLAGS += -lc -lnosys -lm