From 3a4ebf57685e2ea03deb61276f832108b4ab08b7 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Fri, 9 Dec 2016 17:05:51 +1100
Subject: [PATCH] esp8266: Enable inline Xtensa assembler.

With this patch, @micropython.asm_xtensa can be used on the esp8266 port.
---
 esp8266/main.c              | 2 +-
 esp8266/modesp.c            | 4 ++--
 esp8266/mpconfigport.h      | 1 +
 esp8266/mpconfigport_512k.h | 2 ++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/esp8266/main.c b/esp8266/main.c
index 1e988ef33..9883f9f96 100644
--- a/esp8266/main.c
+++ b/esp8266/main.c
@@ -58,7 +58,7 @@ STATIC void mp_reset(void) {
     MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
     MP_STATE_PORT(term_obj) = MP_OBJ_NULL;
     MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL;
-    #if MICROPY_EMIT_XTENSA
+    #if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA
     extern void esp_native_code_init(void);
     esp_native_code_init();
     #endif
diff --git a/esp8266/modesp.c b/esp8266/modesp.c
index 302bc01ed..a20769abc 100644
--- a/esp8266/modesp.c
+++ b/esp8266/modesp.c
@@ -699,7 +699,7 @@ STATIC mp_obj_t esp_esf_free_bufs(mp_obj_t idx_in) {
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_esf_free_bufs_obj, esp_esf_free_bufs);
 
-#if MICROPY_EMIT_XTENSA
+#if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA
 
 // We provide here a way of committing executable data to a region from
 // which it can be executed by the CPU.  There are 2 such writable regions:
@@ -822,7 +822,7 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
     { MP_OBJ_NEW_QSTR(MP_QSTR_malloc), (mp_obj_t)&esp_malloc_obj },
     { MP_OBJ_NEW_QSTR(MP_QSTR_free), (mp_obj_t)&esp_free_obj },
     { MP_OBJ_NEW_QSTR(MP_QSTR_esf_free_bufs), (mp_obj_t)&esp_esf_free_bufs_obj },
-    #if MICROPY_EMIT_XTENSA
+    #if MICROPY_EMIT_XTENSA || MICROPY_EMIT_INLINE_XTENSA
     { MP_OBJ_NEW_QSTR(MP_QSTR_set_native_code_location), (mp_obj_t)&esp_set_native_code_location_obj },
     #endif
 
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 40550024b..d15a7cdd4 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -11,6 +11,7 @@
 #define MICROPY_ALLOC_PARSE_CHUNK_INIT  (64)
 #define MICROPY_PERSISTENT_CODE_LOAD (1)
 #define MICROPY_EMIT_XTENSA         (1)
+#define MICROPY_EMIT_INLINE_XTENSA  (1)
 #define MICROPY_MEM_STATS           (0)
 #define MICROPY_DEBUG_PRINTERS      (1)
 #define MICROPY_DEBUG_PRINTER_DEST  mp_debug_print
diff --git a/esp8266/mpconfigport_512k.h b/esp8266/mpconfigport_512k.h
index 1bb452405..d1d602579 100644
--- a/esp8266/mpconfigport_512k.h
+++ b/esp8266/mpconfigport_512k.h
@@ -2,6 +2,8 @@
 
 #undef MICROPY_EMIT_XTENSA
 #define MICROPY_EMIT_XTENSA             (0)
+#undef MICROPY_EMIT_INLINE_XTENSA
+#define MICROPY_EMIT_INLINE_XTENSA      (0)
 
 #undef MICROPY_FSUSERMOUNT
 #define MICROPY_FSUSERMOUNT             (0)
-- 
GitLab