Skip to content

Commit 424d52b

Browse files
committed
build: MICROPY_FLOAT_IMPL
original PR: pycom#470 Implement make option MICROPY_FLOAT_IMPL on Pycom/ESP32, so it is simpler to build Pycom/ESP32 firmware with single or double precision float point numbers. For example : [esp32]$ make -j8 MICROPY_FLOAT_IMPL=double instead of changing the 'esp32/mpconfigport.h', line : #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) to #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) Batch scripts to build many Pycom/ESP32 firmware variants with combinations of boards (WIPY LOPY SIPY GPY FIPY LOPY4), single/double precision, etc, become possible. In this way the Pycom/ESP32 building workflow becomes more compatible with MicroPython STM32 mainline workflow.
1 parent 96f1673 commit 424d52b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

esp32/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ CFLAGS_XTENSA_PSRAM = -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-stra
144144
CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
145145
CFLAGS_SIGFOX = $(CFLAGS_XTENSA) -O2 -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
146146

147+
# Configure floating point support
148+
ifeq ($(MICROPY_FLOAT_IMPL),double)
149+
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE
150+
else
151+
ifeq ($(MICROPY_FLOAT_IMPL),none)
152+
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE
153+
else
154+
ifeq ($(MICROPY_FLOAT_IMPL),single)
155+
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT
156+
endif
157+
endif
158+
endif
159+
147160
# These flags are used as per the output when linking examples/wifi/scan
148161
# -u ld_include_panic_highint_hdl is needed so esp32/dport_panic_panic_highint_hdl.S is linked and xt_highint4 is used from there,
149162
# otherwise xt_highint4 is used from freertos/xtensa/xtensa_vector_defaults.S which has incorrect implementation and results DPORT core lockup

esp32/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
#define MICROPY_PY_UTIMEQ (1)
102102
#define MICROPY_CPYTHON_COMPAT (1)
103103
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
104+
#ifndef MICROPY_FLOAT_IMPL // can be configured by make option
104105
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
106+
#endif
105107
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
106108
#define MICROPY_OPT_COMPUTED_GOTO (1)
107109
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)

0 commit comments

Comments
 (0)