2019-02-15 18:55:10 -05:00
|
|
|
# This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
#
|
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
2020-06-03 18:40:05 -04:00
|
|
|
# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
2019-02-15 18:55:10 -05:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
|
2022-11-18 12:30:28 -05:00
|
|
|
include ../../py/circuitpy_mkenv.mk
|
2022-11-18 00:57:23 -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
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
CROSS_COMPILE = arm-none-eabi-
|
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
|
|
|
|
|
|
|
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)
|
2020-08-11 10:14:13 -04:00
|
|
|
INC += -isystem ./nrfx
|
|
|
|
INC += -isystem ./nrfx/hal
|
|
|
|
INC += -isystem ./nrfx/mdk
|
|
|
|
INC += -isystem ./nrfx/drivers/include
|
|
|
|
INC += -isystem ./nrfx/drivers/src
|
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
|
|
|
|
|
|
|
#Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
2020-07-23 20:35:04 -04:00
|
|
|
CFLAGS += -ggdb3
|
2020-07-23 20:27:02 -04:00
|
|
|
OPTIMIZATION_FLAGS = -Og
|
2016-11-16 15:38:25 -05:00
|
|
|
else
|
2020-12-15 12:23:56 -05:00
|
|
|
OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions
|
2020-07-23 20:27:02 -04:00
|
|
|
CFLAGS += -DNDEBUG -ggdb3
|
2016-11-16 15:38:25 -05:00
|
|
|
endif
|
|
|
|
|
2021-02-24 11:49:57 -05:00
|
|
|
ifeq ($(NRF_DEBUG_PRINT), 1)
|
|
|
|
CFLAGS += -DNRF_DEBUG_PRINT=1
|
2021-02-17 06:53:18 -05:00
|
|
|
endif
|
|
|
|
|
2020-07-22 13:44:41 -04:00
|
|
|
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
|
2020-07-23 20:27:02 -04:00
|
|
|
CFLAGS += $(OPTIMIZATION_FLAGS)
|
2017-07-17 18:18:05 -04:00
|
|
|
|
2021-11-10 12:26:54 -05:00
|
|
|
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes
|
2019-02-15 18:55:10 -05:00
|
|
|
|
2021-09-08 15:44:45 -04:00
|
|
|
# Nordic Softdevice SDK header files contains inline assembler that has
|
|
|
|
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
|
|
|
|
# is able to "prove" that arguments to wrapper functions generated with
|
|
|
|
# the SVCALL() macro are unused and, as a result, the optimizer will remove
|
|
|
|
# code within the callers that sets up these arguments (which results in
|
|
|
|
# a broken bootloader). The broken headers come from Nordic-supplied zip
|
|
|
|
# files and are not trivial to patch so, for now, we'll simply disable the
|
|
|
|
# new gcc-11 inter-procedural optimizations.
|
|
|
|
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
|
|
|
|
CFLAGS += -fno-ipa-modref
|
|
|
|
endif
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
# Undo some warnings.
|
|
|
|
# nrfx does casts that increase alignment requirements.
|
|
|
|
CFLAGS += -Wno-cast-align
|
|
|
|
|
|
|
|
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
|
|
|
|
CFLAGS += $(NRF_DEFINES)
|
|
|
|
|
|
|
|
CFLAGS += \
|
|
|
|
-mthumb \
|
|
|
|
-mabi=aapcs-linux \
|
|
|
|
-mfloat-abi=hard \
|
|
|
|
-mcpu=cortex-m4 \
|
|
|
|
-mfpu=fpv4-sp-d16
|
|
|
|
|
|
|
|
# TODO: check this
|
|
|
|
CFLAGS += -D__START=main
|
|
|
|
|
2021-08-02 21:37:19 -04:00
|
|
|
LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-z,max-page-size=0x1000 -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
|
2019-02-15 18:55:10 -05:00
|
|
|
LIBS := -lgcc -lc
|
|
|
|
|
|
|
|
LDFLAGS += -mthumb -mcpu=cortex-m4
|
|
|
|
|
|
|
|
# Use toolchain libm if we're not using our own.
|
|
|
|
ifndef INTERNAL_LIBM
|
|
|
|
LIBS += -lm
|
|
|
|
endif
|
|
|
|
|
|
|
|
# TinyUSB defines
|
|
|
|
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
|
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 \
|
2019-02-07 07:50:14 -05:00
|
|
|
drivers/src/nrfx_rtc.c \
|
2019-12-17 09:39:52 -05:00
|
|
|
drivers/src/nrfx_nvmc.c \
|
2020-05-22 05:29:54 -04:00
|
|
|
drivers/src/nrfx_wdt.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-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 \
|
2020-01-05 23:33:42 -05:00
|
|
|
common-hal/_bleio/bonding.c \
|
2018-09-05 17:38:59 -04:00
|
|
|
nrfx/mdk/system_$(MCU_SUB_VARIANT).c \
|
2021-11-10 12:26:54 -05:00
|
|
|
sd_mutex.c \
|
|
|
|
|
|
|
|
SRC_PERIPHERALS := \
|
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 \
|
2019-04-04 00:40:12 -04:00
|
|
|
peripherals/nrf/nvm.c \
|
2018-10-16 11:05:02 -04:00
|
|
|
peripherals/nrf/timers.c \
|
2018-07-04 06:15:49 -04:00
|
|
|
|
2021-11-10 12:26:54 -05:00
|
|
|
$(patsubst %.c,$(BUILD)/%.o,$(SRC_PERIPHERALS)): CFLAGS += -Wno-missing-prototypes
|
|
|
|
|
|
|
|
SRC_C += $(SRC_PERIPHERALS)
|
2021-04-16 10:59:11 -04:00
|
|
|
ifneq ($(CIRCUITPY_USB),0)
|
2018-07-31 05:42:04 -04:00
|
|
|
# USB source files for nrf52840
|
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52840)
|
2021-11-10 12:26:54 -05:00
|
|
|
SRC_DCD = \
|
2019-08-19 19:42:45 -04:00
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c
|
2018-07-31 05:42:04 -04:00
|
|
|
endif
|
2018-02-06 18:03:00 -05:00
|
|
|
|
2020-04-16 22:35:33 -04:00
|
|
|
ifeq ($(MCU_SUB_VARIANT),nrf52833)
|
2021-11-10 12:26:54 -05:00
|
|
|
SRC_DCD += \
|
2020-04-16 22:35:33 -04:00
|
|
|
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c
|
|
|
|
endif
|
2021-11-10 12:26:54 -05:00
|
|
|
SRC_C += $(SRC_DCD)
|
|
|
|
$(patsubst %.c,$(BUILD)/%.o,$(SRC_DCD)): CFLAGS += -Wno-missing-prototypes
|
2021-04-16 10:59:11 -04:00
|
|
|
endif # CIRCUITPY_USB
|
2020-04-16 22:35:33 -04: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)) \
|
2019-08-16 21:34:00 -04:00
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
|
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2019-12-10 17:57:17 -05:00
|
|
|
# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED,
|
2021-08-03 10:59:04 -04:00
|
|
|
# because a few modules have files both in common-hal/ and shared-module/.
|
2019-12-10 17:57:17 -05:00
|
|
|
# Doing a $(sort ...) removes duplicates as part of sorting.
|
|
|
|
SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
|
2018-07-03 10:25:54 -04:00
|
|
|
|
2019-12-10 17:57:17 -05:00
|
|
|
SRC_S = supervisor/cpu.s
|
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))
|
2019-12-10 17:57:17 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
|
2019-02-15 18:55:10 -05:00
|
|
|
ifeq ($(INTERNAL_LIBM),1)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
|
|
|
|
endif
|
2021-04-22 20:55:39 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
|
2018-07-03 10:25:54 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
2019-04-05 15:42:29 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2020-08-12 13:51:35 -04:00
|
|
|
# nrfx uses undefined preprocessor variables quite casually, so we can't do
|
|
|
|
# warning checks for these. Happily, we've confined the offenders to the NRFX
|
|
|
|
# source files themselves.
|
2020-08-11 10:14:13 -04:00
|
|
|
$(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o)): CFLAGS += -Wno-undef
|
|
|
|
|
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
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
# List of sources for qstr extraction
|
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
|
|
|
# Sources that only hold QSTRs after pre-processing.
|
|
|
|
SRC_QSTR_PREPROCESSOR +=
|
|
|
|
|
2021-12-23 17:32:00 -05:00
|
|
|
UF2_FAMILY_ID_nrf52840 = 0xADA52840
|
|
|
|
UF2_FAMILY_ID_nrf52833 = 0x621E937A
|
|
|
|
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2021-07-08 22:11:05 -04:00
|
|
|
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.combined.hex
|
2017-02-25 19:52:46 -05:00
|
|
|
|
2023-06-05 17:16:25 -04:00
|
|
|
ifeq ($(VALID_BOARD),)
|
|
|
|
$(BUILD)/firmware.elf: invalid-board
|
|
|
|
else
|
2019-12-10 17:57:17 -05:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
|
2019-02-15 18:55:10 -05:00
|
|
|
$(STEPECHO) "LINK $@"
|
2021-05-27 16:25:29 -04:00
|
|
|
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
|
|
|
|
$(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group
|
2023-03-04 03:37:38 -05:00
|
|
|
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)
|
2023-06-05 17:16:25 -04:00
|
|
|
endif
|
2017-02-25 19:52:46 -05:00
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
|
|
|
$(STEPECHO) "Create $@"
|
|
|
|
$(Q)$(OBJCOPY) -O binary $^ $@
|
|
|
|
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
2017-02-25 19:52:46 -05:00
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
|
|
|
|
$(STEPECHO) "Create $@"
|
|
|
|
$(Q)$(OBJCOPY) -O ihex $^ $@
|
|
|
|
# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
|
2017-02-25 19:52:46 -05:00
|
|
|
|
2021-07-08 22:11:05 -04:00
|
|
|
$(BUILD)/firmware.combined.hex: $(BUILD)/firmware.hex $(SOFTDEV_HEX)
|
|
|
|
$(STEPECHO) "Create $@"
|
|
|
|
$(Q)hexmerge.py -o $@ $^
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
|
|
|
|
$(ECHO) "Create $@"
|
2021-12-23 17:32:00 -05:00
|
|
|
$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_$(MCU_CHIP)) -c -o "$(BUILD)/firmware.uf2" $^
|
2017-02-25 19:52:46 -05:00
|
|
|
|
2016-11-16 15:38:25 -05:00
|
|
|
|
2018-08-14 09:19:28 -04:00
|
|
|
|
2018-06-27 03:31:08 -04:00
|
|
|
#####################
|
|
|
|
# Flash with debugger
|
|
|
|
#####################
|
2017-01-03 11:00:06 -05:00
|
|
|
FLASHER ?=
|
|
|
|
|
|
|
|
ifeq ($(FLASHER),)
|
|
|
|
|
2023-03-18 11:17:02 -04:00
|
|
|
# Also update to bootloader setting to validate application and skip checksum ( app valid = 0x0001, crc = 0x0000 )
|
2019-02-15 18:55:10 -05:00
|
|
|
flash: $(BUILD)/firmware.hex
|
2018-06-08 04:11:17 -04:00
|
|
|
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)
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
sd: $(BUILD)/firmware.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)
|
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
flash: $(BUILD)/firmware.hex
|
2018-10-20 05:39:09 -04:00
|
|
|
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
|
2019-12-10 17:57:17 -05:00
|
|
|
# pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR)
|
2018-10-20 05:39:09 -04:00
|
|
|
pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
|
|
|
|
pyocd-tool -t $(MCU_VARIANT) reset
|
2017-01-03 11:00:06 -05:00
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
sd: $(BUILD)/firmware.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
|
|
|
|
2022-07-30 01:09:49 -04:00
|
|
|
NRFUTIL = nrfutil
|
|
|
|
ADAFRUIT_NRFUTIL = adafruit-nrfutil
|
2018-08-21 04:15:44 -04:00
|
|
|
|
|
|
|
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)
|
2022-07-30 01:09:49 -04:00
|
|
|
$(ADAFRUIT_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
|
|
|
|
2019-02-15 18:55:10 -05:00
|
|
|
$(BUILD)/dfu-package.zip: $(BUILD)/firmware.hex
|
2022-07-30 01:09:49 -04:00
|
|
|
$(ADAFRUIT_NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
|
2018-06-27 03:31:08 -04:00
|
|
|
|
2022-07-30 01:09:49 -04:00
|
|
|
# Espruino DFU
|
|
|
|
$(BUILD)/firmware.espruino.zip: $(BUILD)/firmware.hex
|
|
|
|
$(Q)$(NRFUTIL) pkg generate $(BUILD)/firmware.espruino.zip --application $^ --application-version 0xff --hw-version 52 --sd-req 0xa9,0xae,0xb6 --key-file espruino_dfu_private_key.pem
|
|
|
|
|
|
|
|
espruino-dfu-gen: $(BUILD)/firmware.espruino.zip
|
2016-12-13 14:27:26 -05:00
|
|
|
|
2017-12-21 07:49:14 -05:00
|
|
|
include $(TOP)/py/mkrules.mk
|