8000 esp8266/main: Activate UART(0) on dupterm for REPL before boot.py runs. · micropython/micropython@36808d4 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit 36808d4

Browse files
committed
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.
1 parent 5064df2 commit 36808d4

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

ports/esp8266/main.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,25 @@ STATIC void mp_reset(void) {
6363
pin_init0();
6464
readline_init0();
6565
dupterm_task_init();
66-
#if MICROPY_MODULE_FROZEN
67-
pyexec_frozen_module("_boot.py");
68-
pyexec_file("boot.py");
69-
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
70-
pyexec_file("main.py");
71-
}
72-
#endif
7366

74 8000 -
// Check if there are any dupterm objects registered and if not then
75-
// activate UART(0), or else there will never be any chance to get a REPL
76-
size_t idx;
77-
for (idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) {
78-
if (MP_STATE_VM(dupterm_objs[idx]) != MP_OBJ_NULL) {
79-
break;
80-
}
81-
}
82-
if (idx == MICROPY_PY_OS_DUPTERM) {
67+
// Activate UART(0) on dupterm slot 1 for the REPL
68+
{
8369
mp_obj_t args[2];
8470
args[0] = MP_OBJ_NEW_SMALL_INT(0);
8571
args[1] = MP_OBJ_NEW_SMALL_INT(115200);
8672
args[0] = pyb_uart_type.make_new(&pyb_uart_type, 2, 0, args);
8773
args[1] = MP_OBJ_NEW_SMALL_INT(1);
8874
extern mp_obj_t os_dupterm(size_t n_args, const mp_obj_t *args);
8975
os_dupterm(2, args);
90-
mp_hal_stdout_tx_str("Activated UART(0) for REPL\r\n");
9176
}
77+
78+
#if MICROPY_MODULE_FROZEN
79+
pyexec_frozen_module("_boot.py");
80+
pyexec_file("boot.py");
81+
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
82+
pyexec_file("main.py");
83+
}
84+
#endif
9285
}
9386

9487
void soft_reset(void) {

ports/esp8266/modules/inisetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def setup():
4545
#import esp
4646
#esp.osdebug(None)
4747
import uos, machine
48-
uos.dupterm(machine.UART(0, 115200), 1)
48+
#uos.dupterm(None, 1) # disable REPL on UART(0)
4949
import gc
5050
#import webrepl
5151
#webrepl.start()

0 commit comments

Comments
 (0)
0