diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 943b16c8f91f5a708bb04aea555dc7a5b127b37a..05f2cb913b862ae57c5b8561d415a1740c45d0f0 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -69,6 +69,15 @@
 #define MICROPY_VFS_FAT                (1)
 
 #define MICROPY_EVENT_POLL_HOOK {ets_event_poll();}
+#define MICROPY_VM_HOOK_COUNT (10)
+#define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
+#define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \
+        vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
+        extern void ets_loop_iter(void); \
+        ets_loop_iter(); \
+    }
+#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
+#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
 
 // type definitions for the specific machine