2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
2018-08-07 14:25:35 +00:00
|
|
|
# CONFIGURE
|
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_HEX : to bootloader hex binary
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
2018-12-19 10:23:06 +00:00
|
|
|
SRC_PATH = src
|
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
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
SD_VER1 = 6
|
|
|
|
SD_VER2 = 1
|
|
|
|
SD_VER3 = 1
|
2018-08-08 17:51:13 +00:00
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
SD_VERSION = $(SD_VER1).$(SD_VER2).$(SD_VER3)
|
|
|
|
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
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
|
2018-02-08 10:34:27 +00:00
|
|
|
|
2018-12-19 10:23:06 +00:00
|
|
|
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
|
2018-12-19 12:12:45 +00:00
|
|
|
RELEASE_DIR = bin/$(BOARD)
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-12-06 18:02:13 +00:00
|
|
|
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION)"
|
2018-08-06 10:41:02 +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" " -)
|
|
|
|
|
|
|
|
OUTPUT_FILENAME = $(BOARD)_bootloader-$(GIT_VERSION)
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Tool configure
|
|
|
|
#******************************************************************************
|
2018-08-21 07:14:23 +00:00
|
|
|
NRFUTIL = adafruit-nrfutil
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-07 09:51:08 +00:00
|
|
|
ifneq ($(JLINK),)
|
|
|
|
NRFJPROG = nrfjprog -s $(JLINK)
|
|
|
|
else
|
2018-09-06 17:46:11 +00:00
|
|
|
NRFJPROG = nrfjprog
|
2018-08-07 09:51:08 +00:00
|
|
|
endif
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
PROGFILES = C:/Program Files (x86)
|
2018-12-04 21:45:55 +00:00
|
|
|
GNU_INSTALL_ROOT = $(PROGFILES)/GNU Tools ARM Embedded/7 2018-q2-update/bin/
|
2018-02-07 16:32:49 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
MK := mkdir
|
|
|
|
RM := rm -rf
|
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
ifeq ("$(V)","2")
|
2018-09-06 17:46:11 +00:00
|
|
|
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
|
2018-12-04 21:45:55 +00:00
|
|
|
CC := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-gcc'
|
|
|
|
AS := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-as'
|
|
|
|
AR := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ar' -r
|
|
|
|
LD := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-ld'
|
|
|
|
NM := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-nm'
|
|
|
|
OBJDUMP := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objdump'
|
|
|
|
OBJCOPY := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-objcopy'
|
|
|
|
SIZE := '$(GNU_INSTALL_ROOT)$(GNU_PREFIX)-size'
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#function for removing duplicates in a list
|
|
|
|
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
|
|
|
|
2018-08-07 06:15:07 +00:00
|
|
|
#*********************************
|
|
|
|
# Select the board to build
|
|
|
|
#*********************************
|
2018-08-09 02:56:42 +00:00
|
|
|
BOARD_LIST = $(sort $(subst .h,,$(subst src/boards/,,$(wildcard src/boards/*.h))))
|
|
|
|
|
2018-12-04 21:45:55 +00:00
|
|
|
NRF52840_BOARDLIST = pca10056 pca10059 feather_nrf52840_express particle_argon particle_boron particle_xenon
|
2018-08-11 03:50:21 +00:00
|
|
|
IS_NRF52840 = $(filter $(BOARD),$(NRF52840_BOARDLIST))
|
2018-08-09 02:56:42 +00:00
|
|
|
|
2018-10-02 15:38:21 +00:00
|
|
|
ifeq ($(filter $(MAKECMDGOALS),all-board all-release help),)
|
2018-08-09 02:56:42 +00:00
|
|
|
ifeq ($(BOARD),)
|
|
|
|
$(info You must provide a BOARD parameter with 'BOARD=')
|
|
|
|
$(info Supported boards are: $(BOARD_LIST))
|
2018-10-02 15:38:21 +00:00
|
|
|
$(info Run 'make help' for usage)
|
2018-08-09 02:56:42 +00:00
|
|
|
$(error BOARD not defined)
|
|
|
|
else
|
2018-08-11 03:50:21 +00:00
|
|
|
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
2018-08-09 02:56:42 +00:00
|
|
|
$(error Invalid BOARD specified)
|
|
|
|
endif
|
2018-08-07 06:15:07 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
BUILD = _build-$(BOARD)
|
|
|
|
|
|
|
|
ifneq ($(IS_NRF52840),)
|
|
|
|
SD_NAME = s140
|
2018-08-09 05:37:39 +00:00
|
|
|
DFU_DEV_REV = 52840
|
2018-08-07 06:15:07 +00:00
|
|
|
else
|
|
|
|
SD_NAME = s132
|
2018-08-09 05:37:39 +00:00
|
|
|
DFU_DEV_REV = 0xADAF
|
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
|
|
|
|
2018-08-07 06:15:07 +00:00
|
|
|
# src
|
2018-02-07 16:32:49 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
2018-08-14 08:56:24 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/boards.c
|
2018-09-28 09:27:58 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/flash_nrf5x.c
|
2018-02-07 16:32:49 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
2018-08-09 05:37:39 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/dfu_init.c
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-07 06:33:44 +00:00
|
|
|
# nrfx
|
|
|
|
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
|
2018-08-07 14:34:26 +00:00
|
|
|
C_SOURCE_FILES += $(NRFX_PATH)/hal/nrf_nvmc.c
|
2018-08-07 06:33:44 +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_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-08-06 15:02:29 +00:00
|
|
|
ifneq ($(IS_NRF52840),)
|
|
|
|
|
2018-08-07 06:25:51 +00:00
|
|
|
# src
|
2018-08-16 11:17:42 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/usb_desc.c
|
2018-08-06 15:02:29 +00:00
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/usb.c
|
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
|
|
|
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
|
|
|
|
2018-08-07 06:25:51 +00:00
|
|
|
# nrfx
|
2018-08-07 06:15:07 +00:00
|
|
|
C_SOURCE_FILES += $(NRFX_PATH)/mdk/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-11-23 08:54:02 +00:00
|
|
|
C_SOURCE_FILES += $(TUSB_PATH)/device/usbd_control.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
|
|
|
|
2018-08-06 15:02:29 +00:00
|
|
|
else
|
|
|
|
|
|
|
|
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c
|
|
|
|
|
2018-08-07 07:32:46 +00:00
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/libraries/uart/app_uart.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/uart/nrf_drv_uart.c
|
|
|
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
|
|
|
|
2018-08-07 14:44:38 +00:00
|
|
|
IPATH += $(SDK11_PATH)/libraries/util
|
2018-08-07 07:32:46 +00:00
|
|
|
IPATH += $(SDK_PATH)/drivers_nrf/common
|
|
|
|
IPATH += $(SDK_PATH)/drivers_nrf/uart
|
2018-08-09 01:45:14 +00:00
|
|
|
|
2018-08-06 15:02:29 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
#******************************************************************************
|
|
|
|
# Assembly Files
|
|
|
|
#******************************************************************************
|
2018-08-07 06:15:07 +00:00
|
|
|
ifneq ($(IS_NRF52840),)
|
|
|
|
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52840.S
|
|
|
|
else
|
2018-08-07 07:32:46 +00:00
|
|
|
ASM_SOURCE_FILES = $(NRFX_PATH)/mdk/gcc_startup_nrf52.S
|
2018-08-07 06:15:07 +00:00
|
|
|
endif
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
#******************************************************************************
|
|
|
|
# INCLUDE PATH
|
|
|
|
#******************************************************************************
|
2018-08-07 06:15:07 +00:00
|
|
|
|
|
|
|
# src
|
2018-08-07 06:33:44 +00:00
|
|
|
IPATH += $(SRC_PATH)
|
2018-08-07 06:15:07 +00:00
|
|
|
IPATH += $(SRC_PATH)/cmsis/include
|
2018-08-06 15:02:29 +00:00
|
|
|
IPATH += $(SRC_PATH)/usb
|
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
|
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
|
|
|
|
#******************************************************************************
|
|
|
|
|
|
|
|
#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
|
2018-09-28 09:27:58 +00:00
|
|
|
CFLAGS += -fno-builtin --short-enums -fstack-usage
|
2018-02-07 16:32:49 +00:00
|
|
|
|
|
|
|
# Defined Symbol (MACROS)
|
2018-12-06 18:02:13 +00:00
|
|
|
CFLAGS += -DMK_BOOTLOADER_VERSION=0x0$(SD_VER1)0$(SD_VER2)0$(SD_VER3)UL
|
2018-08-06 15:02:29 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
CFLAGS += -D__HEAP_SIZE=0
|
|
|
|
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-12-06 18:02:13 +00:00
|
|
|
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS) $(SD_NAME) $(SD_VERSION)"'
|
2018-12-04 23:18:49 +00:00
|
|
|
|
2018-08-06 10:41:02 +00:00
|
|
|
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-08-06 15:02:29 +00:00
|
|
|
ifneq ($(IS_NRF52840),)
|
|
|
|
|
|
|
|
CFLAGS += -DNRF52840_XXAA
|
|
|
|
CFLAGS += -DS140
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
CFLAGS += -DNRF52
|
2018-10-02 09:55:55 +00:00
|
|
|
CFLAGS += -DNRF52832_XXAA
|
2018-08-06 15:02:29 +00:00
|
|
|
CFLAGS += -DS132
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
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-08-07 06:25:51 +00:00
|
|
|
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/linker -T$(LD_FILE)
|
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
|
|
|
|
ASMFLAGS += -D__HEAP_SIZE=0
|
|
|
|
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
|
|
|
|
2018-08-07 06:25:51 +00:00
|
|
|
ifneq ($(IS_NRF52840),)
|
|
|
|
|
|
|
|
ASMFLAGS += -DNRF52840_XXAA
|
|
|
|
ASMFLAGS += -DS140
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ASMFLAGS += -DNRF52
|
|
|
|
ASMFLAGS += -DS132
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
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-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
|
2018-12-05 06:54:45 +00:00
|
|
|
all: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out size
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-11 04:25:13 +00:00
|
|
|
# Rule using BOARD_LIST, nl is newline
|
|
|
|
define nl
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
_make_board = $(MAKE) -s -f $(MAKEFILE_LIST) -e BOARD=$1 $2 $(nl)
|
|
|
|
_make_all_board = $(foreach b,$(BOARD_LIST), $(call _make_board,$b,$1))
|
2018-08-11 03:50:21 +00:00
|
|
|
|
2018-08-09 02:56:42 +00:00
|
|
|
# build all the boards
|
|
|
|
all-board:
|
2018-08-11 04:25:13 +00:00
|
|
|
$(call _make_all_board,clean all)
|
2018-08-09 02:56:42 +00:00
|
|
|
|
|
|
|
all-release:
|
2018-08-11 04:25:13 +00:00
|
|
|
$(call _make_all_board,clean all release)
|
2018-12-04 21:45:55 +00:00
|
|
|
|
2018-10-02 15:38:21 +00:00
|
|
|
help:
|
2018-10-02 16:15:43 +00:00
|
|
|
@echo To flash (with jlink) a pre-built binary with a specific version to a board
|
2018-11-09 15:29:59 +00:00
|
|
|
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 flash
|
2018-10-02 15:38:21 +00:00
|
|
|
@echo
|
2018-10-02 16:15:43 +00:00
|
|
|
@echo To flash (with dfu) a pre-built binary with a specific version to a board
|
2018-11-09 15:29:59 +00:00
|
|
|
@echo $$ make BOARD=feather_nrf52840_express VERSION=6.1.1r0 SERIAL=/dev/ttyACM0 dfu0-flash
|
2018-10-02 16:15:43 +00:00
|
|
|
@echo
|
2018-10-02 15:38:21 +00:00
|
|
|
@echo To compile and build the current code for a board
|
|
|
|
@echo $$ make BOARD=feather_nrf52840_express all
|
|
|
|
@echo
|
|
|
|
@echo To flash current code using jlink
|
|
|
|
@echo $$ make BOARD=feather_nrf52840_express flash
|
|
|
|
@echo
|
|
|
|
@echo To flash current code using existing bootloader dfu
|
2018-10-02 16:15:43 +00:00
|
|
|
@echo $$ make BOARD=feather_nrf52840_express SERIAL=/dev/ttyACM0 dfu-flash
|
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))))
|
|
|
|
|
|
|
|
ifeq ($(VERSION),)
|
|
|
|
|
|
|
|
# Flash the compiled
|
2018-12-05 17:18:12 +00:00
|
|
|
flash: $(BUILD)/$(OUTPUT_FILENAME)-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
|
|
|
|
2018-08-10 14:43:14 +00:00
|
|
|
dfu-flash: $(BUILD)/$(MERGED_FNAME).zip
|
|
|
|
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
2018-09-06 17:46:11 +00:00
|
|
|
$(NRFUTIL) --verbose dfu serial --package $< -p $(SERIAL) -b 115200 --singlebank
|
2018-08-10 14:43:14 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
|
2018-08-21 09:19:16 +00:00
|
|
|
ifeq ($(VERSION),latest)
|
|
|
|
VERSION_FPATH = $(RELEASE_DIR)/$(MERGED_FNAME)
|
|
|
|
else
|
2018-08-10 14:43:14 +00:00
|
|
|
VERSION_FPATH = bin/$(BOARD)/$(VERSION)/$(OUTPUT_FILENAME)_$(SD_NAME)_$(VERSION)
|
2018-08-21 09:19:16 +00:00
|
|
|
endif
|
2018-08-10 14:43:14 +00:00
|
|
|
|
|
|
|
# Flash specific version in binary release folder
|
|
|
|
flash:
|
|
|
|
@echo Flashing: $(VERSION_FPATH).hex
|
2018-08-21 09:19:16 +00:00
|
|
|
$(NRFJPROG) --program $(VERSION_FPATH).hex --chiperase -f nrf52 --reset
|
2018-09-06 17:46:11 +00:00
|
|
|
|
2018-08-10 14:43:14 +00:00
|
|
|
dfu-flash:
|
|
|
|
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
2018-09-06 17:46:11 +00:00
|
|
|
$(NRFUTIL) --verbose dfu serial --package $(VERSION_FPATH).zip -p $(SERIAL) -b 115200 --singlebank
|
|
|
|
|
2018-08-10 14:43:14 +00:00
|
|
|
endif
|
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
|
|
|
|
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 $<)
|
|
|
|
$(QUIET)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $@ $<
|
2018-09-06 17:46:11 +00:00
|
|
|
|
2018-02-07 16:32:49 +00:00
|
|
|
# Link
|
2018-12-05 00:03:33 +00:00
|
|
|
$(BUILD)/$(OUTPUT_FILENAME)-nosd.out: $(BUILD) $(OBJECTS)
|
|
|
|
@echo LD $(OUTPUT_FILENAME)-nosd.out
|
|
|
|
$(QUIET)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -lm -o $@
|
2018-02-07 16:32:49 +00:00
|
|
|
|
2018-12-05 00:03:33 +00:00
|
|
|
size: $(BUILD)/$(OUTPUT_FILENAME)-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 *******************
|
2018-08-10 14:43:14 +00:00
|
|
|
.phony: genhex genpkg 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
|
2018-12-05 17:18:12 +00:00
|
|
|
genhex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-12-05 00:03:33 +00:00
|
|
|
$(BUILD)/$(OUTPUT_FILENAME)-nosd.hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.out
|
|
|
|
@echo CR $(OUTPUT_FILENAME)-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
|
|
|
|
combinehex: $(BUILD)/$(MERGED_FNAME).hex
|
|
|
|
|
2018-12-05 00:03:33 +00:00
|
|
|
$(BUILD)/$(MERGED_FNAME).hex: $(BUILD)/$(OUTPUT_FILENAME)-nosd.hex
|
2018-08-27 07:16:19 +00:00
|
|
|
@echo CR $(MERGED_FNAME).hex
|
|
|
|
@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
|
2018-08-10 14:43:14 +00:00
|
|
|
genpkg: $(BUILD)/$(MERGED_FNAME).zip
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-12-05 00:03:33 +00:00
|
|
|
$(BUILD)/$(MERGED_FNAME).zip: $(BUILD)/$(OUTPUT_FILENAME)-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) $@
|
2018-08-06 10:41:02 +00:00
|
|
|
|
2018-08-09 02:56:42 +00:00
|
|
|
# Create SD+bootloader combo with hex & dfu package at release folder
|
2018-08-27 07:16:19 +00:00
|
|
|
release: combinehex genpkg
|
2018-08-10 14:43:14 +00:00
|
|
|
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).hex
|
|
|
|
@echo CR $(RELEASE_DIR)/$(MERGED_FNAME).zip
|
2018-08-06 10:41:02 +00:00
|
|
|
@mkdir -p $(RELEASE_DIR)
|
2018-08-10 14:43:14 +00:00
|
|
|
@cp $(BUILD)/$(MERGED_FNAME).hex $(RELEASE_DIR)/$(MERGED_FNAME).hex
|
|
|
|
@cp $(BUILD)/$(MERGED_FNAME).zip $(RELEASE_DIR)/$(MERGED_FNAME).zip
|