Skip to content

Commit acc2084

Browse files
dhylandsdpgeorge
authored andcommitted
stmhal: Execute boot.py and main.py when formatting the file system.
When you use the USER button to perform a filesystem reset at boot time then it wipes out the filesystem and creates a new boot.py and main.py. With this patch these files are executed after formatting, ensuring that pyb and machine modules get imported.
1 parent 2b7236d commit acc2084

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

stmhal/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ int main(void) {
529529

530530
// run boot.py, if it exists
531531
// TODO perhaps have pyb.reboot([bootpy]) function to soft-reboot and execute custom boot.py
532-
if (reset_mode == 1) {
532+
if (reset_mode == 1 || reset_mode == 3) {
533533
const char *boot_py = "boot.py";
534534
FRESULT res = f_stat(boot_py, NULL);
535535
if (res == FR_OK) {
@@ -585,7 +585,7 @@ int main(void) {
585585
// At this point everything is fully configured and initialised.
586586

587587
// Run the main script from the current directory.
588-
if (reset_mode == 1 && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
588+
if ((reset_mode == 1 || reset_mode == 3) && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
589589
const char *main_py;
590590
if (MP_STATE_PORT(pyb_config_main) == MP_OBJ_NULL) {
591591
main_py = "main.py";

0 commit comments

Comments
 (0)