2018-07-06 03:39:49 -04: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 /.,,$(subst boards/,,$(wildcard boards/*/.)))))
|
|
|
|
$(error BOARD not defined)
|
|
|
|
else
|
|
|
|
ifeq ($(wildcard boards/$(BOARD)/.),)
|
|
|
|
$(error Invalid BOARD specified)
|
|
|
|
endif
|
2016-11-16 15:38:25 -05:00
|
|
|
endif
|
|
|
|
|
2018-07-11 14:37:23 -04:00
|
|
|
include boards/$(BOARD)/mpconfigboard.mk
|
|
|
|
|
2016-11-16 15:38:25 -05:00
|
|
|
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
2018-07-09 15:02:52 -04:00
|
|
|
# Build directory with SD
|
2018-07-11 14:37:23 -04:00
|
|
|
BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
|
2017-12-22 05:29:39 -05:00
|
|
|
|
2018-06-20 15:21:45 -04:00
|
|
|
include ../../py/mkenv.mk
|
|
|
|
-include mpconfigport.mk
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2018-06-20 15:21:45 -04:00
|
|
|
ifneq ($(SD), )
|
2017-05-11 12:53:53 -04:00
|
|
|
include drivers/bluetooth/bluetooth_common.mk
|
2016-11-16 15:38:25 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
2018-02-12 16:33:01 -05:00
|
|
|
QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2017-02-25 19:30:33 -05:00
|
|
|
FROZEN_MPY_DIR = freeze
|
2016-11-16 15:38:25 -05:00
|
|
|
|
|
|
|
# include py core make definitions
|
2017-10-04 15:54:01 -04:00
|
|
|
include ../../py/py.mk
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
include $(TOP)/supervisor/supervisor.mk
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2017-02-07 17:30:12 -05:00
|
|
|
FATFS_DIR = lib/oofatfs
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2016-11-16 15:38:25 -05:00
|
|
|
CROSS_COMPILE = arm-none-eabi-
|
|
|
|
|
2016-12-13 14:27:26 -05:00
|
|
|
INC += -I.
|
2017-10-04 15:54:01 -04:00
|
|
|
INC += -I../..
|
2016-11-16 15:38:25 -05:00
|
|
|
INC += -I$(BUILD)
|
2018-02-12 16:33:01 -05:00
|
|
|
INC += -I$(BUILD)/genhdr
|
2017-10-04 15:54:01 -04:00
|
|
|
INC += -I./../../lib/cmsis/inc
|
2018-06-20 12:15:34 -04:00
|
|
|
INC += -I./boards/$(BOARD)
|
2017-02-10 15:03:30 -05:00
|
|
|
INC += -I./modules/ubluepy
|
2017-05-11 12:34:12 -04:00
|
|
|
INC += -I./modules/ble
|
2018-06-25 17:33:39 -04:00
|
|
|
INC += -I./nrfx
|
|
|
|
INC += -I./nrfx/hal
|
|
|
|
INC += -I./nrfx/mdk
|
|
|
|
INC += -I./nrfx/drivers/include
|
2017-10-04 15:54:01 -04:00
|
|
|
INC += -I../../lib/mp-readline
|
2017-05-11 12:53:53 -04:00
|
|
|
INC += -I./drivers/bluetooth
|
2017-05-16 19:05:41 -04:00
|
|
|
INC += -I./drivers
|
2018-07-04 05:40:53 -04:00
|
|
|
INC += -I../../lib/tinyusb/src
|
|
|
|
INC += -I./usb
|
2016-11-16 15:38:25 -05:00
|
|
|
|
|
|
|
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
|
|
|
|
|
2018-06-20 12:15:34 -04:00
|
|
|
CFLAGS += -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
|
|
|
|
CFLAGS += -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
2017-02-07 17:30:12 -05:00
|
|
|
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
|
2016-12-13 14:27:26 -05:00
|
|
|
CFLAGS += -fno-strict-aliasing
|
2018-07-02 16:00:04 -04:00
|
|
|
CFLAGS += -fstack-usage -fno-builtin -fshort-enums
|
2017-10-11 18:44:24 -04:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2018-06-20 14:43:59 -04:00
|
|
|
CFLAGS += -D__START=main
|
2016-11-16 15:38:25 -05:00
|
|
|
|
|
|
|
LDFLAGS = $(CFLAGS)
|
|
|
|
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
|
2016-12-13 14:27:26 -05:00
|
|
|
LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
|
2017-10-11 18:44:24 -04:00
|
|
|
LDFLAGS += -Wl,--gc-sections
|
2016-11-16 15:38:25 -05:00
|
|
|
|
|
|
|
#Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
2016-12-13 14:27:26 -05:00
|
|
|
#ASMFLAGS += -g -gtabs+
|
2018-02-12 16:50:07 -05:00
|
|
|
CFLAGS += -O1 -ggdb
|
|
|
|
LDFLAGS += -O1
|
2016-11-16 15:38:25 -05:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
|
|
|
LDFLAGS += -Os
|
|
|
|
endif
|
|
|
|
|
2017-07-17 18:18:05 -04:00
|
|
|
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
|
|
|
|
LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
|
|
|
|
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
|
|
|
|
2018-06-20 12:15:34 -04:00
|
|
|
LIBS := -L $(dir $(LIBM_FILE_NAME)) -lm
|
2017-07-17 18:18:05 -04:00
|
|
|
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
|
|
|
|
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2018-06-25 17:33:39 -04:00
|
|
|
SRC_NRFX = $(addprefix nrfx/,\
|
2018-07-09 15:02:52 -04:00
|
|
|
drivers/src/nrfx_power.c \
|
2018-06-25 17:33:39 -04:00
|
|
|
drivers/src/nrfx_spim.c \
|
2018-06-28 16:45:02 -04:00
|
|
|
drivers/src/nrfx_twim.c \
|
2018-07-08 09:17:06 -04:00
|
|
|
drivers/src/nrfx_uart.c \
|
2016-11-16 15:38:25 -05:00
|
|
|
)
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2016-11-16 17:39:40 -05:00
|
|
|
SRC_C += \
|
2016-11-16 15:38:25 -05:00
|
|
|
mphalport.c \
|
2016-12-13 14:27:26 -05:00
|
|
|
fatfs_port.c \
|
2018-02-03 11:08:51 -05:00
|
|
|
tick.c \
|
2018-07-10 11:49:51 -04:00
|
|
|
background.c \
|
|
|
|
internal_flash.c \
|
2017-05-11 12:53:53 -04:00
|
|
|
drivers/bluetooth/ble_drv.c \
|
|
|
|
drivers/bluetooth/ble_uart.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
boards/$(BOARD)/board.c \
|
2018-06-20 14:43:59 -04:00
|
|
|
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
|
2018-07-05 04:22:23 -04:00
|
|
|
nrfx/hal/nrf_nvmc.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
|
|
|
|
lib/oofatfs/ff.c \
|
|
|
|
lib/oofatfs/option/ccsbcs.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
lib/timeutils/timeutils.c \
|
|
|
|
lib/utils/buffer_helper.c \
|
|
|
|
lib/utils/context_manager_helpers.c \
|
|
|
|
lib/utils/interrupt_char.c \
|
|
|
|
lib/utils/pyexec.c \
|
2018-07-09 15:02:52 -04:00
|
|
|
lib/utils/stdout_helpers.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
lib/libc/string0.c \
|
|
|
|
lib/mp-readline/readline.c \
|
2018-07-04 06:15:49 -04:00
|
|
|
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
|
|
|
|
|
|
|
SRC_C += \
|
|
|
|
usb/tusb_descriptors.c \
|
|
|
|
usb/usb_msc_flash.c \
|
2018-07-10 11:49:51 -04:00
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
|
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \
|
|
|
|
lib/tinyusb/src/common/tusb_fifo.c \
|
|
|
|
lib/tinyusb/src/device/usbd.c \
|
|
|
|
lib/tinyusb/src/device/usbd_desc.c \
|
|
|
|
lib/tinyusb/src/class/msc/msc_device.c \
|
|
|
|
lib/tinyusb/src/class/cdc/cdc_device.c \
|
|
|
|
lib/tinyusb/src/tusb.c \
|
2018-07-13 09:17:30 -04:00
|
|
|
|
2018-07-04 06:15:49 -04:00
|
|
|
endif
|
2017-12-22 05:29:39 -05:00
|
|
|
|
2017-02-04 17:51:11 -05:00
|
|
|
DRIVERS_SRC_C += $(addprefix modules/,\
|
2017-02-07 18:05:37 -05:00
|
|
|
ubluepy/modubluepy.c \
|
|
|
|
ubluepy/ubluepy_peripheral.c \
|
|
|
|
ubluepy/ubluepy_service.c \
|
|
|
|
ubluepy/ubluepy_characteristic.c \
|
|
|
|
ubluepy/ubluepy_uuid.c \
|
2017-02-14 18:17:47 -05:00
|
|
|
ubluepy/ubluepy_delegate.c \
|
2017-02-17 18:11:10 -05:00
|
|
|
ubluepy/ubluepy_constants.c \
|
2017-02-18 16:49:50 -05:00
|
|
|
ubluepy/ubluepy_descriptor.c \
|
2017-03-12 18:24:20 -04:00
|
|
|
ubluepy/ubluepy_scanner.c \
|
|
|
|
ubluepy/ubluepy_scan_entry.c \
|
2017-01-04 11:13:19 -05:00
|
|
|
)
|
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
SRC_COMMON_HAL += \
|
2017-12-22 05:29:39 -05:00
|
|
|
board/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
digitalio/__init__.c \
|
|
|
|
digitalio/DigitalInOut.c \
|
|
|
|
microcontroller/__init__.c \
|
|
|
|
microcontroller/Pin.c \
|
|
|
|
microcontroller/Processor.c \
|
|
|
|
os/__init__.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
time/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
analogio/__init__.c \
|
|
|
|
analogio/AnalogIn.c \
|
|
|
|
analogio/AnalogOut.c \
|
|
|
|
busio/__init__.c\
|
|
|
|
busio/I2C.c \
|
|
|
|
busio/SPI.c \
|
2018-02-21 22:52:33 -05:00
|
|
|
busio/UART.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
pulseio/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
pulseio/PulseIn.c \
|
|
|
|
pulseio/PulseOut.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
pulseio/PWMOut.c \
|
|
|
|
storage/__init__.c \
|
2018-06-20 12:15:34 -04:00
|
|
|
supervisor/__init__.c \
|
|
|
|
supervisor/Runtime.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2018-07-08 15:13:05 -04:00
|
|
|
ifneq ($(SD), )
|
|
|
|
SRC_COMMON_HAL += \
|
|
|
|
bleio/__init__.c \
|
|
|
|
bleio/Adapter.c
|
|
|
|
endif
|
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
# These don't have corresponding files in each port but are still located in
|
|
|
|
# shared-bindings to make it clear what the contents of the modules are.
|
|
|
|
SRC_BINDINGS_ENUMS = \
|
2018-02-21 22:52:33 -05:00
|
|
|
busio/OneWire.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
digitalio/Direction.c \
|
|
|
|
digitalio/DriveMode.c \
|
|
|
|
digitalio/Pull.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
microcontroller/RunMode.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
help.c \
|
|
|
|
math/__init__.c \
|
|
|
|
util.c
|
|
|
|
|
|
|
|
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
|
|
|
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
|
|
|
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
|
|
|
|
|
|
|
SRC_SHARED_MODULE = \
|
2018-01-03 16:50:57 -05:00
|
|
|
os/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
random/__init__.c \
|
|
|
|
storage/__init__.c \
|
2018-02-03 14:20:53 -05:00
|
|
|
struct/__init__.c \
|
2018-02-03 11:08:51 -05:00
|
|
|
gamepad/__init__.c \
|
2018-02-06 18:03:00 -05:00
|
|
|
gamepad/GamePad.c \
|
|
|
|
bitbangio/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
bitbangio/I2C.c \
|
|
|
|
bitbangio/OneWire.c \
|
2018-02-21 22:52:33 -05:00
|
|
|
bitbangio/SPI.c \
|
|
|
|
busio/OneWire.c \
|
2018-02-06 18:03:00 -05:00
|
|
|
|
2018-02-21 22:52:33 -05:00
|
|
|
# uheap/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
ustack/__init__.c
|
|
|
|
|
2018-02-03 11:08:51 -05:00
|
|
|
SRC_SHARED_BINDINGS = \
|
2018-02-03 14:20:53 -05:00
|
|
|
struct/__init__.c \
|
2018-02-03 11:08:51 -05:00
|
|
|
gamepad/__init__.c \
|
2018-02-06 18:03:00 -05:00
|
|
|
gamepad/GamePad.c \
|
|
|
|
bitbangio/__init__.c \
|
|
|
|
bitbangio/I2C.c \
|
|
|
|
bitbangio/SPI.c \
|
2018-07-08 12:38:47 -04:00
|
|
|
bitbangio/OneWire.c \
|
|
|
|
random/__init__.c
|
2018-02-06 18:03:00 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2018-02-03 11:08:51 -05:00
|
|
|
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_BINDINGS)) \
|
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE))
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2018-07-03 10:25:54 -04:00
|
|
|
SRC_S = supervisor/cpu.s
|
|
|
|
|
2016-12-13 14:27:26 -05:00
|
|
|
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
|
|
|
|
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2018-02-12 16:33:01 -05:00
|
|
|
OBJ += $(BUILD)/pins_gen.o
|
2018-06-25 17:33:39 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o))
|
2017-01-04 11:13:19 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
2017-12-21 07:49:14 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
|
2018-07-03 10:25:54 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2016-12-13 14:27:26 -05:00
|
|
|
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
|
|
|
|
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
|
|
|
|
|
2018-06-27 04:22:44 -04:00
|
|
|
.phony: all flash sd binary hex bootloader
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2018-07-09 14:02:33 -04:00
|
|
|
all: binary hex uf2
|
2017-02-25 19:52:46 -05:00
|
|
|
|
|
|
|
OUTPUT_FILENAME = firmware
|
|
|
|
|
|
|
|
## Create binary .bin file from the .out file
|
|
|
|
binary: $(BUILD)/$(OUTPUT_FILENAME).bin
|
|
|
|
|
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).bin: $(BUILD)/$(OUTPUT_FILENAME).elf
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
## Create binary .hex file from the .out file
|
|
|
|
hex: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
|
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).hex: $(BUILD)/$(OUTPUT_FILENAME).elf
|
|
|
|
$(OBJCOPY) -O ihex $< $@
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2018-06-27 03:31:08 -04:00
|
|
|
#####################
|
|
|
|
# Flash with debugger
|
|
|
|
#####################
|
2017-01-03 11:00:06 -05:00
|
|
|
FLASHER ?=
|
|
|
|
|
|
|
|
ifeq ($(FLASHER),)
|
|
|
|
|
2018-06-27 04:22:44 -04:00
|
|
|
# Also update to bootloader settting to validate application and skip checksum ( app valid = 0x0001, crc = 0x0000 )
|
2018-06-08 04:11:17 -04:00
|
|
|
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
nrfjprog --program $< --sectorerase -f $(MCU_VARIANT)
|
|
|
|
nrfjprog --erasepage $(BOOT_SETTING_ADDR) -f $(MCU_VARIANT)
|
|
|
|
nrfjprog --memwr $(BOOT_SETTING_ADDR) --val 0x00000001 -f $(MCU_VARIANT)
|
|
|
|
nrfjprog --reset -f $(MCU_VARIANT)
|
|
|
|
|
2017-02-25 19:52:46 -05:00
|
|
|
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
2016-12-13 14:27:26 -05:00
|
|
|
nrfjprog --eraseall -f $(MCU_VARIANT)
|
|
|
|
nrfjprog --program $(SOFTDEV_HEX) -f $(MCU_VARIANT)
|
2017-02-25 19:52:46 -05:00
|
|
|
nrfjprog --program $< --sectorerase -f $(MCU_VARIANT)
|
2017-01-08 09:17:03 -05:00
|
|
|
nrfjprog --reset -f $(MCU_VARIANT)
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2018-06-27 04:22:44 -04:00
|
|
|
bootloader:
|
|
|
|
nrfjprog --program $(BOOT_FILE).hex -f nrf52 --chiperase --reset
|
2018-07-13 09:17:30 -04:00
|
|
|
|
2017-01-03 11:00:06 -05:00
|
|
|
else ifeq ($(FLASHER), pyocd)
|
|
|
|
|
2017-02-25 19:52:46 -05:00
|
|
|
flash: $(BUILD)/$(OUTPUT_FILENAME).hex
|
2018-07-13 09:17:30 -04:00
|
|
|
pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase
|
|
|
|
pyocd-tool -t $(MCU_SUB_VARIANT) erase $(BOOT_SETTING_ADDR)
|
|
|
|
pyocd-tool -t $(MCU_SUB_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
|
|
|
|
pyocd-tool -t $(MCU_SUB_VARIANT) reset
|
2017-01-03 11:00:06 -05:00
|
|
|
|
2017-02-25 19:52:46 -05:00
|
|
|
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
2018-07-13 09:17:30 -04:00
|
|
|
pyocd-flashtool -t $(MCU_SUB_VARIANT) --chip_erase
|
|
|
|
pyocd-flashtool -t $(MCU_SUB_VARIANT) $(SOFTDEV_HEX)
|
|
|
|
pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase
|
|
|
|
pyocd-tool -t $(MCU_SUB_VARIANT) reset $(BOOT_SETTING_ADDR)
|
|
|
|
|
|
|
|
bootloader:
|
|
|
|
pyocd-flashtool -t $(MCU_SUB_VARIANT) $(BOOT_FILE).hex --chip_erase
|
|
|
|
pyocd-tool -t $(MCU_SUB_VARIANT) reset
|
2017-02-16 17:18:07 -05:00
|
|
|
|
2017-01-03 11:00:06 -05:00
|
|
|
endif
|
|
|
|
|
2018-06-27 03:31:08 -04:00
|
|
|
#####################
|
|
|
|
# Flash with DFU
|
|
|
|
#####################
|
2018-07-09 14:02:33 -04:00
|
|
|
.phony: dfu-gen dfu-flash dfu-bootloader
|
2018-06-27 03:31:08 -04:00
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
NRFUTIL = ../../lib/nrfutil/binaries/win32/nrfutil.exe
|
|
|
|
else
|
|
|
|
NRFUTIL = nrfutil
|
|
|
|
endif
|
|
|
|
|
|
|
|
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))))
|
|
|
|
|
2018-06-27 04:11:50 -04:00
|
|
|
dfu-gen: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2018-06-27 04:11:50 -04:00
|
|
|
dfu-flash: $(BUILD)/dfu-package.zip
|
2018-06-27 03:31:08 -04:00
|
|
|
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
|
2018-06-27 04:11:50 -04:00
|
|
|
$(NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank
|
2018-06-27 03:31:08 -04:00
|
|
|
|
|
|
|
dfu-bootloader:
|
|
|
|
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
|
|
|
|
$(NRFUTIL) --verbose dfu serial --package $(BOOT_FILE).zip -p $(SERIAL) -b 115200
|
|
|
|
|
2018-06-27 04:11:50 -04:00
|
|
|
uf2: $(BUILD)/$(OUTPUT_FILENAME).hex
|
2018-06-27 03:31:08 -04:00
|
|
|
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
|
2018-07-09 14:18:14 -04:00
|
|
|
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2018-06-27 04:11:50 -04:00
|
|
|
$(BUILD)/dfu-package.zip: dfu-gen
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2017-02-25 19:52:46 -05:00
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
|
2016-11-16 15:38:25 -05:00
|
|
|
$(ECHO) "LINK $@"
|
2017-12-21 07:49:14 -05:00
|
|
|
$(Q)$(CC) $(LDFLAGS) -o $@ $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
|
2016-11-16 15:38:25 -05:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2016-12-13 14:27:26 -05:00
|
|
|
# List of sources for qstr extraction
|
2017-12-21 07:49:14 -05:00
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(DRIVERS_SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2016-12-13 14:27:26 -05:00
|
|
|
# Append any auto-generated sources that are needed by sources listed in
|
|
|
|
# SRC_QSTR
|
|
|
|
SRC_QSTR_AUTO_DEPS +=
|
|
|
|
|
|
|
|
# Making OBJ use an order-only depenedency on the generated pins.h file
|
|
|
|
# has the side effect of making the pins.h file before we actually compile
|
|
|
|
# any of the objects. The normal dependency generation will deal with the
|
|
|
|
# case when pins.h is modified. But when it doesn't exist, we don't know
|
|
|
|
# which source files might need it.
|
2018-02-12 16:33:01 -05:00
|
|
|
$(OBJ): | $(HEADER_BUILD)/pins.h
|
2016-12-13 14:27:26 -05:00
|
|
|
|
|
|
|
# Use a pattern rule here so that make will only call make-pins.py once to make
|
2018-06-20 17:26:32 -04:00
|
|
|
# both pins_g.c and pins.h
|
|
|
|
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h $(BUILD)/%_qstr.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
|
2018-02-12 16:33:01 -05:00
|
|
|
$(ECHO) "Create $@"
|
2018-06-20 17:26:32 -04:00
|
|
|
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) > $(GEN_PINS_SRC)
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2018-02-12 16:33:01 -05:00
|
|
|
$(BUILD)/pins_gen.o: $(BUILD)/pins_gen.c
|
|
|
|
$(call compile_c)
|
2016-12-13 14:27:26 -05:00
|
|
|
|
|
|
|
MAKE_PINS = boards/make-pins.py
|
|
|
|
BOARD_PINS = boards/$(BOARD)/pins.csv
|
|
|
|
AF_FILE = $(MCU_VARIANT)_af.csv
|
|
|
|
PREFIX_FILE = boards/$(MCU_VARIANT)_prefix.c
|
|
|
|
GEN_PINS_SRC = $(BUILD)/pins_gen.c
|
|
|
|
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
|
|
|
|
GEN_PINS_QSTR = $(BUILD)/pins_qstr.h
|
|
|
|
|
2017-01-22 16:18:44 -05:00
|
|
|
ifneq ($(FROZEN_DIR),)
|
|
|
|
# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
|
|
|
|
# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
|
|
endif
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2017-01-22 16:18:44 -05:00
|
|
|
ifneq ($(FROZEN_MPY_DIR),)
|
|
|
|
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
|
|
|
|
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
|
|
|
|
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
|
|
|
endif
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
include $(TOP)/py/mkrules.mk
|