Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit ca973bd

Browse files
committed
qemu-arm: Enable software floating point support, and float tests.
This helps to test floating point code on Cortex-M hardware. As part of this patch the link-time-optimisation was disabled because it wasn't compatible with software FP support. In particular, the linker could not find the __aeabi_f2d, __aeabi_d2f etc functions even though they were provided by lib/libm/math.c.
1 parent cd527bb commit ca973bd

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

qemu-arm/Makefile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ INC += -I..
1414
INC += -I$(BUILD)
1515
INC += -I../tools/tinytest/
1616

17-
CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3
17+
CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
1818
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT) \
19-
-flto -ffunction-sections -fdata-sections
19+
-ffunction-sections -fdata-sections
2020

2121
#Debugging/Optimization
2222
ifeq ($(DEBUG), 1)
@@ -40,6 +40,27 @@ SRC_C = \
4040
SRC_TEST_C = \
4141
test_main.c \
4242

43+
LIB_SRC_C = $(addprefix lib/,\
44+
libm/math.c \
45+
libm/fmodf.c \
46+
libm/roundf.c \
47+
libm/ef_sqrt.c \
48+
libm/kf_rem_pio2.c \
49+
libm/kf_sin.c \
50+
libm/kf_cos.c \
51+
libm/kf_tan.c \
52+
libm/ef_rem_pio2.c \
53+
libm/sf_sin.c \
54+
libm/sf_cos.c \
55+
libm/sf_tan.c \
56+
libm/sf_frexp.c \
57+
libm/sf_modf.c \
58+
libm/sf_ldexp.c \
59+
libm/asinfacosf.c \
60+
libm/atanf.c \
61+
libm/atan2f.c \
62+
)
63+
4364
STM_SRC_C = $(addprefix stmhal/,\
4465
pybstdio.c \
4566
)
@@ -50,12 +71,14 @@ OBJ =
5071
OBJ += $(PY_O)
5172
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
5273
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
74+
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
5375
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
5476

5577
OBJ_TEST =
5678
OBJ_TEST += $(PY_O)
5779
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
5880
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
81+
OBJ_TEST += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
5982
OBJ_TEST += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
6083
OBJ_TEST += $(BUILD)/tinytest.o
6184

qemu-arm/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define MICROPY_HELPER_LEXER_UNIX (0)
1515
#define MICROPY_ENABLE_SOURCE_LINE (1)
1616
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
17-
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
17+
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
1818
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
1919
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
2020
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)

tools/tinytest-codegen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ def script_to_map(t):
4646

4747
## XXX: may be we could have `--without <groups>` argument...
4848
# currently these tests are selected because they pass on qemu-arm
49-
test_dirs = ('basics', 'micropython', 'extmod', 'inlineasm') # 'float', 'import', 'io', 'misc')
49+
test_dirs = ('basics', 'micropython', 'float', 'extmod', 'inlineasm') # 'import', 'io', 'misc')
5050
exclude_tests = (
51+
'float/float2int_doubleprec.py', # requires double precision floating point to work
5152
'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py',
5253
'extmod/ticks_diff.py', 'extmod/time_ms_us.py',
53-
'extmod/ujson_dumps_float.py', 'extmod/ujson_loads_float.py',
54-
'extmod/uctypes_native_float.py', 'extmod/uctypes_le_float.py',
5554
'extmod/machine_pinbase.py', 'extmod/machine_pulse.py',
5655
'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py',
5756
)

0 commit comments

Comments
 (0)