stm32/boardctrl: Adjust logic for running boot.py, main.py.

This new logic is equivalent to the old logic when the only possibilities
for reset_mode are NORMAL, SAFE_MODE and FILESYSTEM, which is the standard
case.  But the new logic also allows other reset_mode values (eg
BOOTLOADER) to run boot.py and main.py.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2021-05-06 10:49:43 +10:00
parent ee4ffc1804
commit 9ee116c452
1 changed files with 2 additions and 4 deletions

View File

@ -143,8 +143,7 @@ void boardctrl_top_soft_reset_loop(boardctrl_state_t *state) {
}
int boardctrl_run_boot_py(boardctrl_state_t *state) {
bool run_boot_py = state->reset_mode == BOARDCTRL_RESET_MODE_NORMAL
|| state->reset_mode == BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM;
bool run_boot_py = state->reset_mode != BOARDCTRL_RESET_MODE_SAFE_MODE;
if (run_boot_py) {
// Run boot.py, if it exists.
@ -176,8 +175,7 @@ int boardctrl_run_boot_py(boardctrl_state_t *state) {
}
int boardctrl_run_main_py(boardctrl_state_t *state) {
bool run_main_py = (state->reset_mode == BOARDCTRL_RESET_MODE_NORMAL
|| state->reset_mode == BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM)
bool run_main_py = state->reset_mode != BOARDCTRL_RESET_MODE_SAFE_MODE
&& pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL;
if (run_main_py) {