kopia lustrzana https://github.com/micropython/micropython
samd: Add support for building with user C modules.
Fixes issue #7545. Signed-off-by: Damien George <damien@micropython.org>pull/7557/head
rodzic
7649f5fbd2
commit
a5ac3d5645
|
@ -33,7 +33,11 @@ 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_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 = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
|
||||||
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
|
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
|
||||||
|
CFLAGS += $(CFLAGS_MOD)
|
||||||
|
|
||||||
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
|
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
|
||||||
|
LDFLAGS += $(LDFLAGS_MOD)
|
||||||
|
|
||||||
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||||
|
|
||||||
# Tune for Debugging or Optimization
|
# Tune for Debugging or Optimization
|
||||||
|
@ -45,6 +49,14 @@ LDFLAGS += --gc-sections
|
||||||
CFLAGS += -fdata-sections -ffunction-sections
|
CFLAGS += -fdata-sections -ffunction-sections
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
SRC_C = \
|
SRC_C = \
|
||||||
main.c \
|
main.c \
|
||||||
modutime.c \
|
modutime.c \
|
||||||
|
@ -70,6 +82,10 @@ SRC_C = \
|
||||||
shared/runtime/pyexec.c \
|
shared/runtime/pyexec.c \
|
||||||
shared/runtime/stdout_helpers.c \
|
shared/runtime/stdout_helpers.c \
|
||||||
|
|
||||||
|
SRC_C += $(SRC_MOD)
|
||||||
|
|
||||||
|
SRC_CXX += $(SRC_MOD_CXX)
|
||||||
|
|
||||||
ifeq ($(MCU_SERIES),SAMD21)
|
ifeq ($(MCU_SERIES),SAMD21)
|
||||||
SRC_S = shared/runtime/gchelper_m0.s
|
SRC_S = shared/runtime/gchelper_m0.s
|
||||||
else
|
else
|
||||||
|
@ -77,10 +93,11 @@ SRC_S = shared/runtime/gchelper_m3.s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# List of sources for qstr extraction
|
# List of sources for qstr extraction
|
||||||
SRC_QSTR += modutime.c modmachine.c
|
SRC_QSTR += modutime.c modmachine.c $(SRC_MOD) $(SRC_CXX)
|
||||||
|
|
||||||
OBJ += $(PY_O)
|
OBJ += $(PY_O)
|
||||||
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||||
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
||||||
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||||
|
|
||||||
# Workaround for bug in older gcc, warning on "static usbd_device_t _usbd_dev = { 0 };"
|
# Workaround for bug in older gcc, warning on "static usbd_device_t _usbd_dev = { 0 };"
|
||||||
|
|
|
@ -87,6 +87,11 @@ void nlr_jump_fail(void *val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void abort(void) {
|
||||||
|
for (;;) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
|
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
|
||||||
mp_printf(MP_PYTHON_PRINTER, "Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
mp_printf(MP_PYTHON_PRINTER, "Assertion '%s' failed, at file %s:%d\n", expr, file, line);
|
||||||
|
|
|
@ -11,10 +11,20 @@ SECTIONS
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
_sidata = _etext;
|
|
||||||
} >FLASH
|
} >FLASH
|
||||||
|
|
||||||
.data : AT ( _sidata )
|
/* For C++ exception handling */
|
||||||
|
.ARM :
|
||||||
|
{
|
||||||
|
__exidx_start = .;
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
__exidx_end = .;
|
||||||
|
} >FLASH
|
||||||
|
|
||||||
|
/* Used by the start-up code to initialise data */
|
||||||
|
_sidata = LOADADDR(.data);
|
||||||
|
|
||||||
|
.data :
|
||||||
{
|
{
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_sdata = .;
|
_sdata = .;
|
||||||
|
@ -22,7 +32,7 @@ SECTIONS
|
||||||
*(.data*)
|
*(.data*)
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_edata = .;
|
_edata = .;
|
||||||
} >RAM
|
} >RAM AT> FLASH
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue