2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# CONFIGURE (no spaces!)
|
2018-08-06 11:15:53 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#
|
2018-08-06 11:15:53 +00:00
|
|
|
# - SDK_PATH : path to SDK directory
|
|
|
|
# - SRC_PATH : path to src folder
|
2018-02-07 16:32:49 +00:00
|
|
|
#
|
2018-08-06 11:15:53 +00:00
|
|
|
# - SD_NAME : e.g s132, s140
|
|
|
|
# - SD_VER1, SD_VER2, SD_VER3: SoftDevice version e.g 6.0.0
|
|
|
|
# - SD_VER4 : is build number for bootloader
|
|
|
|
# - SD_HEX : to bootloader hex binary
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
2018-08-06 11:15:53 +00:00
|
|
|
SDK_PATH = ../lib/sdk/components
|
|
|
|
SDK11_PATH = ../lib/sdk11/components
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
SRC_PATH = .
|
|
|
|
TUSB_PATH = ../lib/tinyusb/src
|
2018-04-03 11:28:41 +00:00
|
|
|
|
2018-08-06 11:37:35 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
SD_VER1 = 6
|
|
|
|
SD_VER2 = 0
|
|
|
|
SD_VER3 = 0
|
|
|
|
SD_VER4 = 0
|
|
|
|
SD_VERSION = $(SD_VER1).$(SD_VER2).$(SD_VER3)
|
|
|
|
SD_VERSION_FULL = $(SD_VERSION)r$(SD_VER4)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 13:05:01 +00:00
|
|
|
SD_PATH = ../lib/softdevice/$(SD_NAME)/$(SD_VERSION)
|
|
|
|
SD_HEX = $(SD_PATH)/hex/$(SD_NAME)_nrf52_$(SD_VERSION)_softdevice.hex
|
2018-08-06 11:15:53 +00:00
|
|
|
LINKER_SCRIPT = $(SRC_PATH)/$(SD_NAME)_$(SD_VERSION).ld
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
OUTPUT_FILENAME = $(BOARD)_bootloader
|
|
|
|
BOOT_SD_NAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL)
|
2018-02-08 10:34:27 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
BETA_DIR = ../bin/$(BOARD)/beta
|
2018-08-06 11:37:35 +00:00
|
|
|
RELEASE_DIR = ../bin/$(BOARD)/$(SD_VERSION_FULL)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-06 11:29:32 +00:00
|
|
|
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION_FULL)"
|
2018-08-06 10:41:02 +00:00
|
|
|
|
|
|
|
# Select the board to build for.
|
|
|
|
ifeq ($(BOARD),)
|
|
|
|
$(info You must provide a BOARD parameter with 'BOARD=')
|
|
|
|
$(info Possible values are:)
|
|
|
|
$(info $(sort $(subst .h,,$(subst boards/,,$(wildcard boards/*)))))
|
|
|
|
$(error BOARD not defined)
|
|
|
|
else
|
|
|
|
ifeq ($(wildcard boards/$(BOARD).h),)
|
|
|
|
$(error Invalid BOARD specified)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
BUILD = _build-$(BOARD)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 11:29:32 +00:00
|
|
|
NRF52840_BOARDLIST = pca10056 feather52840
|
2018-08-06 13:05:01 +00:00
|
|
|
IS_NRF52840 = $(findstring $(BOARD),$(NRF52840_BOARDLIST))
|
2018-08-06 11:29:32 +00:00
|
|
|
|
2018-08-06 11:37:35 +00:00
|
|
|
ifneq ($(IS_NRF52840),)
|
2018-08-06 11:29:32 +00:00
|
|
|
#nrf52840 board
|
2018-08-06 13:05:01 +00:00
|
|
|
$(info nRF52840)
|
2018-08-06 11:37:35 +00:00
|
|
|
SD_NAME = s140
|
2018-08-06 11:29:32 +00:00
|
|
|
else
|
|
|
|
#nrf52832 board
|
2018-08-06 13:05:01 +00:00
|
|
|
$(info nRF52832)
|
2018-08-06 11:37:35 +00:00
|
|
|
SD_NAME = s132
|
2018-08-06 11:29:32 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Tool configure
|
|
|
|
#******************************************************************************
|
|
|
|
NRFUTIL = nrfutil
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
PROGFILES = C:/Program Files (x86)
|
|
|
|
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/6 2017-q2-update
|
|
|
|
else
|
|
|
|
GNU_INSTALL_ROOT = /usr
|
|
|
|
endif
|
|
|
|
|
|
|
|
MK := mkdir
|
|
|
|
RM := rm -rf
|
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
ifeq ("$(V)","2")
|
|
|
|
QUIET :=
|
2018-02-07 16:32:49 +00:00
|
|
|
else
|
2018-08-06 10:41:02 +00:00
|
|
|
QUIET := @
|
2018-02-07 16:32:49 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
GNU_PREFIX = arm-none-eabi
|
|
|
|
|
|
|
|
# Toolchain commands
|
|
|
|
CC := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc'
|
|
|
|
AS := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as'
|
|
|
|
AR := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar' -r
|
|
|
|
LD := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld'
|
|
|
|
NM := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm'
|
|
|
|
OBJDUMP := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump'
|
|
|
|
OBJCOPY := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy'
|
|
|
|
SIZE := '$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size'
|
|
|
|
|
|
|
|
#function for removing duplicates in a list
|
|
|
|
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
|
|
|
|
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# SOURCE FILES
|
|
|
|
#******************************************************************************
|
2018-04-20 06:42:51 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
2018-06-18 09:54:41 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/tusb_descriptors.c
|
2018-06-20 08:28:30 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
2018-06-25 16:37:24 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-04-04 17:35:08 +00:00
|
|
|
# SDK 11 files
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_util.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_init_template.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
2018-06-26 07:28:03 +00:00
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-04-04 17:35:08 +00:00
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
|
|
|
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
|
|
|
C_SOURCE_FILES += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
|
|
|
|
|
|
|
# Latest SDK files
|
2018-02-07 16:32:49 +00:00
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/timer/app_timer.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/scheduler/app_scheduler.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_error.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/app_util_platform.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/crc16/crc16.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_slip.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/hci/hci_transport.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c
|
|
|
|
|
2018-04-14 05:26:21 +00:00
|
|
|
#C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
|
|
|
|
#C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-04-04 17:35:08 +00:00
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
2018-05-11 16:16:43 +00:00
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/hal/nrf_nvmc.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-02-09 16:06:27 +00:00
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/toolchain/system_nrf52840.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-04-04 17:35:08 +00:00
|
|
|
# Tinyusb stack
|
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/hal_nrf5x.c
|
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/common/tusb_fifo.c
|
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd.c
|
2018-08-01 03:30:36 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd_auto_desc.c
|
2018-04-04 17:35:08 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/class/cdc/cdc_device.c
|
2018-04-14 05:26:21 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c
|
2018-06-16 07:08:28 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c
|
2018-04-04 17:35:08 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# Assembly Files
|
|
|
|
#******************************************************************************
|
2018-02-09 16:06:27 +00:00
|
|
|
ASM_SOURCE_FILES = $(SDK_PATH)/toolchain/gcc/gcc_startup_nrf52840.S
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# INCLUDE PATH
|
|
|
|
#******************************************************************************
|
|
|
|
INC_PATHS += -I$(SRC_PATH)/
|
2018-06-18 09:54:41 +00:00
|
|
|
INC_PATHS += -I$(SRC_PATH)/usb
|
2018-04-02 06:11:21 +00:00
|
|
|
INC_PATHS += -I$(TUSB_PATH)/
|
2018-04-04 17:35:08 +00:00
|
|
|
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/libraries/bootloader_dfu
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/drivers_nrf/pstorage
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/ble/common
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/ble/ble_services/ble_dfu
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/ble/ble_services/ble_dis
|
|
|
|
INC_PATHS += -I$(SDK11_PATH)/libraries/util
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/timer
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/scheduler
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/crc16
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/util
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/hci/config
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/uart
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/libraries/hci
|
|
|
|
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/common
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/hal
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/config
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/delay
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/uart
|
2018-04-02 06:11:21 +00:00
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/power
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/usbd
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/device
|
|
|
|
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/toolchain/cmsis/include
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/toolchain/gcc
|
|
|
|
INC_PATHS += -I$(SDK_PATH)/toolchain
|
|
|
|
|
2018-04-04 17:35:08 +00:00
|
|
|
|
|
|
|
INC_PATHS += -I$(SD_PATH)/common
|
2018-08-06 13:05:01 +00:00
|
|
|
INC_PATHS += -I$(SD_PATH)/headers
|
|
|
|
INC_PATHS += -I$(SD_PATH)/headers/nrf52
|
2018-04-04 17:35:08 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Compiler Flags
|
|
|
|
# - Additional compiler flags
|
|
|
|
#******************************************************************************
|
|
|
|
|
|
|
|
#flags common to all targets
|
2018-08-06 10:41:02 +00:00
|
|
|
CFLAGS += -mcpu=cortex-m4
|
|
|
|
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
|
|
|
|
CFLAGS += -Wall -Werror -Os -g3
|
|
|
|
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
|
|
|
|
|
|
# keep every function in separate section. This will allow linker to dump unused functions
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
|
|
|
CFLAGS += -fno-builtin --short-enums
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
# Defined Symbol (MACROS)
|
2018-08-06 11:15:53 +00:00
|
|
|
CFLAGS += -DBOOTLOADER_VERSION=0x0$(SD_VER1)0$(SD_VER2)0$(SD_VER3)0$(SD_VER4)UL
|
2018-02-08 06:50:01 +00:00
|
|
|
CFLAGS += -DNRF52840_XXAA
|
2018-02-07 16:32:49 +00:00
|
|
|
CFLAGS += -D__HEAP_SIZE=0
|
2018-02-08 06:50:01 +00:00
|
|
|
CFLAGS += -DS140
|
2018-02-07 16:32:49 +00:00
|
|
|
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
|
|
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
|
|
|
CFLAGS += -DBSP_DEFINES_ONLY
|
|
|
|
CFLAGS += -DSWI_DISABLE0
|
|
|
|
CFLAGS += -DSOFTDEVICE_PRESENT
|
2018-02-08 06:50:01 +00:00
|
|
|
CFLAGS += -DFLOAT_ABI_HARD
|
2018-05-25 14:33:47 +00:00
|
|
|
CFLAGS += -DMK_DIS_FIRMWARE='$(MK_DIS_FIRMWARE)'
|
2018-02-07 16:32:49 +00:00
|
|
|
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# Linker Flags
|
|
|
|
#
|
|
|
|
#******************************************************************************
|
|
|
|
|
|
|
|
# keep every function in separate section. This will allow linker to dump unused functions
|
2018-08-06 10:41:02 +00:00
|
|
|
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
|
2018-04-03 11:28:41 +00:00
|
|
|
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/ -T$(LINKER_SCRIPT)
|
2018-02-07 16:32:49 +00:00
|
|
|
LDFLAGS += -mcpu=cortex-m4
|
|
|
|
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
|
|
|
|
|
|
# let linker to dump unused sections
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
|
|
|
|
|
|
|
# use newlib in nano version
|
|
|
|
LDFLAGS += --specs=nano.specs -lc -lnosys
|
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# Assembler flags
|
|
|
|
#
|
|
|
|
#******************************************************************************
|
|
|
|
ASMFLAGS += -x assembler-with-cpp
|
2018-02-08 06:50:01 +00:00
|
|
|
ASMFLAGS += -DNRF52840_XXAA
|
2018-02-07 16:32:49 +00:00
|
|
|
ASMFLAGS += -D__HEAP_SIZE=0
|
2018-02-08 06:50:01 +00:00
|
|
|
ASMFLAGS += -DS140
|
2018-02-07 16:32:49 +00:00
|
|
|
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
|
|
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
|
|
|
ASMFLAGS += -DBSP_DEFINES_ONLY
|
|
|
|
ASMFLAGS += -DSWI_DISABLE0
|
|
|
|
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
2018-02-08 06:50:01 +00:00
|
|
|
ASMFLAGS += -DFLOAT_ABI_HARD
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
|
|
|
|
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
|
2018-08-06 10:41:02 +00:00
|
|
|
C_OBJECTS = $(addprefix $(BUILD)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
|
|
|
|
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
|
2018-08-06 10:41:02 +00:00
|
|
|
ASM_OBJECTS = $(addprefix $(BUILD)/, $(ASM_SOURCE_FILE_NAMES:.S=.o) )
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
vpath %.c $(C_PATHS)
|
|
|
|
vpath %.S $(ASM_PATHS)
|
|
|
|
|
|
|
|
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# BUILD TARGETS
|
|
|
|
#******************************************************************************
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
ifeq ("$(V)","1")
|
|
|
|
$(info CFLAGS $(CFLAGS))
|
|
|
|
$(info )
|
|
|
|
$(info LDFLAGS $(LDFLAGS))
|
|
|
|
$(info )
|
|
|
|
endif
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-06 11:15:53 +00:00
|
|
|
.phony: all clean size flash sd
|
2018-08-06 10:41:02 +00:00
|
|
|
|
|
|
|
all: $(BUILD)/$(OUTPUT_FILENAME).out size
|
|
|
|
|
|
|
|
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
@echo Flashing: $<
|
|
|
|
nrfjprog --program $< --sectoranduicrerase -f nrf52 --reset
|
|
|
|
|
|
|
|
sd:
|
|
|
|
@echo Flashing: $(SD_HEX)
|
|
|
|
nrfjprog --program $(SD_HEX) -f nrf52 --chiperase --reset
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
## Create build directories
|
2018-08-06 10:41:02 +00:00
|
|
|
$(BUILD):
|
2018-02-07 16:32:49 +00:00
|
|
|
@$(MK) $@
|
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
clean:
|
|
|
|
@$(RM) $(BUILD)
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
# Create objects from C SRC files
|
2018-08-06 10:41:02 +00:00
|
|
|
$(BUILD)/%.o: %.c
|
|
|
|
@echo CC $(notdir $<)
|
|
|
|
$(QUIET)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
# Assemble files
|
2018-08-06 10:41:02 +00:00
|
|
|
$(BUILD)/%.o: %.S
|
|
|
|
@echo AS $(notdir $<)
|
|
|
|
$(QUIET)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
# Link
|
2018-08-06 10:41:02 +00:00
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).out: $(BUILD) $(OBJECTS)
|
|
|
|
@echo LD $(OUTPUT_FILENAME).out
|
|
|
|
$(QUIET)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -lm -o $(BUILD)/$(OUTPUT_FILENAME).out
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
size: $(BUILD)/$(OUTPUT_FILENAME).out
|
2018-02-07 16:32:49 +00:00
|
|
|
-@echo ''
|
2018-08-06 10:41:02 +00:00
|
|
|
$(QUIET)$(SIZE) $<
|
2018-02-07 16:32:49 +00:00
|
|
|
-@echo ''
|
|
|
|
|
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
.phony: genhex genpkg beta release
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
## Create binary .hex file from the .out file
|
|
|
|
genhex: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
|
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).out
|
|
|
|
@echo CR $(OUTPUT_FILENAME).hex
|
|
|
|
@echo CR $(BOOT_SD_NAME).hex
|
|
|
|
$(QUIET)$(OBJCOPY) -O ihex $< $@
|
|
|
|
@mergehex -q -m $@ $(SD_HEX) -o $(BUILD)/$(BOOT_SD_NAME).hex
|
|
|
|
|
|
|
|
## Create pkg file for bootloader+SD combo to use with DFU
|
|
|
|
genpkg: $(BUILD)/$(BOOT_SD_NAME).zip
|
|
|
|
|
|
|
|
$(BUILD)/$(BOOT_SD_NAME).zip: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision 0xADAF --bootloader $< --softdevice $(SD_HEX) $@
|
|
|
|
|
|
|
|
# Create SD+bootloader combo with hex & dfu package at beta folder
|
|
|
|
beta: genhex genpkg
|
|
|
|
@echo CR $(BETA_DIR)/$(BOOT_SD_NAME).hex
|
|
|
|
@echo CR $(BETA_DIR)/$(BOOT_SD_NAME).zip
|
|
|
|
@mkdir -p $(BETA_DIR)
|
|
|
|
@cp $(BUILD)/$(BOOT_SD_NAME).hex $(BETA_DIR)/$(BOOT_SD_NAME).hex
|
|
|
|
@cp $(BUILD)/$(BOOT_SD_NAME).zip $(BETA_DIR)/$(BOOT_SD_NAME).zip
|
|
|
|
|
|
|
|
release: genhex genpkg
|
|
|
|
@echo CR $(RELEASE_DIR)/$(BOOT_SD_NAME).hex
|
|
|
|
@echo CR $(RELEASE_DIR)/$(BOOT_SD_NAME).zip
|
|
|
|
@mkdir -p $(RELEASE_DIR)
|
|
|
|
@cp $(BUILD)/$(BOOT_SD_NAME).hex $(RELEASE_DIR)/$(BOOT_SD_NAME).hex
|
|
|
|
@cp $(BUILD)/$(BOOT_SD_NAME).zip $(RELEASE_DIR)/$(BOOT_SD_NAME).zip
|
|
|
|
|