2020-02-03 20:20:29 -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 Scott Shawcroft for Adafruit Industries
|
2020-02-03 20:20:29 -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
|
2020-02-03 20:20:29 -05:00
|
|
|
|
|
|
|
CROSS_COMPILE = riscv64-unknown-elf-
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# CFLAGS
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
INC += -I.
|
|
|
|
INC += -I../..
|
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(BUILD)/genhdr
|
|
|
|
INC += -I./boards
|
|
|
|
INC += -I./boards/$(BOARD)
|
|
|
|
INC += -I./peripherals
|
|
|
|
INC += -I../../lib/mp-readline
|
|
|
|
INC += -I../../lib/tinyusb/src
|
|
|
|
INC += -I../../supervisor/shared/usb
|
|
|
|
|
|
|
|
|
|
|
|
#Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -ggdb
|
|
|
|
# You may want to enable these flags to make setting breakpoints easier.
|
|
|
|
CFLAGS += -fno-inline -fno-ipa-sra
|
2020-07-23 20:27:02 -04:00
|
|
|
OPTIMIZATION_FLAGS ?= -Og
|
2020-02-03 20:20:29 -05:00
|
|
|
else
|
2020-07-23 20:27:02 -04:00
|
|
|
CFLAGS += -DNDEBUG -ggdb3
|
2020-12-15 12:23:56 -05:00
|
|
|
OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions
|
2020-02-03 20:20:29 -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)
|
2020-07-21 11:11:08 -04:00
|
|
|
|
2021-11-12 20:13:35 -05:00
|
|
|
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes
|
2020-02-03 20:20:29 -05:00
|
|
|
|
|
|
|
# TODO: check this
|
2020-03-29 23:06:52 -04:00
|
|
|
CFLAGS += -D__START=main -DFOMU
|
2020-02-03 20:20:29 -05:00
|
|
|
|
|
|
|
LD_FILE := boards/$(BOARD)/$(BOARD)-spi.ld
|
|
|
|
|
2020-05-28 18:43:55 -04:00
|
|
|
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs -Wl,-melf32lriscv
|
2020-02-03 20:20:29 -05:00
|
|
|
LIBS := -lgcc -lc
|
|
|
|
|
|
|
|
|
2022-05-27 15:59:54 -04:00
|
|
|
LDFLAGS += -ffreestanding -nostartfiles -Wl,--gc-section -Wl,-Bstatic -Wl,-melf32lriscv -nostartfiles \
|
2020-02-03 20:20:29 -05:00
|
|
|
-Wl,--no-warn-mismatch \
|
|
|
|
-Wl,--build-id=none
|
|
|
|
|
|
|
|
# Use toolchain libm if we're not using our own.
|
|
|
|
ifndef INTERNAL_LIBM
|
|
|
|
LIBS += -lm
|
|
|
|
endif
|
|
|
|
|
|
|
|
# TinyUSB defines
|
|
|
|
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI -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
|
|
|
|
|
|
|
|
|
|
|
|
######################################
|
|
|
|
# source
|
|
|
|
######################################
|
|
|
|
|
|
|
|
|
|
|
|
SRC_C += \
|
|
|
|
background.c \
|
|
|
|
mphalport.c \
|
|
|
|
boards/$(BOARD)/board.c \
|
2021-04-22 20:55:39 -04:00
|
|
|
boards/$(BOARD)/pins.c
|
2020-02-03 20:20:29 -05:00
|
|
|
|
2021-04-16 10:59:11 -04:00
|
|
|
ifneq ($(CIRCUITPY_USB),0)
|
2020-02-03 20:20:29 -05:00
|
|
|
SRC_C += lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRC_S = \
|
|
|
|
crt0-vexriscv.S
|
|
|
|
|
|
|
|
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
|
|
|
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
|
|
|
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
|
|
|
|
|
|
|
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
|
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
|
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
|
|
|
|
|
|
|
|
|
|
|
|
ifneq ($(FROZEN_MPY_DIR),)
|
|
|
|
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))
|
|
|
|
endif
|
|
|
|
|
|
|
|
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
|
|
|
|
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))
|
2020-02-03 20:20:29 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.S=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
|
|
|
|
|
|
|
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
|
|
|
|
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
|
|
|
|
|
|
|
|
# List of sources for qstr extraction
|
2023-09-29 10:49:34 -04:00
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(SRC_CIRCUITPY_COMMON)
|
2020-02-03 20:20:29 -05:00
|
|
|
# Sources that only hold QSTRs after pre-processing.
|
|
|
|
SRC_QSTR_PREPROCESSOR +=
|
|
|
|
|
|
|
|
|
2020-03-30 23:42:55 -04:00
|
|
|
all: $(BUILD)/firmware.bin $(BUILD)/firmware.dfu
|
2020-02-03 20:20:29 -05:00
|
|
|
|
2023-06-05 17:16:25 -04:00
|
|
|
ifeq ($(VALID_BOARD),)
|
|
|
|
$(BUILD)/firmware.elf: invalid-board
|
|
|
|
else
|
2020-02-03 20:20:29 -05:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(STEPECHO) "LINK $@"
|
2023-02-28 18:16:36 -05:00
|
|
|
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--print-memory-usage -Wl,--start-group $(LIBS) -Wl,--end-group
|
2023-03-04 03:37:38 -05:00
|
|
|
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)
|
2023-06-05 17:16:25 -04:00
|
|
|
endif
|
2020-02-03 20:20:29 -05:00
|
|
|
|
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
|
|
|
$(STEPECHO) "Create $@"
|
|
|
|
$(Q)$(OBJCOPY) -O binary $^ $@
|
|
|
|
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
|
|
|
|
|
|
|
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
|
|
|
|
$(STEPECHO) "Create $@"
|
|
|
|
$(Q)$(OBJCOPY) -O ihex $^ $@
|
|
|
|
# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
|
|
|
|
|
2020-03-30 23:42:55 -04:00
|
|
|
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
|
2020-02-03 20:20:29 -05:00
|
|
|
$(ECHO) "Create $@"
|
2021-10-15 15:59:04 -04:00
|
|
|
$(PYTHON) $(TOP)/tools/dfu.py -b $^ -D 0x1209:0x5bf0 "$(BUILD)/firmware.dfu"
|
2020-02-03 20:20:29 -05:00
|
|
|
|
|
|
|
include $(TOP)/py/mkrules.mk
|