2019-06-22 09:03:41 -04:00
|
|
|
BOARD ?= ADAFRUIT_ITSYBITSY_M4_EXPRESS
|
|
|
|
BOARD_DIR ?= boards/$(BOARD)
|
|
|
|
BUILD ?= build-$(BOARD)
|
|
|
|
|
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
|
|
|
UF2CONV ?= $(TOP)/tools/uf2conv.py
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(BOARD_DIR)/.),)
|
|
|
|
$(error Invalid BOARD specified: $(BOARD_DIR))
|
|
|
|
endif
|
|
|
|
|
|
|
|
include ../../py/mkenv.mk
|
2019-08-10 01:17:09 -04:00
|
|
|
include $(BOARD_DIR)/mpconfigboard.mk
|
2019-06-22 09:03:41 -04:00
|
|
|
|
|
|
|
# Qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
|
|
|
|
|
2021-05-20 04:30:08 -04:00
|
|
|
MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
|
|
FROZEN_MANIFEST ?= boards/manifest.py
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
# Include py core make definitions
|
|
|
|
include $(TOP)/py/py.mk
|
2022-06-17 12:11:30 -04:00
|
|
|
include $(TOP)/extmod/extmod.mk
|
2019-06-22 09:03:41 -04:00
|
|
|
|
2022-07-08 00:59:33 -04:00
|
|
|
GIT_SUBMODULES += lib/asf4 lib/tinyusb
|
2019-10-13 21:09:06 -04:00
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
INC += -I.
|
|
|
|
INC += -I$(TOP)
|
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(BOARD_DIR)
|
|
|
|
INC += -I$(TOP)/lib/cmsis/inc
|
2021-05-20 04:30:08 -04:00
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hal/include
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hal/utils/include
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/config
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hri
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/core
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/gclk
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/pm
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/port
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/rtc
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hpl/tc
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/include
|
|
|
|
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/include/pio
|
2019-06-22 09:03:41 -04:00
|
|
|
INC += -I$(TOP)/lib/tinyusb/src
|
|
|
|
|
2022-06-05 02:55:27 -04:00
|
|
|
MAKE_PIN_AF = boards/make-pin-af.py
|
|
|
|
PIN_AF_TABLE_CSV = boards/pin-af-table-$(MCU_SERIES).csv
|
|
|
|
GEN_PIN_AF = pin_af_table.c
|
|
|
|
|
|
|
|
MAKE_PINS = boards/make-pins.py
|
|
|
|
BOARD_PINS = $(BOARD_DIR)/pins.csv
|
|
|
|
GEN_PINS_SRC = $(BUILD)/pins.c
|
|
|
|
GEN_PINS_HDR = $(BUILD)/pins.h
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
CFLAGS_MCU_SAMD21 = -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
|
|
|
|
CFLAGS_MCU_SAMD51 = -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
|
|
|
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
|
|
|
|
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
|
2021-05-20 04:30:08 -04:00
|
|
|
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
|
2022-06-04 07:27:12 -04:00
|
|
|
CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
|
2022-06-05 02:55:27 -04:00
|
|
|
CFLAGS += -DPIN_AF_TABLE_C='<$(BUILD)/$(GEN_PIN_AF)>'
|
2022-06-04 07:27:12 -04:00
|
|
|
|
|
|
|
QSTR_GLOBAL_DEPENDENCIES += boards/mpconfig_$(MCU_SERIES_LOWER).h
|
2021-07-22 02:18:54 -04:00
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
|
2021-07-22 02:18:54 -04:00
|
|
|
LDFLAGS += $(LDFLAGS_MOD)
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
|
|
|
|
|
|
|
# Tune for Debugging or Optimization
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -g # always include debug info in the ELF
|
2019-06-22 09:03:41 -04:00
|
|
|
ifeq ($(DEBUG),1)
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -O0
|
2019-06-22 09:03:41 -04:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
|
|
|
LDFLAGS += --gc-sections
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
|
|
|
endif
|
|
|
|
|
2021-07-22 02:18:54 -04:00
|
|
|
# Flags for optional C++ source code
|
|
|
|
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
|
|
|
|
CXXFLAGS += $(CXXFLAGS_MOD)
|
|
|
|
ifneq ($(SRC_CXX)$(SRC_MOD_CXX),)
|
|
|
|
LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)"
|
|
|
|
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))"
|
|
|
|
endif
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
SRC_C = \
|
2022-06-04 10:31:46 -04:00
|
|
|
clock_config.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
help.c \
|
2022-06-05 04:34:23 -04:00
|
|
|
machine_adc.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
machine_led.c \
|
|
|
|
machine_pin.c \
|
|
|
|
main.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
modutime.c \
|
|
|
|
modmachine.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
modsamd.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
mphalport.c \
|
2022-06-05 02:55:27 -04:00
|
|
|
pin_af.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
$(BUILD)/pins.c \
|
|
|
|
samd_flash.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
samd_isr.c \
|
|
|
|
samd_soc.c \
|
|
|
|
tusb_port.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
lib/asf4/$(MCU_SERIES_LOWER)/hal/src/hal_atomic.c \
|
|
|
|
lib/asf4/$(MCU_SERIES_LOWER)/hal/src/hal_flash.c \
|
|
|
|
lib/asf4/$(MCU_SERIES_LOWER)/hpl/nvmctrl/hpl_nvmctrl.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
lib/libm/ef_sqrt.c \
|
|
|
|
lib/libm/fmodf.c \
|
|
|
|
lib/libm/math.c \
|
|
|
|
lib/libm/nearbyintf.c \
|
|
|
|
lib/tinyusb/src/class/cdc/cdc_device.c \
|
|
|
|
lib/tinyusb/src/common/tusb_fifo.c \
|
|
|
|
lib/tinyusb/src/device/usbd.c \
|
|
|
|
lib/tinyusb/src/device/usbd_control.c \
|
2020-01-14 22:15:08 -05:00
|
|
|
lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
lib/tinyusb/src/tusb.c \
|
2022-06-04 15:26:45 -04:00
|
|
|
drivers/bus/softspi.c \
|
2021-07-09 00:19:15 -04:00
|
|
|
shared/libc/printf.c \
|
|
|
|
shared/libc/string0.c \
|
|
|
|
shared/readline/readline.c \
|
|
|
|
shared/runtime/gchelper_native.c \
|
|
|
|
shared/runtime/pyexec.c \
|
|
|
|
shared/runtime/stdout_helpers.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
shared/runtime/sys_stdio_mphal.c \
|
|
|
|
shared/timeutils/timeutils.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
|
2021-07-22 02:18:54 -04:00
|
|
|
SRC_C += $(SRC_MOD)
|
|
|
|
|
|
|
|
SRC_CXX += $(SRC_MOD_CXX)
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
ifeq ($(MCU_SERIES),SAMD21)
|
2021-07-09 00:19:15 -04:00
|
|
|
SRC_S = shared/runtime/gchelper_m0.s
|
2019-06-22 09:03:41 -04:00
|
|
|
else
|
2021-07-09 00:19:15 -04:00
|
|
|
SRC_S = shared/runtime/gchelper_m3.s
|
2019-06-22 09:03:41 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
# List of sources for qstr extraction
|
2022-03-03 03:30:58 -05:00
|
|
|
SRC_QSTR += \
|
2022-06-05 04:34:23 -04:00
|
|
|
machine_adc.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
machine_led.c \
|
|
|
|
machine_pin.c \
|
2022-06-05 05:03:59 -04:00
|
|
|
machine_pwm.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
modutime.c \
|
|
|
|
modmachine.c \
|
|
|
|
modsamd.c \
|
|
|
|
samd_flash.c \
|
2022-07-01 15:06:10 -04:00
|
|
|
shared/readline/readline.c \
|
2021-05-20 04:30:08 -04:00
|
|
|
|
|
|
|
SRC_QSTR += $(SRC_MOD) $(SRC_CXX)
|
2019-06-22 09:03:41 -04:00
|
|
|
|
|
|
|
OBJ += $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2021-07-22 02:18:54 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
2019-06-22 09:03:41 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
2021-05-20 04:30:08 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
|
|
|
|
|
|
|
ifneq ($(FROZEN_MANIFEST),)
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
|
|
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
|
|
|
endif
|
2019-06-22 09:03:41 -04:00
|
|
|
|
|
|
|
# Workaround for bug in older gcc, warning on "static usbd_device_t _usbd_dev = { 0 };"
|
|
|
|
$(BUILD)/lib/tinyusb/src/device/usbd.o: CFLAGS += -Wno-missing-braces
|
|
|
|
|
|
|
|
all: $(BUILD)/firmware.uf2
|
|
|
|
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
|
|
|
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
|
|
|
|
|
|
|
|
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
|
|
|
|
$(Q)$(PYTHON) $(UF2CONV) -b $(TEXT0) -c -o $@ $<
|
|
|
|
|
2022-06-05 02:55:27 -04:00
|
|
|
pin_af.c: $(BUILD)/$(GEN_PIN_AF)
|
|
|
|
|
|
|
|
$(BUILD)/$(GEN_PIN_AF): $(PIN_AF_TABLE_CSV)
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(PYTHON) $(MAKE_PIN_AF) --csv $(PIN_AF_TABLE_CSV) --table $(BUILD)/$(GEN_PIN_AF) --mcu $(MCU_SERIES)
|
|
|
|
|
|
|
|
|
2022-05-27 15:19:47 -04:00
|
|
|
$(GEN_PINS_SRC): $(BOARD_PINS)
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --pins $(GEN_PINS_SRC) --inc $(GEN_PINS_HDR)
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|