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-11-28 19:58:44 -05:00
|
|
|
CLI_SD := $(SD)
|
|
|
|
|
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-11-28 19:58:44 -05:00
|
|
|
# Build directory with SD if it's different from the default.
|
|
|
|
BUILD ?= $(if $(CLI_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), )
|
2018-07-22 10:23:04 -04:00
|
|
|
include bluetooth/bluetooth_common.mk
|
2016-11-16 15:38:25 -05:00
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
ifneq ($(MCU_SUB_VARIANT),nrf52840)
|
|
|
|
USB = FALSE
|
|
|
|
endif
|
|
|
|
|
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
|
2018-08-31 15:34:01 -04:00
|
|
|
INC += -I./bluetooth
|
|
|
|
INC += -I./peripherals
|
2017-10-04 15:54:01 -04:00
|
|
|
INC += -I../../lib/mp-readline
|
2018-07-04 05:40:53 -04:00
|
|
|
INC += -I../../lib/tinyusb/src
|
2018-10-19 21:46:22 -04:00
|
|
|
INC += -I../../supervisor/shared/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
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
# TinyUSB defines
|
2018-11-16 20:04:42 -05:00
|
|
|
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
|
2018-10-19 21:46:22 -04:00
|
|
|
|
2016-11-16 15:38:25 -05:00
|
|
|
#Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
2018-12-27 00:04:04 -05:00
|
|
|
#ASMFLAGS += -g -gtabs+
|
|
|
|
CFLAGS += -O1 -ggdb
|
|
|
|
LDFLAGS += -O1
|
|
|
|
# You may want to enable these flags to make setting breakpoints easier.
|
|
|
|
CFLAGS += -fno-inline -fno-ipa-sra
|
2016-11-16 15:38:25 -05:00
|
|
|
else
|
2018-12-27 00:04:04 -05:00
|
|
|
CFLAGS += -Os -DNDEBUG
|
|
|
|
LDFLAGS += -Os
|
2016-11-16 15:38:25 -05:00
|
|
|
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-10-16 11:05:02 -04:00
|
|
|
drivers/src/nrfx_timer.c \
|
2018-06-28 16:45:02 -04:00
|
|
|
drivers/src/nrfx_twim.c \
|
2018-09-24 03:37:28 -04:00
|
|
|
drivers/src/nrfx_uarte.c \
|
2018-12-18 10:05:17 -05:00
|
|
|
drivers/src/nrfx_gpiote.c \
|
2016-11-16 15:38:25 -05:00
|
|
|
)
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
ifdef EXTERNAL_FLASH_DEVICES
|
|
|
|
ifeq ($(QSPI_FLASH_FILESYSTEM),1)
|
|
|
|
SRC_NRFX += nrfx/drivers/src/nrfx_qspi.c
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2016-11-16 17:39:40 -05:00
|
|
|
SRC_C += \
|
2018-07-10 11:49:51 -04:00
|
|
|
background.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
fatfs_port.c \
|
|
|
|
mphalport.c \
|
|
|
|
tick.c \
|
2018-01-03 16:50:57 -05:00
|
|
|
boards/$(BOARD)/board.c \
|
2018-08-30 21:42:25 -04:00
|
|
|
boards/$(BOARD)/pins.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
|
2018-08-31 15:34:01 -04:00
|
|
|
bluetooth/ble_drv.c \
|
|
|
|
bluetooth/ble_uart.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
lib/libc/string0.c \
|
|
|
|
lib/mp-readline/readline.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
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 \
|
2018-07-31 03:28:34 -04:00
|
|
|
lib/utils/interrupt_char.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
lib/utils/pyexec.c \
|
2018-07-09 15:02:52 -04:00
|
|
|
lib/utils/stdout_helpers.c \
|
2018-07-31 23:19:20 -04:00
|
|
|
lib/utils/sys_stdio_mphal.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
nrfx/hal/nrf_nvmc.c \
|
|
|
|
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
|
2018-09-09 15:01:28 -04:00
|
|
|
peripherals/nrf/cache.c \
|
|
|
|
peripherals/nrf/clocks.c \
|
2018-08-30 21:42:25 -04:00
|
|
|
peripherals/nrf/$(MCU_CHIP)/pins.c \
|
2018-09-09 15:01:28 -04:00
|
|
|
peripherals/nrf/$(MCU_CHIP)/power.c \
|
2018-10-16 11:05:02 -04:00
|
|
|
peripherals/nrf/timers.c \
|
2019-01-19 19:45:35 -05:00
|
|
|
sd_mutex.c \
|
2018-08-02 17:35:46 -04:00
|
|
|
supervisor/shared/memory.c
|
2018-07-04 06:15:49 -04:00
|
|
|
|
2017-01-04 11:13:19 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
SRC_COMMON_HAL += \
|
|
|
|
analogio/AnalogIn.c \
|
|
|
|
analogio/AnalogOut.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
analogio/__init__.c \
|
|
|
|
board/__init__.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
busio/I2C.c \
|
|
|
|
busio/SPI.c \
|
2018-02-21 22:52:33 -05:00
|
|
|
busio/UART.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
busio/__init__.c\
|
|
|
|
digitalio/DigitalInOut.c \
|
|
|
|
digitalio/__init__.c \
|
2019-01-17 18:15:59 -05:00
|
|
|
displayio/ParallelBus.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
microcontroller/Pin.c \
|
|
|
|
microcontroller/Processor.c \
|
|
|
|
microcontroller/__init__.c \
|
2018-08-30 21:42:25 -04:00
|
|
|
neopixel_write/__init__.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
os/__init__.c \
|
|
|
|
pulseio/PWMOut.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
pulseio/PulseIn.c \
|
|
|
|
pulseio/PulseOut.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
pulseio/__init__.c \
|
2019-02-04 21:26:36 -05:00
|
|
|
rotaryio/__init__.c \
|
|
|
|
rotaryio/IncrementalEncoder.c \
|
2018-06-20 12:15:34 -04:00
|
|
|
supervisor/Runtime.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
supervisor/__init__.c \
|
|
|
|
time/__init__.c \
|
2018-12-03 23:28:48 -05:00
|
|
|
touchio/__init__.c \
|
|
|
|
touchio/TouchIn.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 \
|
2018-07-16 08:44:20 -04:00
|
|
|
bleio/Adapter.c \
|
2018-12-28 22:55:29 -05:00
|
|
|
bleio/Broadcaster.c \
|
2018-07-18 17:47:06 -04:00
|
|
|
bleio/Characteristic.c \
|
2019-01-07 22:46:20 -05:00
|
|
|
bleio/CharacteristicBuffer.c \
|
2018-07-16 10:31:28 -04:00
|
|
|
bleio/Descriptor.c \
|
2018-12-29 13:55:10 -05:00
|
|
|
bleio/Peripheral.c \
|
2018-07-18 04:22:11 -04:00
|
|
|
bleio/Scanner.c \
|
2018-07-18 19:01:41 -04:00
|
|
|
bleio/Service.c \
|
2018-07-16 08:44:20 -04:00
|
|
|
bleio/UUID.c
|
2018-07-08 15:13:05 -04:00
|
|
|
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 \
|
2019-02-06 15:13:17 -05:00
|
|
|
displayio/Glyph.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
|
|
|
|
|
2018-07-16 08:44:20 -04:00
|
|
|
ifneq ($(SD), )
|
|
|
|
SRC_BINDINGS_ENUMS += \
|
2018-07-17 05:44:55 -04:00
|
|
|
bleio/Address.c \
|
2018-07-17 03:34:39 -04:00
|
|
|
bleio/AddressType.c \
|
2018-07-17 11:00:37 -04:00
|
|
|
bleio/AdvertisementData.c \
|
2018-11-15 17:00:12 -05:00
|
|
|
bleio/ScanEntry.c
|
2018-07-16 08:44:20 -04:00
|
|
|
endif
|
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
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 \
|
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 \
|
2019-01-17 18:15:59 -05:00
|
|
|
displayio/__init__.c \
|
|
|
|
displayio/Bitmap.c \
|
2019-02-06 15:13:17 -05:00
|
|
|
displayio/BuiltinFont.c \
|
2019-01-17 18:15:59 -05:00
|
|
|
displayio/ColorConverter.c \
|
|
|
|
displayio/Display.c \
|
|
|
|
displayio/FourWire.c \
|
|
|
|
displayio/Group.c \
|
|
|
|
displayio/OnDiskBitmap.c \
|
|
|
|
displayio/Palette.c \
|
|
|
|
displayio/Shape.c \
|
2019-01-29 20:10:17 -05:00
|
|
|
displayio/TileGrid.c \
|
|
|
|
storage/__init__.c \
|
|
|
|
terminalio/__init__.c \
|
|
|
|
terminalio/Terminal.c
|
2018-02-06 18:03:00 -05:00
|
|
|
|
2019-01-13 23:51:13 -05:00
|
|
|
|
|
|
|
ifndef EXCLUDE_PIXELBUF
|
|
|
|
SRC_SHARED_MODULE += _pixelbuf/__init__.c \
|
|
|
|
_pixelbuf/PixelBuf.c
|
|
|
|
endif
|
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-07-31 05:42:04 -04:00
|
|
|
# USB source files for nrf52840
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
|
|
|
|
|
|
|
SRC_C += \
|
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
|
2018-11-23 15:51:11 -05:00
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c
|
2018-07-31 05:42:04 -04:00
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
SRC_SHARED_MODULE += \
|
2018-07-31 05:42:04 -04:00
|
|
|
usb_hid/__init__.c \
|
2018-07-27 06:36:41 -04:00
|
|
|
usb_hid/Device.c \
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2018-07-31 05:42:04 -04:00
|
|
|
endif
|
2018-02-06 18:03:00 -05:00
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
|
|
|
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
|
|
|
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
2017-12-21 07:49:14 -05:00
|
|
|
|
2018-10-19 21:46:22 -04:00
|
|
|
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
|
2018-02-03 11:08:51 -05:00
|
|
|
$(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-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-08-14 09:19:28 -04:00
|
|
|
.phony: all flash sd binary hex
|
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-08-14 09:19:28 -04:00
|
|
|
## Create uf2 file
|
|
|
|
uf2: $(BUILD)/$(OUTPUT_FILENAME).hex
|
|
|
|
$(ECHO) "Create $(OUTPUT_FILENAME).uf2"
|
|
|
|
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/$(OUTPUT_FILENAME).uf2" $^
|
|
|
|
|
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
|
|
|
|
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-10-20 05:39:09 -04:00
|
|
|
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
|
|
|
|
#pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR)
|
|
|
|
pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
|
|
|
|
pyocd-tool -t $(MCU_VARIANT) reset
|
2017-01-03 11:00:06 -05:00
|
|
|
|
2017-02-25 19:52:46 -05:00
|
|
|
sd: $(BUILD)/$(OUTPUT_FILENAME).hex
|
2018-10-20 05:39:09 -04:00
|
|
|
pyocd-flashtool -t $(MCU_VARIANT) --chip_erase
|
|
|
|
pyocd-flashtool -t $(MCU_VARIANT) $(SOFTDEV_HEX)
|
|
|
|
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
|
|
|
|
pyocd-tool -t $(MCU_VARIANT) reset $(BOOT_SETTING_ADDR)
|
2018-07-13 09:17:30 -04:00
|
|
|
|
2017-01-03 11:00:06 -05:00
|
|
|
endif
|
|
|
|
|
2018-06-27 03:31:08 -04:00
|
|
|
#####################
|
|
|
|
# Flash with DFU
|
|
|
|
#####################
|
2018-08-14 09:19:28 -04:00
|
|
|
.phony: dfu-gen dfu-flash
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2018-08-21 04:15:44 -04:00
|
|
|
NRFUTIL = adafruit-nrfutil
|
|
|
|
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
|
|
|
DFU_TOUCH = --touch 1200
|
2018-06-27 03:31:08 -04:00
|
|
|
else
|
2018-08-21 04:15:44 -04:00
|
|
|
DFU_TOUCH =
|
2018-06-27 03:31:08 -04:00
|
|
|
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-08-14 09:19:28 -04:00
|
|
|
## Flash with DFU serial
|
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-08-21 04:15:44 -04:00
|
|
|
$(NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank $(DFU_TOUCH)
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2018-08-14 09:19:28 -04:00
|
|
|
## Create DFU package file
|
2018-08-30 21:42:25 -04:00
|
|
|
dfu-gen: $(BUILD)/dfu-package.zip
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2018-08-14 09:19:28 -04:00
|
|
|
$(BUILD)/dfu-package.zip: $(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-10-19 21:46:22 -04:00
|
|
|
# You must have $^ here because it deduplicates entries in $(OBJ)
|
2017-02-25 19:52:46 -05:00
|
|
|
$(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
|
2016-11-16 15:38:25 -05:00
|
|
|
$(ECHO) "LINK $@"
|
2018-10-19 21:46:22 -04:00
|
|
|
$(Q)$(CC) $(LDFLAGS) -o $@ $^ -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 +=
|
|
|
|
|
|
|
|
AF_FILE = $(MCU_VARIANT)_af.csv
|
|
|
|
PREFIX_FILE = boards/$(MCU_VARIANT)_prefix.c
|
|
|
|
|
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
|