Skip to content

Commit f3ca090

Browse files
mhightower83earlephilhower
authored andcommitted
Update UART selection for Boot ROM ets_putc, when debug port is selected. (#6489)
* Add code to select the UART for Boot ROM ets_putc which is used by ::printf, ets_printf_P in core_esp_postmortem.cpp and others. ets_putc is a wrapper for uart_tx_one_char. uart_tx_one_char uses the element buff_uart_no in UartDev (A structure in data area of the Boot ROM) to select UART0 or UART1. uart_buff_switch is used to set that entry. The structure for UartDev can be found in uart.h from the ESP8266_NONOS_SDK. As best I can tell the Boot ROM always defaults to UART0. * Fixes debug UART selection for ets_putc This addresses an issue of UART selection for ROM function ets_putc, which is used by ::printf, ets_printf_P in core_esp_postmortem.cpp and others. Currently ets_putc stays on UART0 after Serial1.setDebugOutput(true) is called. ets_putc() is not affected by calls to ets_install_putc1. Its UART selection is controlled by the ROM function uart_buff_switch. Updated uart_set_debug() to call uart_buff_switch whenever debug is enabled on an UART. For the case of disabling, a call to select UART0 is made, because there is no disable option for this print method. * Removed fp_putc_t typedef, save for a later PR
1 parent 308e131 commit f3ca090

File tree

2 files changed

+106
-77
lines changed

2 files changed

+106
-77
lines changed

cores/esp8266/esp8266_undocumented.h

+21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ extern int rom_i2c_readReg_Mask(int, int, int, int, int);
1111

1212
extern int uart_baudrate_detect(int, int);
1313

14+
/*
15+
ROM function, uart_buff_switch(), is used to switch printing between UART0 and
16+
UART1. It updates a structure that only controls a select group of print
17+
functions. ets_putc() and ets_uart_printf() are examples and are not affected by
18+
calls to ets_install_putc1().
19+
20+
Use:
21+
0 for UART0, also clears RX FIFO
22+
1 for UART1
23+
*/
24+
extern void uart_buff_switch(uint8_t);
25+
26+
/*
27+
ROM function, ets_uart_printf(), prints on the UART selected by
28+
uart_buff_switch(). Supported format options are the same as vprintf(). Also
29+
has cooked newline behavior. No flash format/string support; however, ISR safe.
30+
Also, uses a static function in ROM to print characters which is only
31+
controlled by uart_buff_switch().
32+
*/
33+
extern int ets_uart_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
34+
1435
extern void ets_delay_us(uint32_t us);
1536

1637
#ifdef __cplusplus

0 commit comments

Comments
 (0)