diff --git a/stmhal/main.c b/stmhal/main.c
index afef84e290f9ff2f8609894c3abf3a3d158020d2..897271d14a8d9e418412fbdf65a7fe45c02a2274 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -434,7 +434,7 @@ soft_reset:
 #endif
 
     // run main script
-    if (reset_mode == 1) {
+    if (reset_mode == 1 && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
         vstr_t *vstr = vstr_new();
         vstr_add_str(vstr, "0:/");
         if (pyb_config_source_dir == MP_OBJ_NULL) {