micropython/shared/runtime
Damien George 69c25ea865 shared/runtime/pyexec: Make a raised SystemExit always do a forced exit.
The current situation with SystemExit and soft reset is the following:
- `sys.exit()` follows CPython and just raises `SystemExit`.
- On the unix port, raising `SystemExit` quits the application/MicroPython,
  whether at the REPL or in code (this follows CPython behaviour).
- On bare-metal ports, raising `SystemExit` at the REPL does nothing,
  raising it in code will stop the code and drop into the REPL.
- `machine.soft_reset()` raises `SystemExit` but with a special flag set,
  and bare-metal targets check this flag when it propagates to the
  top-level and do a soft reset when they receive it.

The original idea here was that a bare-metal target can't "quit" like the
unix port can, and so dropping to the REPL was considered the same as
"quit".  But this bare-metal behaviour is arguably inconsistent with unix,
and "quit" should mean terminate everything, including REPL access.

This commit changes the behaviour to the following, which is more
consistent:
- Raising `SystemExit` on a bare-metal port will do a soft reset (unless
  the exception is caught by the application).
- `machine.soft_reset()` is now equivalent to `sys.exit()`.
- unix port behaviour remains unchanged.

Tested running the test suite on an stm32 board and everything still
passes, in particular tests that skip by raising `SystemExit` still
correctly skip.

Signed-off-by: Damien George <damien@micropython.org>
2024-07-20 12:13:14 +10:00
..
gchelper_generic.c shared/runtime/gchelper: Add RISC-V RV32I native gchelper. 2024-06-06 12:01:00 +10:00
gchelper_native.c shared/runtime/gchelper_native: Fix pointer cast on x86_64. 2022-11-08 19:15:37 +11:00
gchelper_rv32i.s shared/runtime/gchelper: Add RISC-V RV32I native gchelper. 2024-06-06 12:01:00 +10:00
gchelper_thumb1.s shared/runtime/gchelper: Drop cpu directive from ARM asm helpers. 2023-01-28 15:51:38 +11:00
gchelper_thumb2.s shared/runtime/gchelper: Drop cpu directive from ARM asm helpers. 2023-01-28 15:51:38 +11:00
gchelper.h shared/runtime/gchelper: Add RISC-V RV32I native gchelper. 2024-06-06 12:01:00 +10:00
interrupt_char.c shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
interrupt_char.h shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
mpirq.c all: Remove the "STATIC" macro and just use "static" instead. 2024-03-07 14:20:42 +11:00
mpirq.h shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
pyexec.c shared/runtime/pyexec: Make a raised SystemExit always do a forced exit. 2024-07-20 12:13:14 +10:00
pyexec.h shared/runtime/pyexec: Make a raised SystemExit always do a forced exit. 2024-07-20 12:13:14 +10:00
semihosting_arm.c shared/runtime/semihosting: Rename ARM semihosting files. 2024-06-06 12:55:15 +10:00
semihosting_arm.h shared/runtime/semihosting: Rename ARM semihosting files. 2024-06-06 12:55:15 +10:00
semihosting_rv32.c shared/runtime/semihosting: Add RISC-V semihosting support. 2024-06-06 12:55:21 +10:00
semihosting_rv32.h shared/runtime/semihosting: Add RISC-V semihosting support. 2024-06-06 12:55:21 +10:00
softtimer.c rp2: Refactor to not use pico-sdk alarm pool functions for sleeping. 2024-05-31 16:44:09 +10:00
softtimer.h rp2: Refactor soft timer to use hardware timer alarm. 2024-05-31 16:43:52 +10:00
stdout_helpers.c shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
sys_stdio_mphal.c all: Remove the "STATIC" macro and just use "static" instead. 2024-03-07 14:20:42 +11:00