Skip to content

Commit

Permalink
ports: Make all ports skip execution of main.py if boot.py fails.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
robert-hh authored and dpgeorge committed Oct 12, 2023
1 parent d2a9d70 commit 480659b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions ports/esp32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ void mp_task(void *pvParameter) {

// 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;
Expand Down
4 changes: 2 additions & 2 deletions ports/esp8266/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ports/nrf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ int main(int argc, char **argv) {

#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 (;;) {
Expand Down
2 changes: 1 addition & 1 deletion ports/rp2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 480659b

Please sign in to comment.