summaryrefslogtreecommitdiff
path: root/ports/esp8266/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-01-10 00:53:38 +1100
committerDamien George <damien.p.george@gmail.com>2019-01-16 17:24:23 +1100
commit36808d4e6a6cfa632f5c8fcd02742a7ad657eaef (patch)
tree76f06c125c1e6db619ee03e371b414204eaff09c /ports/esp8266/main.c
parent5064df2074dfd8bdc61f16ab3cbc2d695c10c3a6 (diff)
esp8266/main: Activate UART(0) on dupterm for REPL before boot.py runs.
So that the user can explicitly deactivate UART(0) if needed. See issue #4314. This introduces some risk to "brick" the device, if the user disables the REPL without providing an alternative REPL (eg WebREPL), or any way to reenable it. In such a case the device needs to be erased and reprogrammed. This seems unavoidable, given the desire to have the option to use the UART for something other than the REPL.
Diffstat (limited to 'ports/esp8266/main.c')
-rw-r--r--ports/esp8266/main.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/ports/esp8266/main.c b/ports/esp8266/main.c
index 482e32e4d..923e4530f 100644
--- a/ports/esp8266/main.c
+++ b/ports/esp8266/main.c
@@ -63,23 +63,9 @@ STATIC void mp_reset(void) {
pin_init0();
readline_init0();
dupterm_task_init();
-#if MICROPY_MODULE_FROZEN
- pyexec_frozen_module("_boot.py");
- pyexec_file("boot.py");
- if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
- pyexec_file("main.py");
- }
-#endif
- // Check if there are any dupterm objects registered and if not then
- // activate UART(0), or else there will never be any chance to get a REPL
- size_t idx;
- for (idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) {
- if (MP_STATE_VM(dupterm_objs[idx]) != MP_OBJ_NULL) {
- break;
- }
- }
- if (idx == MICROPY_PY_OS_DUPTERM) {
+ // Activate UART(0) on dupterm slot 1 for the REPL
+ {
mp_obj_t args[2];
args[0] = MP_OBJ_NEW_SMALL_INT(0);
args[1] = MP_OBJ_NEW_SMALL_INT(115200);
@@ -87,8 +73,15 @@ STATIC void mp_reset(void) {
args[1] = MP_OBJ_NEW_SMALL_INT(1);
extern mp_obj_t os_dupterm(size_t n_args, const mp_obj_t *args);
os_dupterm(2, args);
- mp_hal_stdout_tx_str("Activated UART(0) for REPL\r\n");
}
+
+ #if MICROPY_MODULE_FROZEN
+ pyexec_frozen_module("_boot.py");
+ pyexec_file("boot.py");
+ if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
+ pyexec_file("main.py");
+ }
+ #endif
}
void soft_reset(void) {