From 6d0629bddcac1fede980ba24a1285ab670bca640 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Fri, 18 Dec 2015 21:07:58 +0000
Subject: [PATCH] esp8266: Enable float support, using 30-bit stuffed floats.

No complex numbers though.
---
 esp8266/Makefile       | 4 ++++
 esp8266/esp8266.ld     | 1 +
 esp8266/mpconfigport.h | 4 +++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/esp8266/Makefile b/esp8266/Makefile
index b836248c6..f6681eefa 100644
--- a/esp8266/Makefile
+++ b/esp8266/Makefile
@@ -72,6 +72,10 @@ STM_SRC_C = $(addprefix stmhal/,\
 
 LIB_SRC_C = $(addprefix lib/,\
 	libc/string0.c \
+	libm/math.c \
+	libm/fmodf.c \
+	libm/roundf.c \
+	libm/ef_sqrt.c \
 	mp-readline/readline.c \
 	netutils/netutils.c \
 	timeutils/timeutils.c \
diff --git a/esp8266/esp8266.ld b/esp8266/esp8266.ld
index e2f1b807e..15f923239 100644
--- a/esp8266/esp8266.ld
+++ b/esp8266/esp8266.ld
@@ -81,6 +81,7 @@ SECTIONS
 
         /* we put some specific text in this section */
         *py/*.o*(.literal* .text*)
+        *lib/libm/*.o*(.literal*, .text*)
         *pyexec.o(.literal*, .text*)
         *readline.o(.literal*, .text*)
         *pybstdio.o(.literal*, .text*)
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index c80f78d45..53eda128b 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -2,6 +2,7 @@
 
 // options to control how Micro Python is built
 
+#define MICROPY_OBJ_REPR            (MICROPY_OBJ_REPR_C)
 #define MICROPY_ALLOC_PATH_MAX      (128)
 #define MICROPY_EMIT_X64            (0)
 #define MICROPY_EMIT_THUMB          (0)
@@ -15,6 +16,7 @@
 #define MICROPY_HELPER_LEXER_UNIX   (0)
 #define MICROPY_ENABLE_SOURCE_LINE  (1)
 #define MICROPY_MODULE_WEAK_LINKS   (1)
+#define MICROPY_PY_BUILTINS_COMPLEX (0)
 #define MICROPY_PY_BUILTINS_STR_UNICODE (1)
 #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
 #define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
@@ -35,7 +37,7 @@
 #define MICROPY_PY_SYS_STDFILES     (1)
 #define MICROPY_CPYTHON_COMPAT      (0)
 #define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
-#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_NONE)
+#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_FLOAT)
 #define MICROPY_ERROR_REPORTING     (MICROPY_ERROR_REPORTING_TERSE)
 #define MICROPY_MODULE_FROZEN       (1)
 
-- 
GitLab