clean up makefile, move linker out of src folder

This commit is contained in:
hathach 2020-03-24 21:07:20 +07:00
parent bfa269c55f
commit cb735eaf8b
5 changed files with 17 additions and 23 deletions

View File

@ -1,13 +1,11 @@
#****************************************************************************** #******************************************************************************
# CONFIGURE # CONFIGURE
# - SDK_PATH : path to SDK directory # - SDK_PATH : path to SDK directory
# - SRC_PATH : path to src folder
# #
# - SD_NAME : e.g s132, s140 # - SD_NAME : e.g s132, s140
# - SD_VERSION : SoftDevice version e.g 6.0.0 # - SD_VERSION : SoftDevice version e.g 6.0.0
# - SD_HEX : to bootloader hex binary # - SD_HEX : to bootloader hex binary
#****************************************************************************** #******************************************************************************
SRC_PATH = src
SDK_PATH = lib/sdk/components SDK_PATH = lib/sdk/components
SDK11_PATH = lib/sdk11/components SDK11_PATH = lib/sdk11/components
@ -21,7 +19,8 @@ SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
LD_FILE = $(SRC_PATH)/linker/$(MCU_SUB_VARIANT)_$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld # linker by MCU and SoftDevice eg. nrf52840_s140_v6.ld
LD_FILE = linker/$(MCU_SUB_VARIANT)_$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION) MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
@ -102,22 +101,18 @@ endif
# SOURCE FILES # SOURCE FILES
#****************************************************************************** #******************************************************************************
# src # all files in src
C_SRC += $(SRC_PATH)/boards.c C_SRC += $(wildcard src/*.c)
C_SRC += $(SRC_PATH)/dfu_ble_svc.c
C_SRC += $(SRC_PATH)/dfu_init.c
C_SRC += $(SRC_PATH)/flash_nrf5x.c
C_SRC += $(SRC_PATH)/main.c
# all sources files in specific board # all sources files in specific board
C_SRC += $(wildcard $(SRC_PATH)/boards/$(BOARD)/*.c) C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
# nrfx # nrfx
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c C_SRC += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
C_SRC += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c C_SRC += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
# SDK 11 files # SDK 11 files: serial + OTA DFU
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
@ -130,7 +125,7 @@ C_SRC += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
# Latest SDK files # Latest SDK files: peripheral drivers
C_SRC += $(SDK_PATH)/libraries/timer/app_timer.c C_SRC += $(SDK_PATH)/libraries/timer/app_timer.c
C_SRC += $(SDK_PATH)/libraries/scheduler/app_scheduler.c C_SRC += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
C_SRC += $(SDK_PATH)/libraries/util/app_error.c C_SRC += $(SDK_PATH)/libraries/util/app_error.c
@ -152,11 +147,10 @@ IPATH += $(SDK_PATH)/drivers_nrf/common
IPATH += $(SDK_PATH)/drivers_nrf/uart IPATH += $(SDK_PATH)/drivers_nrf/uart
else else
# src
C_SRC += $(SRC_PATH)/usb/usb_desc.c # USB Application ( MSC + UF2 )
C_SRC += $(SRC_PATH)/usb/usb.c C_SRC += $(wildcard src/usb/*.c)
C_SRC += $(SRC_PATH)/usb/msc_uf2.c C_SRC += $(wildcard src/usb/uf2/*.c)
C_SRC += $(SRC_PATH)/usb/uf2/ghostfat.c
# TinyUSB stack # TinyUSB stack
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
@ -180,12 +174,12 @@ ASM_SRC = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
#****************************************************************************** #******************************************************************************
# src # src
IPATH += $(SRC_PATH) IPATH += src
IPATH += $(SRC_PATH)/boards/$(BOARD) IPATH += src/boards/$(BOARD)
IPATH += $(SRC_PATH)/cmsis/include IPATH += src/cmsis/include
IPATH += $(SRC_PATH)/usb IPATH += src/usb
IPATH += $(SRC_PATH)/boards IPATH += src/boards
IPATH += $(TUSB_PATH) IPATH += $(TUSB_PATH)
# nrfx # nrfx
@ -257,7 +251,7 @@ CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)
# keep every function in separate section. This will allow linker to dump unused functions # keep every function in separate section. This will allow linker to dump unused functions
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/linker -T$(LD_FILE) LDFLAGS += -mthumb -mabi=aapcs -Llinker -T$(LD_FILE)
LDFLAGS += -mcpu=cortex-m4 LDFLAGS += -mcpu=cortex-m4
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16