2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
2018-08-07 14:25:35 +00:00
|
|
|
# CONFIGURE
|
2019-04-24 11:25:25 +00:00
|
|
|
# - SDK_PATH : path to SDK directory
|
2018-02-07 16:32:49 +00:00
|
|
|
#
|
2019-04-24 11:25:25 +00:00
|
|
|
# - SD_NAME : e.g s132, s140
|
2019-04-25 03:36:08 +00:00
|
|
|
# - SD_VERSION : SoftDevice version e.g 6.0.0
|
2019-04-24 11:25:25 +00:00
|
|
|
# - SD_HEX : to bootloader hex binary
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
2018-08-08 17:51:13 +00:00
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
SDK_PATH = lib/sdk/components
|
|
|
|
SDK11_PATH = lib/sdk11/components
|
|
|
|
SD_PATH = lib/softdevice/$(SD_FILENAME)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
TUSB_PATH = lib/tinyusb/src
|
|
|
|
NRFX_PATH = lib/nrfx
|
2018-04-03 11:28:41 +00:00
|
|
|
|
2019-04-24 11:25:25 +00:00
|
|
|
SD_VERSION = 6.1.1
|
2018-12-19 10:23:06 +00:00
|
|
|
SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION)
|
|
|
|
SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API
|
|
|
|
SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
|
2018-08-08 17:51:13 +00:00
|
|
|
|
2020-03-24 14:07:20 +00:00
|
|
|
# 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
|
2018-02-08 10:34:27 +00:00
|
|
|
|
2018-12-04 23:18:49 +00:00
|
|
|
GIT_VERSION = $(shell git describe --dirty --always --tags)
|
|
|
|
GIT_SUBMODULE_VERSIONS = $(shell git submodule status | cut -d' ' -f3,4 | paste -s -d" " -)
|
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
# compiled file name
|
|
|
|
OUT_FILE = $(BOARD)_bootloader-$(GIT_VERSION)
|
|
|
|
|
|
|
|
# merged file = compiled + sd
|
|
|
|
MERGED_FILE = $(OUT_FILE)_$(SD_NAME)_$(SD_VERSION)
|
2019-04-24 11:25:25 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Tool configure
|
|
|
|
#******************************************************************************
|
2018-08-07 09:51:08 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
# Toolchain commands
|
|
|
|
# Should be added to your PATH
|
|
|
|
CROSS_COMPILE = arm-none-eabi-
|
2020-03-24 16:51:42 +00:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
AS = $(CROSS_COMPILE)as
|
|
|
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
|
|
|
SIZE = $(CROSS_COMPILE)size
|
|
|
|
GDB = $(CROSS_COMPILE)gdb
|
2020-02-14 01:14:37 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
NRFUTIL = adafruit-nrfutil
|
|
|
|
NRFJPROG = nrfjprog
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 16:51:42 +00:00
|
|
|
MK = mkdir -p
|
|
|
|
RM = rm -rf
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
# auto-detect BMP on macOS, otherwise have to specify
|
|
|
|
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
|
|
|
|
GDB_BMP = $(GDB) -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1'
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-07 06:15:07 +00:00
|
|
|
#*********************************
|
|
|
|
# Select the board to build
|
|
|
|
#*********************************
|
2020-03-24 09:04:21 +00:00
|
|
|
BOARD_LIST = $(sort $(subst src/boards/,,$(wildcard src/boards/*)))
|
2018-08-09 02:56:42 +00:00
|
|
|
|
2019-04-24 05:03:26 +00:00
|
|
|
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
|
|
|
$(info You must provide a BOARD parameter with 'BOARD='. Supported boards are:)
|
|
|
|
$(info $(BOARD_LIST))
|
|
|
|
$(error Invalid BOARD specified)
|
2018-08-07 06:15:07 +00:00
|
|
|
endif
|
|
|
|
|
2019-11-11 17:32:47 +00:00
|
|
|
# Build directory
|
2020-03-24 15:47:15 +00:00
|
|
|
BUILD = _build/build-$(BOARD)
|
2018-08-07 06:15:07 +00:00
|
|
|
|
2019-11-11 17:32:47 +00:00
|
|
|
# Board specific
|
|
|
|
-include src/boards/$(BOARD)/board.mk
|
|
|
|
|
|
|
|
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
2019-11-28 18:02:05 +00:00
|
|
|
SD_NAME = s132
|
|
|
|
DFU_DEV_REV = 0xADAF
|
|
|
|
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
|
2019-11-11 17:32:47 +00:00
|
|
|
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
2019-11-28 18:02:05 +00:00
|
|
|
SD_NAME = s140
|
|
|
|
DFU_DEV_REV = 52840
|
|
|
|
MCU_FLAGS = -DNRF52833_XXAA -DS140
|
|
|
|
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
|
|
|
SD_NAME = s140
|
|
|
|
DFU_DEV_REV = 52840
|
|
|
|
MCU_FLAGS = -DNRF52840_XXAA -DS140
|
2019-01-04 00:00:45 +00:00
|
|
|
else
|
2019-11-28 18:02:05 +00:00
|
|
|
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
|
2018-08-07 06:15:07 +00:00
|
|
|
endif
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# SOURCE FILES
|
|
|
|
#******************************************************************************
|
2018-04-20 06:42:51 +00:00
|
|
|
|
2020-03-24 14:07:20 +00:00
|
|
|
# all files in src
|
|
|
|
C_SRC += $(wildcard src/*.c)
|
2020-02-29 17:49:52 +00:00
|
|
|
|
|
|
|
# all sources files in specific board
|
2020-03-24 14:07:20 +00:00
|
|
|
C_SRC += $(wildcard src/boards/$(BOARD)/*.c)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-07 06:33:44 +00:00
|
|
|
# nrfx
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
|
|
|
C_SRC += $(NRFX_PATH)/drivers/src/nrfx_nvmc.c
|
|
|
|
C_SRC += $(NRFX_PATH)/mdk/system_$(MCU_SUB_VARIANT).c
|
2018-08-07 06:33:44 +00:00
|
|
|
|
2020-03-24 14:07:20 +00:00
|
|
|
# SDK 11 files: serial + OTA DFU
|
2020-03-24 09:04:21 +00:00
|
|
|
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_util.c
|
|
|
|
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_serial.c
|
|
|
|
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_transport_ble.c
|
|
|
|
C_SRC += $(SDK11_PATH)/libraries/bootloader_dfu/dfu_single_bank.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(SDK11_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
2018-04-04 17:35:08 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dfu/ble_dfu.c
|
|
|
|
C_SRC += $(SDK11_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
2018-04-04 17:35:08 +00:00
|
|
|
|
2020-03-24 14:07:20 +00:00
|
|
|
# Latest SDK files: peripheral drivers
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(SDK_PATH)/libraries/timer/app_timer.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_util_platform.c
|
|
|
|
C_SRC += $(SDK_PATH)/libraries/crc16/crc16.c
|
|
|
|
C_SRC += $(SDK_PATH)/libraries/hci/hci_mem_pool.c
|
|
|
|
C_SRC += $(SDK_PATH)/libraries/hci/hci_slip.c
|
|
|
|
C_SRC += $(SDK_PATH)/libraries/hci/hci_transport.c
|
|
|
|
C_SRC += $(SDK_PATH)/libraries/util/nrf_assert.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2019-11-11 17:32:47 +00:00
|
|
|
# UART or USB Serial
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52)
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(SDK_PATH)/libraries/uart/app_uart.c
|
|
|
|
C_SRC += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
|
|
|
C_SRC += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
2019-01-04 00:00:45 +00:00
|
|
|
|
|
|
|
IPATH += $(SDK11_PATH)/libraries/util
|
|
|
|
IPATH += $(SDK_PATH)/drivers_nrf/common
|
|
|
|
IPATH += $(SDK_PATH)/drivers_nrf/uart
|
|
|
|
|
|
|
|
else
|
2020-03-24 14:07:20 +00:00
|
|
|
|
|
|
|
# USB Application ( MSC + UF2 )
|
|
|
|
C_SRC += $(wildcard src/usb/*.c)
|
|
|
|
C_SRC += $(wildcard src/usb/uf2/*.c)
|
2018-08-06 15:02:29 +00:00
|
|
|
|
2019-11-11 17:32:47 +00:00
|
|
|
# TinyUSB stack
|
2020-03-24 09:04:21 +00:00
|
|
|
C_SRC += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
|
|
|
C_SRC += $(TUSB_PATH)/common/tusb_fifo.c
|
|
|
|
C_SRC += $(TUSB_PATH)/device/usbd.c
|
|
|
|
C_SRC += $(TUSB_PATH)/device/usbd_control.c
|
|
|
|
C_SRC += $(TUSB_PATH)/class/cdc/cdc_device.c
|
|
|
|
C_SRC += $(TUSB_PATH)/class/msc/msc_device.c
|
|
|
|
C_SRC += $(TUSB_PATH)/tusb.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 15:02:29 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Assembly Files
|
|
|
|
#******************************************************************************
|
2020-03-24 09:04:21 +00:00
|
|
|
ASM_SRC = $(NRFX_PATH)/mdk/gcc_startup_$(MCU_SUB_VARIANT).S
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# INCLUDE PATH
|
|
|
|
#******************************************************************************
|
2018-08-07 06:15:07 +00:00
|
|
|
|
|
|
|
# src
|
2020-03-24 14:07:20 +00:00
|
|
|
IPATH += src
|
|
|
|
IPATH += src/boards/$(BOARD)
|
2019-04-24 05:08:58 +00:00
|
|
|
|
2020-03-24 14:07:20 +00:00
|
|
|
IPATH += src/cmsis/include
|
|
|
|
IPATH += src/usb
|
|
|
|
IPATH += src/boards
|
2018-08-07 06:33:44 +00:00
|
|
|
IPATH += $(TUSB_PATH)
|
2018-08-06 15:02:29 +00:00
|
|
|
|
2018-08-07 06:15:07 +00:00
|
|
|
# nrfx
|
|
|
|
IPATH += $(NRFX_PATH)
|
2018-08-06 15:02:29 +00:00
|
|
|
IPATH += $(NRFX_PATH)/mdk
|
2018-08-07 06:15:07 +00:00
|
|
|
IPATH += $(NRFX_PATH)/hal
|
2018-08-07 06:33:44 +00:00
|
|
|
IPATH += $(NRFX_PATH)/drivers/include
|
2019-11-11 08:27:44 +00:00
|
|
|
IPATH += $(NRFX_PATH)/drivers/src
|
2018-08-06 15:02:29 +00:00
|
|
|
|
|
|
|
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
|
|
|
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
|
|
|
|
IPATH += $(SDK11_PATH)/drivers_nrf/pstorage
|
|
|
|
IPATH += $(SDK11_PATH)/ble/common
|
|
|
|
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dfu
|
|
|
|
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dis
|
2018-08-07 14:44:38 +00:00
|
|
|
|
2018-08-06 15:02:29 +00:00
|
|
|
IPATH += $(SDK_PATH)/libraries/timer
|
|
|
|
IPATH += $(SDK_PATH)/libraries/scheduler
|
|
|
|
IPATH += $(SDK_PATH)/libraries/crc16
|
|
|
|
IPATH += $(SDK_PATH)/libraries/util
|
|
|
|
IPATH += $(SDK_PATH)/libraries/hci/config
|
|
|
|
IPATH += $(SDK_PATH)/libraries/uart
|
|
|
|
IPATH += $(SDK_PATH)/libraries/hci
|
|
|
|
IPATH += $(SDK_PATH)/drivers_nrf/delay
|
|
|
|
|
2018-08-07 06:15:07 +00:00
|
|
|
# Softdevice
|
2018-08-08 17:51:13 +00:00
|
|
|
IPATH += $(SD_API_PATH)/include
|
|
|
|
IPATH += $(SD_API_PATH)/include/nrf52
|
2018-08-06 15:02:29 +00:00
|
|
|
|
|
|
|
INC_PATHS = $(addprefix -I,$(IPATH))
|
2018-04-04 17:35:08 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Compiler Flags
|
|
|
|
# - Additional compiler flags
|
|
|
|
#******************************************************************************
|
|
|
|
|
2020-03-24 17:04:28 +00:00
|
|
|
# Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -Og -ggdb
|
|
|
|
else
|
|
|
|
CFLAGS += -Os
|
|
|
|
endif
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#flags common to all targets
|
2020-03-24 17:04:28 +00:00
|
|
|
CFLAGS += \
|
|
|
|
-mthumb \
|
|
|
|
-mabi=aapcs \
|
|
|
|
-mcpu=cortex-m4 \
|
|
|
|
-mfloat-abi=hard \
|
|
|
|
-mfpu=fpv4-sp-d16 \
|
|
|
|
-ffunction-sections \
|
|
|
|
-fdata-sections \
|
|
|
|
-fno-builtin \
|
|
|
|
-fshort-enums \
|
|
|
|
-fstack-usage \
|
|
|
|
-fno-strict-aliasing \
|
|
|
|
-Wall \
|
|
|
|
-Werror
|
|
|
|
|
|
|
|
CFLAGS += -Wno-error=unused-parameter
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
# Defined Symbol (MACROS)
|
|
|
|
CFLAGS += -D__HEAP_SIZE=0
|
|
|
|
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
2019-04-24 05:23:11 +00:00
|
|
|
CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
|
2018-02-07 16:32:49 +00:00
|
|
|
CFLAGS += -DSOFTDEVICE_PRESENT
|
|
|
|
CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
2019-11-11 17:32:47 +00:00
|
|
|
CFLAGS += $(MCU_FLAGS)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-12-06 18:02:13 +00:00
|
|
|
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
2019-04-24 10:13:41 +00:00
|
|
|
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2019-04-24 11:25:25 +00:00
|
|
|
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
|
|
|
|
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# Linker Flags
|
|
|
|
#
|
|
|
|
#******************************************************************************
|
|
|
|
|
2020-03-24 16:51:42 +00:00
|
|
|
LDFLAGS += \
|
|
|
|
$(CFLAGS) \
|
|
|
|
-Wl,-L,linker -Wl,-T,$(LD_FILE) \
|
|
|
|
-Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections \
|
|
|
|
-specs=nosys.specs -specs=nano.specs
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 16:51:42 +00:00
|
|
|
LIBS += -lm -lc
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# Assembler flags
|
|
|
|
#
|
|
|
|
#******************************************************************************
|
|
|
|
ASMFLAGS += -x assembler-with-cpp
|
|
|
|
ASMFLAGS += -D__HEAP_SIZE=0
|
|
|
|
ASMFLAGS += -DSOFTDEVICE_PRESENT
|
2019-11-11 17:32:47 +00:00
|
|
|
ASMFLAGS += $(MCU_FLAGS)
|
2018-08-07 06:25:51 +00:00
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
|
|
|
|
#function for removing duplicates in a list
|
|
|
|
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
|
|
|
|
|
|
|
C_SOURCE_FILE_NAMES = $(notdir $(C_SRC))
|
|
|
|
C_PATHS = $(call remduplicates, $(dir $(C_SRC) ) )
|
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
|
|
|
|
2020-03-24 09:04:21 +00:00
|
|
|
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SRC))
|
|
|
|
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SRC) ))
|
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
|
|
|
|
2020-03-24 16:51:42 +00:00
|
|
|
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
2018-08-06 11:15:53 +00:00
|
|
|
ifeq ("$(V)","1")
|
|
|
|
$(info CFLAGS $(CFLAGS))
|
|
|
|
$(info )
|
|
|
|
$(info LDFLAGS $(LDFLAGS))
|
|
|
|
$(info )
|
2019-01-14 05:50:20 +00:00
|
|
|
$(info ASMFLAGS $(ASMFLAGS))
|
|
|
|
$(info )
|
2018-08-06 11:15:53 +00:00
|
|
|
endif
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2020-03-24 16:51:42 +00:00
|
|
|
ifeq ("$(V)","2")
|
|
|
|
QUIET =
|
|
|
|
else
|
|
|
|
QUIET = @
|
|
|
|
endif
|
|
|
|
|
2018-08-08 09:00:29 +00:00
|
|
|
.phony: all clean size flash sd erase
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-09 02:56:42 +00:00
|
|
|
# default target to build
|
2020-03-24 16:08:23 +00:00
|
|
|
all: $(BUILD)/$(OUT_FILE)-nosd.out size
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-09 02:56:42 +00:00
|
|
|
#******************* Flash target *******************
|
2018-08-10 14:43:14 +00:00
|
|
|
|
|
|
|
check_defined = \
|
|
|
|
$(strip $(foreach 1,$1, \
|
|
|
|
$(call __check_defined,$1,$(strip $(value 2)))))
|
|
|
|
__check_defined = \
|
|
|
|
$(if $(value $1),, \
|
|
|
|
$(error Undefined make flag: $1$(if $2, ($2))))
|
|
|
|
|
|
|
|
# Flash the compiled
|
2020-03-24 16:08:23 +00:00
|
|
|
flash: $(BUILD)/$(OUT_FILE)-nosd.hex
|
2018-08-06 10:41:02 +00:00
|
|
|
@echo Flashing: $<
|
2018-08-07 09:51:08 +00:00
|
|
|
$(NRFJPROG) --program $< --sectoranduicrerase -f nrf52 --reset
|
2018-09-06 17:46:11 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
dfu-flash: $(BUILD)/$(MERGED_FILE).zip
|
2018-08-10 14:43:14 +00:00
|
|
|
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
2019-02-22 16:55:01 +00:00
|
|
|
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank --touch 1200
|
2018-09-06 17:46:11 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
sd:
|
|
|
|
@echo Flashing: $(SD_HEX)
|
2018-09-06 17:46:11 +00:00
|
|
|
$(NRFJPROG) --program $(SD_HEX) -f nrf52 --chiperase --reset
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-08 09:00:29 +00:00
|
|
|
erase:
|
|
|
|
@echo Erasing chip
|
|
|
|
$(NRFJPROG) --eraseall -f nrf52
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
gdbflash: $(BUILD)/$(MERGED_FILE).hex
|
2020-02-14 01:14:37 +00:00
|
|
|
@echo Flashing: $<
|
|
|
|
@$(GDB_BMP) -nx --batch -ex 'load $<' -ex 'compare-sections' -ex 'kill'
|
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
gdb: $(BUILD)/$(OUT_FILE)-nosd.out
|
2020-02-28 18:26:49 +00:00
|
|
|
$(GDB_BMP) $<
|
|
|
|
|
2018-08-09 02:56:42 +00:00
|
|
|
#******************* Compile rules *******************
|
|
|
|
|
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-09-06 17:46:11 +00:00
|
|
|
|
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 $<)
|
2019-01-14 05:50:20 +00:00
|
|
|
$(QUIET)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
|
2018-09-06 17:46:11 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
# Link
|
2020-03-24 16:08:23 +00:00
|
|
|
$(BUILD)/$(OUT_FILE)-nosd.out: $(BUILD) $(OBJECTS)
|
|
|
|
@echo LD $(OUT_FILE)-nosd.out
|
2020-03-24 16:51:42 +00:00
|
|
|
$(QUIET)$(CC) -o $@ $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
size: $(BUILD)/$(OUT_FILE)-nosd.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-09 02:56:42 +00:00
|
|
|
#******************* Binary generator *******************
|
2019-02-22 16:55:01 +00:00
|
|
|
.phony: genhex genpkg
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
## Create binary .hex file from the .out file
|
2020-03-24 16:08:23 +00:00
|
|
|
genhex: $(BUILD)/$(OUT_FILE)-nosd.hex
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
$(BUILD)/$(OUT_FILE)-nosd.hex: $(BUILD)/$(OUT_FILE)-nosd.out
|
|
|
|
@echo CR $(OUT_FILE)-nosd.hex
|
2018-08-06 10:41:02 +00:00
|
|
|
$(QUIET)$(OBJCOPY) -O ihex $< $@
|
2018-08-27 07:16:19 +00:00
|
|
|
|
|
|
|
# merge bootloader and sd hex together
|
2020-03-24 16:08:23 +00:00
|
|
|
combinehex: $(BUILD)/$(MERGED_FILE).hex
|
2018-08-27 07:16:19 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_FILE)-nosd.hex
|
|
|
|
@echo CR $(MERGED_FILE).hex
|
2018-08-27 07:16:19 +00:00
|
|
|
@mergehex -q -m $< $(SD_HEX) -o $@
|
2018-08-06 10:41:02 +00:00
|
|
|
|
|
|
|
## Create pkg file for bootloader+SD combo to use with DFU
|
2020-03-24 16:08:23 +00:00
|
|
|
genpkg: $(BUILD)/$(MERGED_FILE).zip
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2020-03-24 16:08:23 +00:00
|
|
|
$(BUILD)/$(MERGED_FILE).zip: $(BUILD)/$(OUT_FILE)-nosd.hex
|
2018-09-06 17:46:11 +00:00
|
|
|
@$(NRFUTIL) dfu genpkg --dev-type 0x0052 --dev-revision $(DFU_DEV_REV) --bootloader $< --softdevice $(SD_HEX) $@
|