Page 1 of 2

Making micropython with ULAB for ESP32

Posted: Mon May 04, 2020 9:38 am
by hiro_ono
I'm trying to get ulab working on my tiny-pico (has an esp32) but I'm not really sure how to get started, does anybody have a compiled version of micropython I could use? If I build my own then how would I do that?

Thanks

Re: Making micropython with ULAB for ESP32

Posted: Mon May 04, 2020 10:39 am
by DJShadow1966
Hello

You can download pre-complied binarys at https://micropython.org/download/esp32/

You can compile your own following the readme at https://github.com/micropython/micropyt ... orts/esp32

Regards Mike

Re: Making micropython with ULAB for ESP32

Posted: Mon May 04, 2020 2:45 pm
by hiro_ono
The pre compiled ones don't seem to have ulab on them, trying to make my own works fine when I don't include ulab, but when i run:
~/micropython/ports/esp32$ make BOARD=TINYPICO USER_C_MODULES=../../../ulab all




i get
CC machine_sdcard.c
CC ../../../ulab/code/ndarray.c
../../../ulab/code/ndarray.c: In function 'insert_binary_value':
../../../ulab/code/ndarray.c:320:78: error: implicit conversion from 'mp_float_t {aka float}' to 'double' to match other operand of binary expression [-Werror=double-promotion]
int32_t x = (int32_t)MICROPY_FLOAT_C_FUN(floor)(mp_obj_get_float(tmp)+0.5);
^
../../../ulab/code/ndarray.c:320:57: error: conversion to 'float' from 'double' may alter its value [-Werror=float-conversion]
int32_t x = (int32_t)MICROPY_FLOAT_C_FUN(floor)(mp_obj_get_float(tmp)+0
^
cc1: all warnings being treated as errors
../../py/mkrules.mk:63: recipe for target 'build-TINYPICO/code/ndarray.o' failed
make: *** [build-TINYPICO/code/ndarray.o] Error 1

Re: Making micropython with ULAB for ESP32

Posted: Mon May 04, 2020 3:03 pm
by Roberthh
You could try to set in mpconfigboard.h:

#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)

Re: Making micropython with ULAB for ESP32

Posted: Tue May 05, 2020 10:54 am
by hiro_ono
I tried that and it just seemed to make it even more unhappy :p

If anybody has a working compiler would they be able to build a version of micropython for BOARD=TINYPICO with ulab? I'm giving up hope at this point :?

Re: Making micropython with ULAB for ESP32

Posted: Tue May 05, 2020 12:37 pm
by stijn
The floating point conversions are because recently extra compiler flags were introduced for MicroPython. Looks like ulab isn't up to date for that, so easiest way to get this building is to change the makefile and remove -Wdouble-promotion -Wsign-compare -Wfloat-conversion

Re: Making micropython with ULAB for ESP32

Posted: Tue May 05, 2020 3:05 pm
by hiro_ono
It worked! thank you so much

Re: Making micropython with ULAB for ESP32

Posted: Mon May 18, 2020 9:05 am
by josverl
what would be a good way to change these setting (-Wdouble-promotion -Wsign-compare -Wfloat-conversion) only for the ulab files and maintain the for the rest of the code and other C modules ?


I tried various options with the make files and find that thre is much i do not understand nor can find documented.

Re: Making micropython with ULAB for ESP32

Posted: Mon May 18, 2020 1:17 pm
by stijn
Principle would be to filter those flags out of CFLAGS for just the ulab source files I guess. So I assume something like this in the C module's Makefile should work (not tested):

Code: Select all

MYMODULE_OBJ = $(addprefix $(BUILD)/, $(SRC_USERMOD:.c=.o))
$(MYMODULE_OBJ): CFLAGS := $(filter-out -Wdouble-promotion -Wsign-compare -Wfloat-conversion, $(CFLAGS))

Re: Making micropython with ULAB for ESP32

Posted: Tue Jul 28, 2020 5:43 am
by rcolistete
stijn wrote:
Mon May 18, 2020 1:17 pm
Principle would be to filter those flags out of CFLAGS for just the ulab source files I guess. So I assume something like this in the C module's Makefile should work (not tested):

Code: Select all

MYMODULE_OBJ = $(addprefix $(BUILD)/, $(SRC_USERMOD:.c=.o))
$(MYMODULE_OBJ): CFLAGS := $(filter-out -Wdouble-promotion -Wsign-compare -Wfloat-conversion, $(CFLAGS))
This issue of ulab & ESP32 persists. It doesn't happen on ports/unix, ports/stm32, ports/esp8266.

About the above suggestion : but $(MYMODULE_OBJ) should be used in some makefile (ulab 'micropython.mk' or main 'Makefile' ?) to compile/link ulab separately, no ? I don't realise the exact commands to do so.

What worked is to modify 'esp32/Makefile' :
- commenting the line :

Code: Select all

$(OBJ_MP): CFLAGS += -Wdouble-promotion -Wfloat-conversion
- or removing '-Werror' from this line :

Code: Select all

	-Wall -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable \