187 lines
5.6 KiB
Makefile
187 lines
5.6 KiB
Makefile
|
# This file is part of the MicroPython project, http://micropython.org/
|
||
|
#
|
||
|
# The MIT License (MIT)
|
||
|
#
|
||
|
# Copyright 2019 Sony Semiconductor Solutions Corporation
|
||
|
#
|
||
|
# 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.
|
||
|
|
||
|
include ../../py/mkenv.mk
|
||
|
|
||
|
# Port-specific
|
||
|
include mpconfigport.mk
|
||
|
|
||
|
# CircuitPython-specific
|
||
|
include $(TOP)/py/circuitpy_mpconfig.mk
|
||
|
|
||
|
# qstr definitions (must come before including py.mk)
|
||
|
QSTR_DEFS = qstrdefsport.h
|
||
|
|
||
|
# include py core make definitions
|
||
|
include $(TOP)/py/py.mk
|
||
|
|
||
|
include $(TOP)/supervisor/supervisor.mk
|
||
|
|
||
|
# Include make rules and variables common across CircuitPython builds.
|
||
|
include $(TOP)/py/circuitpy_defns.mk
|
||
|
|
||
|
CROSS_COMPILE = arm-none-eabi-
|
||
|
|
||
|
SPRESENSE_SDK = spresense-exported-sdk
|
||
|
|
||
|
FIRMWARE = $(SPRESENSE_SDK)/firmware
|
||
|
|
||
|
INC += \
|
||
|
-I. \
|
||
|
-I../.. \
|
||
|
-I../lib/mp-readline \
|
||
|
-I../lib/timeutils \
|
||
|
-I../../lib/tinyusb/src \
|
||
|
-I../../supervisor/shared/usb \
|
||
|
-I$(BUILD) \
|
||
|
-I$(SPRESENSE_SDK)/nuttx/include \
|
||
|
-I$(SPRESENSE_SDK)/nuttx/arch \
|
||
|
-I$(SPRESENSE_SDK)/nuttx/arch/chip \
|
||
|
-I$(SPRESENSE_SDK)/sdk/bsp/include \
|
||
|
-I$(SPRESENSE_SDK)/sdk/bsp/include/sdk \
|
||
|
|
||
|
CFLAGS += \
|
||
|
$(INC) \
|
||
|
-DCONFIG_WCHAR_BUILTIN \
|
||
|
-DCONFIG_HAVE_DOUBLE \
|
||
|
-Dmain=spresense_main \
|
||
|
-D_estack=__stack \
|
||
|
-c \
|
||
|
-Os \
|
||
|
-pipe \
|
||
|
-std=gnu11 \
|
||
|
-mcpu=cortex-m4 \
|
||
|
-mthumb \
|
||
|
-mfpu=fpv4-sp-d16 \
|
||
|
-mfloat-abi=hard \
|
||
|
-mabi=aapcs \
|
||
|
-fno-builtin \
|
||
|
-fno-strict-aliasing \
|
||
|
-fno-strength-reduce \
|
||
|
-fomit-frame-pointer \
|
||
|
-ffunction-sections \
|
||
|
-fdata-sections \
|
||
|
-Wall \
|
||
|
|
||
|
LIBM = "${shell "$(CC)" $(CFLAGS) -print-file-name=libm.a}"
|
||
|
|
||
|
LIBGCC = "${shell "$(CC)" $(CFLAGS) -print-libgcc-file-name}"
|
||
|
|
||
|
LDFLAGS = \
|
||
|
--entry=__start \
|
||
|
-nostartfiles \
|
||
|
-nodefaultlibs \
|
||
|
--defsym __stack=_vectors+786432 \
|
||
|
-T$(SPRESENSE_SDK)/nuttx/build/ramconfig.ld \
|
||
|
--gc-sections \
|
||
|
-Map=$(BUILD)/output.map \
|
||
|
-o $(BUILD)/circuitpython.elf \
|
||
|
--start-group \
|
||
|
-u spresense_main \
|
||
|
$(BUILD)/libmpy.a \
|
||
|
$(SPRESENSE_SDK)/sdk/libs/libapps.a \
|
||
|
$(SPRESENSE_SDK)/sdk/libs/libsdk.a \
|
||
|
$(LIBM) \
|
||
|
$(LIBGCC) \
|
||
|
--end-group \
|
||
|
-L$(BUILD) \
|
||
|
|
||
|
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_CXD56 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=512 $(CFLAGS_MOD)
|
||
|
|
||
|
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))
|
||
|
|
||
|
SRC_S = supervisor/cpu.s
|
||
|
|
||
|
SRC_C = \
|
||
|
tick.c \
|
||
|
background.c \
|
||
|
fatfs_port.c \
|
||
|
mphalport.c \
|
||
|
lib/utils/stdout_helpers.c \
|
||
|
lib/utils/pyexec.c \
|
||
|
lib/libc/string0.c \
|
||
|
lib/mp-readline/readline.c \
|
||
|
lib/timeutils/timeutils.c \
|
||
|
lib/oofatfs/ff.c \
|
||
|
lib/oofatfs/option/ccsbcs.c \
|
||
|
lib/utils/interrupt_char.c \
|
||
|
lib/utils/sys_stdio_mphal.c \
|
||
|
lib/utils/context_manager_helpers.c \
|
||
|
lib/utils/buffer_helper.c \
|
||
|
supervisor/shared/memory.c \
|
||
|
lib/tinyusb/src/portable/sony/cxd56/dcd_cxd56.c \
|
||
|
|
||
|
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||
|
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
||
|
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
|
||
|
|
||
|
# List of sources for qstr extraction
|
||
|
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
|
||
|
# Sources that only hold QSTRs after pre-processing.
|
||
|
SRC_QSTR_PREPROCESSOR +=
|
||
|
|
||
|
all: $(BUILD)/circuitpython.spk
|
||
|
|
||
|
$(FIRMWARE):
|
||
|
$(ECHO) ""
|
||
|
$(ECHO) "Download the spresense binaries zip archive from:"
|
||
|
$(ECHO) "https://developer.sony.com/file/download/download-spresense-firmware-v1-4-000"
|
||
|
$(ECHO) "Extract spresense binaries to $(FIRMWARE)"
|
||
|
$(ECHO) ""
|
||
|
$(ECHO) "run make flash-bootloader again to flash bootloader."
|
||
|
exit 1
|
||
|
|
||
|
$(BUILD)/libmpy.a: $(SPRESENSE_SDK) $(OBJ)
|
||
|
$(ECHO) "AR $@"
|
||
|
$(Q)$(AR) rcs $(BUILD)/libmpy.a $(OBJ)
|
||
|
|
||
|
$(BUILD)/circuitpython.elf: $(BUILD)/libmpy.a
|
||
|
$(ECHO) "LD $@"
|
||
|
$(Q)$(LD) $(LDFLAGS)
|
||
|
|
||
|
$(BUILD)/circuitpython.spk: $(BUILD)/circuitpython.elf
|
||
|
$(ECHO) "Creating $@"
|
||
|
$(SPRESENSE_SDK)/sdk/tools/linux/mkspk -c 2 $(BUILD)/circuitpython.elf nuttx $(BUILD)/circuitpython.spk
|
||
|
|
||
|
flash: $(BUILD)/circuitpython.spk
|
||
|
$(ECHO) "Writing $< to the board"
|
||
|
$(SPRESENSE_SDK)/sdk/tools/flash.sh -c /dev/ttyUSB0 $(BUILD)/circuitpython.spk
|
||
|
|
||
|
flash-bootloader: $(SPRESENSE_SDK) $(FIRMWARE)
|
||
|
$(ECHO) "Writing loader to the board"
|
||
|
$(SPRESENSE_SDK)/sdk/tools/flash.sh -l $(FIRMWARE) -c /dev/ttyUSB0
|
||
|
|
||
|
include $(TOP)/py/mkrules.mk
|
||
|
|
||
|
# Print out the value of a make variable.
|
||
|
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||
|
print-%:
|
||
|
@echo $* = $($*)
|