summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2023-10-11 09:55:14 +0200
committerDamien George <damien@micropython.org>2023-10-12 11:53:29 +1100
commit480659b1ac758c377568c93c0ccda6a232f744ca (patch)
tree4dfe05b96f66505b9d3ecffe79f2acac2e0428db
parentd2a9d70c0977f02b4d52fa5e6d31f17c2a7aa313 (diff)
ports: Make all ports skip execution of main.py if boot.py fails.
That can be caused e.g. by an exception. This feature is implemented in some way already for the stm32, renesas-ra, mimxrt and samd ports. This commit adds it for the rp2, esp8266, esp32 and nrf ports. No change for the cc3200 and teensy ports. Signed-off-by: robert-hh <robert@hammelrath.com>
-rw-r--r--ports/esp32/main.c7
-rw-r--r--ports/esp8266/main.c4
-rw-r--r--ports/nrf/main.c6
-rw-r--r--ports/rp2/main.c2
4 files changed, 12 insertions, 7 deletions
diff --git a/ports/esp32/main.c b/ports/esp32/main.c
index b514f44e0..044b43655 100644
--- a/ports/esp32/main.c
+++ b/ports/esp32/main.c
@@ -124,8 +124,11 @@ soft_reset:
// run boot-up scripts
pyexec_frozen_module("_boot.py", false);
- pyexec_file_if_exists("boot.py");
- if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
+ int ret = pyexec_file_if_exists("boot.py");
+ if (ret & PYEXEC_FORCED_EXIT) {
+ goto soft_reset_exit;
+ }
+ if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) {
int ret = pyexec_file_if_exists("main.py");
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
diff --git a/ports/esp8266/main.c b/ports/esp8266/main.c
index 11ac5b63f..7c940ac2a 100644
--- a/ports/esp8266/main.c
+++ b/ports/esp8266/main.c
@@ -83,8 +83,8 @@ STATIC void mp_reset(void) {
#if MICROPY_MODULE_FROZEN
pyexec_frozen_module("_boot.py", false);
- pyexec_file_if_exists("boot.py");
- if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
+ int ret = pyexec_file_if_exists("boot.py");
+ if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) {
pyexec_file_if_exists("main.py");
}
#endif
diff --git a/ports/nrf/main.c b/ports/nrf/main.c
index 7f35c7f1b..650a47e16 100644
--- a/ports/nrf/main.c
+++ b/ports/nrf/main.c
@@ -263,8 +263,10 @@ soft_reset:
#if MICROPY_VFS || MICROPY_MBFS || MICROPY_MODULE_FROZEN
// run boot.py and main.py if they exist.
- pyexec_file_if_exists("boot.py");
- pyexec_file_if_exists("main.py");
+ ret = pyexec_file_if_exists("boot.py");
+ if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) {
+ pyexec_file_if_exists("main.py");
+ }
#endif
for (;;) {
diff --git a/ports/rp2/main.c b/ports/rp2/main.c
index 72b243a59..682ea1447 100644
--- a/ports/rp2/main.c
+++ b/ports/rp2/main.c
@@ -179,7 +179,7 @@ int main(int argc, char **argv) {
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
- if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
+ if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) {
ret = pyexec_file_if_exists("main.py");
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;