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
|
|
|
|
|
2022-06-08 04:54:02 -04:00
|
|
|
MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
include ../../py/mkenv.mk
|
2019-08-10 01:17:09 -04:00
|
|
|
include $(BOARD_DIR)/mpconfigboard.mk
|
2022-06-08 04:54:02 -04:00
|
|
|
include mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.mk
|
2019-06-22 09:03:41 -04:00
|
|
|
|
|
|
|
# Qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
2022-06-08 04:54:02 -04:00
|
|
|
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.h
|
2021-05-20 04:30:08 -04:00
|
|
|
|
|
|
|
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)
|
2022-06-08 04:54:02 -04:00
|
|
|
INC += -Imcu/$(MCU_SERIES_LOWER)
|
2019-06-22 09:03:41 -04:00
|
|
|
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
|
2022-06-16 05:32:21 -04:00
|
|
|
PIN_AF_TABLE_CSV = mcu/$(MCU_SERIES_LOWER)/pin-af-table.csv
|
2022-06-05 02:55:27 -04:00
|
|
|
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
|
2022-10-08 08:08:53 -04:00
|
|
|
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
|
2019-06-22 09:03:41 -04:00
|
|
|
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
|
extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-08 08:59:08 -04:00
|
|
|
CFLAGS += $(CFLAGS_EXTRA)
|
2022-06-04 07:27:12 -04:00
|
|
|
|
2022-10-08 08:08:53 -04:00
|
|
|
LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
|
2021-07-22 02:18:54 -04:00
|
|
|
|
2022-10-08 08:08:53 -04:00
|
|
|
LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
2019-06-22 09:03:41 -04:00
|
|
|
|
|
|
|
# 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))
|
extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-08 08:59:08 -04:00
|
|
|
|
2022-10-08 08:28:24 -04:00
|
|
|
# TODO make this common -- shouldn't be using these "private" vars from py.mk
|
|
|
|
ifneq ($(SRC_CXX)$(SRC_USERMOD_CXX)$(SRC_USERMOD_LIB_CXX),)
|
2021-07-22 02:18:54 -04:00
|
|
|
LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)"
|
|
|
|
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))"
|
|
|
|
endif
|
|
|
|
|
2022-06-10 10:40:50 -04:00
|
|
|
SRC_C += \
|
2022-06-15 12:49:24 -04:00
|
|
|
mcu/$(MCU_SERIES_LOWER)/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-10 10:40:50 -04:00
|
|
|
machine_bitstream.c \
|
2022-06-07 14:37:44 -04:00
|
|
|
machine_dac.c \
|
2022-06-05 12:11:06 -04:00
|
|
|
machine_i2c.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
machine_led.c \
|
|
|
|
machine_pin.c \
|
2022-09-15 09:58:54 -04:00
|
|
|
machine_rtc.c \
|
2022-06-05 11:02:46 -04:00
|
|
|
machine_spi.c \
|
2022-06-06 05:13:25 -04:00
|
|
|
machine_timer.c \
|
2022-06-05 09:03:52 -04:00
|
|
|
machine_uart.c \
|
2022-06-06 05:23:09 -04:00
|
|
|
machine_wdt.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
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-06 05:13:25 -04:00
|
|
|
pendsv.c \
|
2022-06-05 02:55:27 -04:00
|
|
|
pin_af.c \
|
2022-06-04 10:16:22 -04:00
|
|
|
samd_flash.c \
|
2019-06-22 09:03:41 -04:00
|
|
|
samd_isr.c \
|
|
|
|
samd_soc.c \
|
|
|
|
tusb_port.c \
|
2022-10-08 09:05:26 -04:00
|
|
|
|
|
|
|
SHARED_SRC_C += \
|
2022-06-05 08:08:44 -04:00
|
|
|
shared/runtime/mpirq.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 \
|
2022-06-28 10:59:01 -04:00
|
|
|
shared/runtime/interrupt_char.c \
|
2021-07-09 00:19:15 -04:00
|
|
|
shared/runtime/pyexec.c \
|
2022-06-06 05:13:25 -04:00
|
|
|
shared/runtime/softtimer.c \
|
2021-07-09 00:19:15 -04:00
|
|
|
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
|
|
|
|
2022-10-08 09:05:26 -04:00
|
|
|
ASF4_SRC_C += $(addprefix lib/asf4/$(MCU_SERIES_LOWER)/,\
|
|
|
|
hal/src/hal_atomic.c \
|
|
|
|
hal/src/hal_flash.c \
|
|
|
|
hpl/nvmctrl/hpl_nvmctrl.c \
|
|
|
|
)
|
|
|
|
|
|
|
|
LIBM_SRC_C += $(addprefix lib/libm/,\
|
|
|
|
ef_sqrt.c \
|
|
|
|
fmodf.c \
|
|
|
|
math.c \
|
|
|
|
nearbyintf.c \
|
|
|
|
)
|
|
|
|
|
|
|
|
TINYUSB_SRC_C += $(addprefix lib/tinyusb/src/,\
|
|
|
|
class/cdc/cdc_device.c \
|
|
|
|
common/tusb_fifo.c \
|
|
|
|
device/usbd.c \
|
|
|
|
device/usbd_control.c \
|
|
|
|
portable/microchip/samd/dcd_samd.c \
|
|
|
|
tusb.c \
|
|
|
|
)
|
|
|
|
|
|
|
|
DRIVERS_SRC_C += \
|
|
|
|
drivers/bus/softspi.c \
|
2021-07-22 02:18:54 -04:00
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
# List of sources for qstr extraction
|
2022-10-08 09:05:26 -04:00
|
|
|
SRC_QSTR += $(SRC_C) $(SHARED_SRC_C) $(SRC_CXX) $(GEN_PINS_SRC)
|
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))
|
2022-10-08 09:05:26 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(ASF4_SRC_C:.c=.o))
|
extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-08 08:59:08 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o))
|
2022-10-08 09:05:26 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(TINYUSB_SRC_C:.c=.o))
|
2022-10-08 08:23:52 -04:00
|
|
|
OBJ += $(GEN_PINS_SRC:.c=.o)
|
2021-05-20 04:30:08 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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)
|
|
|
|
|
2022-06-24 02:27:23 -04:00
|
|
|
$(BUILD)/$(GEN_PIN_AF): $(PIN_AF_TABLE_CSV) | $(HEADER_BUILD)
|
2022-06-05 02:55:27 -04:00
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(PYTHON) $(MAKE_PIN_AF) --csv $(PIN_AF_TABLE_CSV) --table $(BUILD)/$(GEN_PIN_AF) --mcu $(MCU_SERIES)
|
|
|
|
|
2022-06-24 02:27:23 -04:00
|
|
|
machine_led.c machine_pin.c modsamd.c: $(GEN_PINS_HDR)
|
2022-06-05 02:55:27 -04:00
|
|
|
|
2022-06-24 02:27:23 -04:00
|
|
|
$(GEN_PINS_SRC) $(GEN_PINS_HDR): $(BOARD_PINS) | $(HEADER_BUILD)
|
2022-05-27 15:19:47 -04:00
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --pins $(GEN_PINS_SRC) --inc $(GEN_PINS_HDR)
|
|
|
|
|
2022-10-08 08:23:52 -04:00
|
|
|
$(GEN_PINS_SRC:.c=.o): $(GEN_PINS_SRC)
|
|
|
|
$(call compile_c)
|
|
|
|
|
2019-06-22 09:03:41 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|