Skip to content

ESP32 : make option MICROPY_FLOAT_IMPL#6294

Closed
rcolistete wants to merge 1 commit intomicropython:masterfrom
rcolistete:esp32_FLOAT_option
Closed

ESP32 : make option MICROPY_FLOAT_IMPL#6294
rcolistete wants to merge 1 commit intomicropython:masterfrom
rcolistete:esp32_FLOAT_option

Conversation

@rcolistete
Copy link
Copy Markdown
Contributor

Implement make option MICROPY_FLOAT_IMPL on ESP32, so it is simpler to build 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 ESP32 firmware variants with combinations of boards (GENERIC, GENERIC_SPIRAM, etc), single/double precision, etc, become possible.

This option MICROPY_FLOAT_IMPL can also be configured by each board via $BOARD/mpconfigboard.mk.

In this way the ESP32 building workflow becomes more compatible with STM32 one.

@stinos
Copy link
Copy Markdown
Contributor

stinos commented Jul 29, 2020

Does the STM32 also have a flag like this?
Because as far as I know this is the same as doing make CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE" i.e. it works already like that for all other platforms.

@rcolistete
Copy link
Copy Markdown
Contributor Author

Does the STM32 also have a flag like this?
Because as far as I know this is the same as doing make CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE" i.e. it works already like that for all other platforms.

Yes, micropython/ports/stm32/Makefile has this MICROPY_FLOAT_IMPL flag due to the following code :

# 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

From which I adapted, except the line :
CFLAGS += -fsingle-precision-constant

@rcolistete
Copy link
Copy Markdown
Contributor Author

rcolistete commented Jul 29, 2020

Also, the majority (all?) of people compiling ESP32 with double precision is changing the 'esp32/mpconfigport.h' file :

as they don't see (on ESP32) the make flag/option used by STM32 :

@stinos
Copy link
Copy Markdown
Contributor

stinos commented Jul 29, 2020

Ah I just figured STM32 has this flag because it also alters the build itself (like adding lib/libm_dbl source when using double) so for STM32 just setting CFLAGS_EXTRA won't cut it.

@rcolistete
Copy link
Copy Markdown
Contributor Author

rcolistete commented Jul 29, 2020

Does the STM32 also have a flag like this?
Because as far as I know this is the same as doing make CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE" i.e. it works already like that for all other platforms.

After a Internet search, I don't see one example at all using this flag (CFLAGS_EXTRA=...) to compile double precision, besides the Makefile. So this flag is less known by the community, not cited in any docs/tutorial/forum.

Again, it is a lot more practical and known to use :

$ make MICROPY_FLOAT_IMPL=double

@dpgeorge
Copy link
Copy Markdown
Member

This is now obsolete, after the move to CMake.

So I'll close the PR. Feel free to rework it so it works with the latest code and reopen.

@dpgeorge dpgeorge closed this Jan 21, 2022
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request May 12, 2022
Update documentation for end param in SPI.readinto()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants