diff --git a/esp8266/main.c b/esp8266/main.c
index fd07efcbf29297ef296f95956b549018694c32a8..888e589704a2f0faba83e6d872cf6aca491da41c 100644
--- a/esp8266/main.c
+++ b/esp8266/main.c
@@ -65,7 +65,9 @@ STATIC void mp_reset(void) {
 #if MICROPY_MODULE_FROZEN
     pyexec_frozen_module("_boot.py");
     pyexec_file("boot.py");
-    pyexec_file("main.py");
+    if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
+        pyexec_file("main.py");
+    }
 #endif
 }