mimxrt: Add floating point support.

Since not all boards support double fp, all board specific .mk files are
affected too.
This commit is contained in:
robert-hh 2021-05-26 11:29:34 +02:00 committed by Damien George
parent 2f365d234e
commit a40e1473dc
7 changed files with 121 additions and 0 deletions

View File

@ -67,6 +67,21 @@ CFLAGS += -DXIP_EXTERNAL_FLASH=1 \
-DCPU_HEADER_H='<$(MCU_SERIES).h>'
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
# Configure floating point support
ifeq ($(MICROPY_FLOAT_IMPL),double)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE
else
ifeq ($(MICROPY_FLOAT_IMPL),none)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE
else
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT
CFLAGS += -fsingle-precision-constant
endif
endif
SUPPORTS_HARDWARE_FP_SINGLE = 0
SUPPORTS_HARDWARE_FP_DOUBLE = 0
LDFLAGS = $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref --print-memory-usage
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
@ -140,6 +155,99 @@ SRC_C = \
$(SRC_TINYUSB_C) \
$(SRC_TINYUSB_IMX_C) \
ifeq ($(MICROPY_FLOAT_IMPL),double)
LIBM_SRC_C += $(addprefix lib/libm_dbl/,\
__cos.c \
__expo2.c \
__fpclassify.c \
__rem_pio2.c \
__rem_pio2_large.c \
__signbit.c \
__sin.c \
__tan.c \
acos.c \
acosh.c \
asin.c \
asinh.c \
atan.c \
atan2.c \
atanh.c \
ceil.c \
cos.c \
cosh.c \
copysign.c \
erf.c \
exp.c \
expm1.c \
floor.c \
fmod.c \
frexp.c \
ldexp.c \
lgamma.c \
log.c \
log10.c \
log1p.c \
modf.c \
nearbyint.c \
pow.c \
rint.c \
round.c \
scalbn.c \
sin.c \
sinh.c \
tan.c \
tanh.c \
tgamma.c \
trunc.c \
)
ifeq ($(SUPPORTS_HARDWARE_FP_DOUBLE),1)
LIBM_SRC_C += lib/libm_dbl/thumb_vfp_sqrt.c
else
LIBM_SRC_C += lib/libm_dbl/sqrt.c
endif
else
LIBM_SRC_C += $(addprefix lib/libm/,\
math.c \
acoshf.c \
asinfacosf.c \
asinhf.c \
atan2f.c \
atanf.c \
atanhf.c \
ef_rem_pio2.c \
erf_lgamma.c \
fmodf.c \
kf_cos.c \
kf_rem_pio2.c \
kf_sin.c \
kf_tan.c \
log1pf.c \
nearbyintf.c \
roundf.c \
sf_cos.c \
sf_erf.c \
sf_frexp.c \
sf_ldexp.c \
sf_modf.c \
sf_sin.c \
sf_tan.c \
wf_lgamma.c \
wf_tgamma.c \
)
ifeq ($(SUPPORTS_HARDWARE_FP_SINGLE),1)
LIBM_SRC_C += lib/libm/thumb_vfp_sqrtf.c
else
LIBM_SRC_C += lib/libm/ef_sqrt.c
endif
endif
LIBM_O = $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o))
# Too many warnings in libm_dbl, disable for now.
ifeq ($(MICROPY_FLOAT_IMPL),double)
$(LIBM_O): CFLAGS := $(filter-out -Wdouble-promotion -Wfloat-conversion, $(CFLAGS))
endif
SRC_SS = $(MCU_DIR)/gcc/startup_$(MCU_SERIES).S
SRC_S = lib/utils/gchelper_m3.s \
@ -160,6 +268,7 @@ SRC_QSTR += \
$(GEN_PINS_SRC) \
OBJ += $(PY_O)
OBJ += $(LIBM_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_SS:.S=.o))

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1011
MCU_VARIANT = MIMXRT1011DAE5A
MICROPY_FLOAT_IMPL = single
JLINK_PATH = /media/RT1010-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1021
MCU_VARIANT = MIMXRT1021DAG5A
MICROPY_FLOAT_IMPL = double
JLINK_PATH ?= /media/RT1020-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1052
MCU_VARIANT = MIMXRT1052DVL6B
MICROPY_FLOAT_IMPL = double
JLINK_PATH ?= /media/RT1050-EVK/
deploy: $(BUILD)/firmware.bin

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1062
MCU_VARIANT = MIMXRT1062DVJ6A
MICROPY_FLOAT_IMPL = double
JLINK_PATH ?= /media/RT1060-EVK/
JLINK_COMMANDER_SCRIPT = $(BUILD)/script.jlink

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1064
MCU_VARIANT = MIMXRT1064DVL6A
MICROPY_FLOAT_IMPL = double
JLINK_PATH ?= /media/RT1064-EVK/
CFLAGS += -DBOARD_FLASH_SIZE=0x400000

View File

@ -1,6 +1,8 @@
MCU_SERIES = MIMXRT1062
MCU_VARIANT = MIMXRT1062DVJ6A
MICROPY_FLOAT_IMPL = double
deploy: $(BUILD)/firmware.hex
teensy_loader_cli --mcu=imxrt1062 -v -w $<
sleep 1