stm32/main: Start UART REPL as early as possible.
For debugging purposes, to see output from other peripherals. Also reset the pyb_stdio_uart state at the end of soft reset, in case it points to a heap-allocated object. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
fb1bdf0ff2
commit
b839acc7d9
@ -411,6 +411,21 @@ void stm32_main(uint32_t reset_mode) {
|
||||
rtc_init_start(false);
|
||||
#endif
|
||||
uart_init0();
|
||||
|
||||
#if defined(MICROPY_HW_UART_REPL)
|
||||
// Set up a UART REPL using a statically allocated object
|
||||
pyb_uart_repl_obj.base.type = &pyb_uart_type;
|
||||
pyb_uart_repl_obj.uart_id = MICROPY_HW_UART_REPL;
|
||||
pyb_uart_repl_obj.is_static = true;
|
||||
pyb_uart_repl_obj.timeout = 0;
|
||||
pyb_uart_repl_obj.timeout_char = 2;
|
||||
uart_init(&pyb_uart_repl_obj, MICROPY_HW_UART_REPL_BAUD, UART_WORDLENGTH_8B, UART_PARITY_NONE, UART_STOPBITS_1, 0);
|
||||
uart_set_rxbuf(&pyb_uart_repl_obj, sizeof(pyb_uart_repl_rxbuf), pyb_uart_repl_rxbuf);
|
||||
uart_attach_to_repl(&pyb_uart_repl_obj, true);
|
||||
MP_STATE_PORT(pyb_uart_obj_all)[MICROPY_HW_UART_REPL - 1] = &pyb_uart_repl_obj;
|
||||
MP_STATE_PORT(pyb_stdio_uart) = &pyb_uart_repl_obj;
|
||||
#endif
|
||||
|
||||
spi_init0();
|
||||
#if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
|
||||
i2c_init0();
|
||||
@ -446,19 +461,6 @@ void stm32_main(uint32_t reset_mode) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MICROPY_HW_UART_REPL)
|
||||
// Set up a UART REPL using a statically allocated object
|
||||
pyb_uart_repl_obj.base.type = &pyb_uart_type;
|
||||
pyb_uart_repl_obj.uart_id = MICROPY_HW_UART_REPL;
|
||||
pyb_uart_repl_obj.is_static = true;
|
||||
pyb_uart_repl_obj.timeout = 0;
|
||||
pyb_uart_repl_obj.timeout_char = 2;
|
||||
uart_init(&pyb_uart_repl_obj, MICROPY_HW_UART_REPL_BAUD, UART_WORDLENGTH_8B, UART_PARITY_NONE, UART_STOPBITS_1, 0);
|
||||
uart_set_rxbuf(&pyb_uart_repl_obj, sizeof(pyb_uart_repl_rxbuf), pyb_uart_repl_rxbuf);
|
||||
uart_attach_to_repl(&pyb_uart_repl_obj, true);
|
||||
MP_STATE_PORT(pyb_uart_obj_all)[MICROPY_HW_UART_REPL - 1] = &pyb_uart_repl_obj;
|
||||
#endif
|
||||
|
||||
boardctrl_state_t state;
|
||||
state.reset_mode = reset_mode;
|
||||
state.log_soft_reset = false;
|
||||
@ -496,12 +498,6 @@ soft_reset:
|
||||
// we can run Python scripts (eg boot.py), but anything that is configurable
|
||||
// by boot.py must be set after boot.py is run.
|
||||
|
||||
#if defined(MICROPY_HW_UART_REPL)
|
||||
MP_STATE_PORT(pyb_stdio_uart) = &pyb_uart_repl_obj;
|
||||
#else
|
||||
MP_STATE_PORT(pyb_stdio_uart) = NULL;
|
||||
#endif
|
||||
|
||||
readline_init0();
|
||||
pin_init0();
|
||||
extint_init0();
|
||||
@ -659,6 +655,12 @@ soft_reset_exit:
|
||||
pyb_thread_deinit();
|
||||
#endif
|
||||
|
||||
#if defined(MICROPY_HW_UART_REPL)
|
||||
MP_STATE_PORT(pyb_stdio_uart) = &pyb_uart_repl_obj;
|
||||
#else
|
||||
MP_STATE_PORT(pyb_stdio_uart) = NULL;
|
||||
#endif
|
||||
|
||||
MICROPY_BOARD_END_SOFT_RESET(&state);
|
||||
|
||||
gc_sweep_all();
|
||||
|
Loading…
x
Reference in New Issue
Block a user