summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/main.c
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2014-10-21 23:04:38 -0700
committerDamien George <damien.p.george@gmail.com>2014-10-22 19:14:20 +0100
commit8d62bbd46aa178abc6e029b0ba79d915f7f988c2 (patch)
tree80b86e266347cccc1d99f9c1c362037a06c7e94b /stmhal/main.c
parent3e42570538b46d680e796136ff441ae7b8a8fac5 (diff)
downloadmicropython-8d62bbd46aa178abc6e029b0ba79d915f7f988c2.tar.gz
micropython-8d62bbd46aa178abc6e029b0ba79d915f7f988c2.zip
Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset.
Diffstat (limited to 'stmhal/main.c')
-rw-r--r--stmhal/main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/stmhal/main.c b/stmhal/main.c
index 097b8ca853..0279e70b48 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -458,7 +458,11 @@ soft_reset:
const char *boot_py = "boot.py";
FRESULT res = f_stat(boot_py, NULL);
if (res == FR_OK) {
- if (!pyexec_file(boot_py)) {
+ int ret = pyexec_file(boot_py);
+ if (ret & PYEXEC_FORCED_EXIT) {
+ goto soft_reset_exit;
+ }
+ if (!ret) {
flash_error(4);
}
}
@@ -517,7 +521,11 @@ soft_reset:
}
FRESULT res = f_stat(main_py, NULL);
if (res == FR_OK) {
- if (!pyexec_file(main_py)) {
+ int ret = pyexec_file(main_py);
+ if (ret & PYEXEC_FORCED_EXIT) {
+ goto soft_reset_exit;
+ }
+ if (!ret) {
flash_error(3);
}
}
@@ -537,6 +545,8 @@ soft_reset:
}
}
+soft_reset_exit:
+
// soft reset
printf("PYB: sync filesystems\n");