2019-06-22 14:03:41 +01: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
|
|
|
|
|
2022-06-08 09:54:02 +01:00
|
|
|
MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
include ../../py/mkenv.mk
|
2019-08-10 06:17:09 +01:00
|
|
|
include $(BOARD_DIR)/mpconfigboard.mk
|
2022-06-08 09:54:02 +01:00
|
|
|
include mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.mk
|
2019-06-22 14:03:41 +01:00
|
|
|
|
|
|
|
# Qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
2022-06-08 09:54:02 +01:00
|
|
|
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.h
|
2021-05-20 09:30:08 +01:00
|
|
|
|
|
|
|
FROZEN_MANIFEST ?= boards/manifest.py
|
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
# Include py core make definitions
|
|
|
|
include $(TOP)/py/py.mk
|
2022-06-17 17:11:30 +01:00
|
|
|
include $(TOP)/extmod/extmod.mk
|
2019-06-22 14:03:41 +01:00
|
|
|
|
2022-07-08 05:59:33 +01:00
|
|
|
GIT_SUBMODULES += lib/asf4 lib/tinyusb
|
2019-10-14 02:09:06 +01:00
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
INC += -I.
|
|
|
|
INC += -I$(TOP)
|
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(BOARD_DIR)
|
2022-06-08 09:54:02 +01:00
|
|
|
INC += -Imcu/$(MCU_SERIES_LOWER)
|
2019-06-22 14:03:41 +01:00
|
|
|
INC += -I$(TOP)/lib/cmsis/inc
|
2021-05-20 09:30:08 +01: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 14:03:41 +01:00
|
|
|
INC += -I$(TOP)/lib/tinyusb/src
|
|
|
|
|
2022-06-05 07:55:27 +01: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 14:03:41 +01: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 09:30:08 +01:00
|
|
|
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
|
2022-06-04 12:27:12 +01:00
|
|
|
CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
|
2022-06-05 07:55:27 +01:00
|
|
|
CFLAGS += -DPIN_AF_TABLE_C='<$(BUILD)/$(GEN_PIN_AF)>'
|
2022-06-04 12:27:12 +01:00
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
|
2021-07-22 07:18:54 +01:00
|
|
|
LDFLAGS += $(LDFLAGS_MOD)
|
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
|
|
|
|
|
|
|
# Tune for Debugging or Optimization
|
2022-07-28 08:56:27 +01:00
|
|
|
CFLAGS += -g # always include debug info in the ELF
|
2019-06-22 14:03:41 +01:00
|
|
|
ifeq ($(DEBUG),1)
|
2022-07-28 08:56:27 +01:00
|
|
|
CFLAGS += -O0
|
2019-06-22 14:03:41 +01:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
|
|
|
LDFLAGS += --gc-sections
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
|
|
|
endif
|
|
|
|
|
2021-07-22 07:18:54 +01: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
|
|
|
|
|
2022-06-10 15:40:50 +01:00
|
|
|
SRC_C += \
|
2022-06-15 17:49:24 +01:00
|
|
|
mcu/$(MCU_SERIES_LOWER)/clock_config.c \
|
2021-05-20 09:30:08 +01:00
|
|
|
help.c \
|
2022-06-05 09:34:23 +01:00
|
|
|
machine_adc.c \
|
2022-06-10 15:40:50 +01:00
|
|
|
machine_bitstream.c \
|
2022-06-07 19:37:44 +01:00
|
|
|
machine_dac.c \
|
2022-06-05 17:11:06 +01:00
|
|
|
machine_i2c.c \
|
2022-06-04 15:16:22 +01:00
|
|
|
machine_led.c \
|
|
|
|
machine_pin.c \
|
2022-06-05 16:02:46 +01:00
|
|
|
machine_spi.c \
|
2022-06-06 10:13:25 +01:00
|
|
|
machine_timer.c \
|
2022-06-05 14:03:52 +01:00
|
|
|
machine_uart.c \
|
2022-06-06 10:23:09 +01:00
|
|
|
machine_wdt.c \
|
2022-06-04 15:16:22 +01:00
|
|
|
main.c \
|
2019-06-22 14:03:41 +01:00
|
|
|
modutime.c \
|
|
|
|
modmachine.c \
|
2021-05-20 09:30:08 +01:00
|
|
|
modsamd.c \
|
2019-06-22 14:03:41 +01:00
|
|
|
mphalport.c \
|
2022-06-06 10:13:25 +01:00
|
|
|
pendsv.c \
|
2022-06-05 07:55:27 +01:00
|
|
|
pin_af.c \
|
2022-06-04 15:16:22 +01:00
|
|
|
$(BUILD)/pins.c \
|
|
|
|
samd_flash.c \
|
2019-06-22 14:03:41 +01:00
|
|
|
samd_isr.c \
|
|
|
|
samd_soc.c \
|
|
|
|
tusb_port.c \
|
2021-05-20 09:30:08 +01: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 14:03:41 +01: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-15 03:15:08 +00:00
|
|
|
lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \
|
2019-06-22 14:03:41 +01:00
|
|
|
lib/tinyusb/src/tusb.c \
|
2022-06-04 20:26:45 +01:00
|
|
|
drivers/bus/softspi.c \
|
2022-06-05 19:34:37 +01:00
|
|
|
extmod/uos_dupterm.c \
|
2022-06-05 13:08:44 +01:00
|
|
|
shared/runtime/mpirq.c \
|
2021-07-09 05:19:15 +01:00
|
|
|
shared/libc/printf.c \
|
|
|
|
shared/libc/string0.c \
|
|
|
|
shared/readline/readline.c \
|
|
|
|
shared/runtime/gchelper_native.c \
|
|
|
|
shared/runtime/pyexec.c \
|
2022-06-06 10:13:25 +01:00
|
|
|
shared/runtime/softtimer.c \
|
2021-07-09 05:19:15 +01:00
|
|
|
shared/runtime/stdout_helpers.c \
|
2021-05-20 09:30:08 +01:00
|
|
|
shared/runtime/sys_stdio_mphal.c \
|
|
|
|
shared/timeutils/timeutils.c \
|
2019-06-22 14:03:41 +01:00
|
|
|
|
2021-07-22 07:18:54 +01:00
|
|
|
SRC_C += $(SRC_MOD)
|
|
|
|
|
|
|
|
SRC_CXX += $(SRC_MOD_CXX)
|
|
|
|
|
2019-06-22 14:03:41 +01:00
|
|
|
# List of sources for qstr extraction
|
2022-03-03 08:30:58 +00:00
|
|
|
SRC_QSTR += \
|
2022-06-05 09:34:23 +01:00
|
|
|
machine_adc.c \
|
2022-06-07 19:37:44 +01:00
|
|
|
machine_dac.c \
|
2022-06-05 17:11:06 +01:00
|
|
|
machine_i2c.c \
|
2022-06-04 15:16:22 +01:00
|
|
|
machine_led.c \
|
|
|
|
machine_pin.c \
|
2022-06-05 10:03:59 +01:00
|
|
|
machine_pwm.c \
|
2022-06-05 16:02:46 +01:00
|
|
|
machine_spi.c \
|
2022-06-06 10:13:25 +01:00
|
|
|
machine_timer.c \
|
2022-06-05 14:03:52 +01:00
|
|
|
machine_uart.c \
|
2022-06-06 10:23:09 +01:00
|
|
|
machine_wdt.c \
|
2021-05-20 09:30:08 +01:00
|
|
|
modutime.c \
|
|
|
|
modmachine.c \
|
|
|
|
modsamd.c \
|
|
|
|
samd_flash.c \
|
2022-07-01 20:06:10 +01:00
|
|
|
shared/readline/readline.c \
|
2022-06-05 19:34:37 +01:00
|
|
|
extmod/uos_dupterm.c \
|
2022-06-05 13:08:44 +01:00
|
|
|
shared/runtime/mpirq.c \
|
2022-06-15 14:16:07 +01:00
|
|
|
shared/runtime/sys_stdio_mphal.c \
|
2021-05-20 09:30:08 +01:00
|
|
|
|
|
|
|
SRC_QSTR += $(SRC_MOD) $(SRC_CXX)
|
2019-06-22 14:03:41 +01:00
|
|
|
|
|
|
|
OBJ += $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2021-07-22 07:18:54 +01:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
2019-06-22 14:03:41 +01:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
2021-05-20 09:30:08 +01: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 14:03:41 +01: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 07:55:27 +01: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 20:19:47 +01: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 14:03:41 +01:00
|
|
|
include $(TOP)/py/mkrules.mk
|