double precision float on ESP8266

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: double precision float on ESP32

Post by rpr » Wed Jun 26, 2019 3:22 am

How does one enable building the firmware for double precision?

Edit to add: This is for an ESP32
Last edited by rpr on Wed Jun 26, 2019 5:58 am, edited 1 time in total.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: double precision float on ESP8266

Post by kevinkk525 » Wed Jun 26, 2019 5:47 am

I don't know the solution but are you looking for ESP8266 or ESP32? Your title says ESP8266 and your post ESP32..
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: double precision float on ESP8266

Post by Roberthh » Wed Jun 26, 2019 6:02 am

The place to change is mpconfigport.h in the esp32 directory. Change line:

#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
into
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: double precision float on ESP8266

Post by rpr » Wed Jun 26, 2019 7:11 am

Roberthh wrote:
Wed Jun 26, 2019 6:02 am
The place to change is mpconfigport.h in the esp32 directory. Change line:

#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
into
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
Thanks. That worked great.

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP8266

Post by glubuluck » Wed Jun 26, 2019 7:43 am

Thanks for the hint Roberthh, but i need first to understand how to build the FW.

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP8266 -> ESP32

Post by glubuluck » Wed Jun 26, 2019 9:46 am

hey
maybe i have to start a new thread for this issue but i cannot build esp32 FW.

installed xtensa, esp-idf

Code: Select all

matthieu@heronux:~/esp/micropython/ports/esp32$ make V=1
fatal: cannot change to '-s': Aucun fichier ou dossier de ce type
** WARNING **
The git hash of ESP IDF does not match the supported version
The build may complete and the firmware may work but it is not guaranteed
ESP IDF path:       </home/matthieu/esp/esp-idf/>
Current git hash:   
Supported git hash: 6b3da6b1882f3b72e904cc90be67e9c4e3f369a9
aucun répertoire fourni pour -C
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
/bin/sh: 1: cannot create /components: Permission denied
/bin/sh: 1: cannot create /components: Permission denied
/bin/sh: 1: cannot create /components: Permission denied
GEN build/sdkconfig.h
mkdir -p build/
python3 </home/matthieu/esp/esp-idf/>/tools/kconfig_new/confgen.py \
	--output header build/sdkconfig.h \
	--config boards/sdkconfig \
	--kconfig </home/matthieu/esp/esp-idf/>/Kconfig \
	--env "IDF_TARGET=esp32" \
	--env "IDF_CMAKE=n" \
	--env "COMPONENT_KCONFIGS=" \
	--env "COMPONENT_KCONFIGS_PROJBUILD="
/bin/sh: 1: cannot create /tools/kconfig_new/confgen.py: Directory nonexistent
Makefile:242: recipe for target 'build/sdkconfig.h' failed
make: *** [build/sdkconfig.h] Error 2
i followed the micropython/ports/esp32/readme but... i probably miss something..

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: double precision float on ESP8266

Post by Roberthh » Wed Jun 26, 2019 10:58 am

Yes, you have to follow the instructions step by step. Typical errors I use to make:

a) Wrong version checked out (this error is shown in your log):
In the esp-idf directory run the commands:

git checkout 6b3da6b1882f3b72e904cc90be67e9c4e3f369a9
git submodule update --init

b) Forgot git submodule init
In the esp-idf directory, issue the command:

git submodule update --init

c) ESPIDF not set
You have to set the environment variable ESPIDF to the path of the esp-idf directory. That canbe done permanent, or in the call to make. My preference is a GNUmakefile in the esp32 port directory. My example:

Code: Select all

ESPIDF = $(HOME)/Downloads/esp-idf
# SDKCONFIG = boards/sdkconfig.spiram
SDKCONFIG = boards/sdkconfig
$(info SDKCONFIG = $(SDKCONFIG))
ESPTOOL=esptool.py
MPY_CROSS_FLAGS = -march=xtensa
include Makefile
Depending on whether you device has SPIRAM, I use one of the two settings for SDKCONFIG.

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP32

Post by glubuluck » Fri Jun 28, 2019 7:24 pm

Hey,
so i restarted the building from beginning, following this :
http://www.microdev.it/wp/en/2018/08/08 ... for-esp32/

the build went on but stopped on an Error 1 :

Code: Select all

(...)
Traceback (most recent call last):
  File "/home/matthieu/esp32/esp-idf/tools/ldgen/ldgen.py", line 22, in <module>
    from fragments import FragmentFileModel
  File "/home/matthieu/esp32/esp-idf/tools/ldgen/fragments.py", line 20, in <module>
    from sdkconfig import SDKConfig
  File "/home/matthieu/esp32/esp-idf/tools/ldgen/sdkconfig.py", line 18, in <module>
    from pyparsing import Word, printables, Combine, Literal, hexnums, quotedString, Optional, nums, removeQuotes, oneOf, Group, infixNotation, opAssoc
ModuleNotFoundError: No module named 'pyparsing'
Makefile:805: recipe for target 'build/esp32.project.ld' failed
make: *** [build/esp32.project.ld] Error 1
any hint to fix it ?

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: double precision float on ESP8266

Post by rpr » Fri Jun 28, 2019 7:51 pm

See the ports/esp32 help page (README.md)

Try the following.

make PYTHON=python2

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP32

Post by glubuluck » Fri Jun 28, 2019 9:09 pm

it worked :)

and i'm with 64bit float :P

Code: Select all

>>> 10/3
3.333333333333333
>>> 2*math.acos(0)
3.141592653589793
thanks a lot !

Matthieu

Post Reply