Skip to content

Update UART selection for Boot ROM ets_putc, when debug port is selected. #6489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mhightower83
Copy link
Contributor

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.
This only applies to a debug build where Debug Port has been selected.

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 the 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.

::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.
@mhightower83
Copy link
Contributor Author

Sorry - I need to rethink the placement of this call. I am now thinking it should be in function uart_set_debug() file uart.cpp

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.
@mhightower83
Copy link
Contributor Author

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.

@mhightower83 mhightower83 reopened this Sep 12, 2019
Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and thanks for the plentiful comments explaining the logic behind things!

mhightower83 added a commit to mhightower83/Arduino that referenced this pull request Sep 23, 2019
Replaced relevent usage of `(void *)` with `fn_putc1_t`.
Correct usage of `ets_putc()`, returning 0, in libc_replacement.cpp
This PR assumes PR esp8266#6489 (comment) has merged and removes `uart_buff_switch` from `umm_performance.cpp`
Updated method of defining `_rom_putc1` to be more acceptable (I hope) to the new compiler.
@earlephilhower earlephilhower merged commit f3ca090 into esp8266:master Sep 23, 2019
earlephilhower pushed a commit that referenced this pull request Sep 27, 2019
* Add typedef for putc1, fn_putc1_t.
Replaced relevant usage of `(void *)` with `fn_putc1_t`.
Correct usage of `ets_putc()`, returning 0, in libc_replacement.cpp
This PR assumes PR #6489 (comment) has merged and removes `uart_buff_switch` from `umm_performance.cpp`
Updated method of defining `_rom_putc1` to be more acceptable (I hope) to the new compiler.

* Use PROVIDE to expose ROM function entry point, ets_uart_putc1.
Added comments to ets_putc() and ets_uart_putc1() to explain their
differences. Change prototype of ets_putc() to conform with fp_putc_t.
Updated _isr_safe_printf_P to use new definition, ets_uart_putc1.
@mhightower83 mhightower83 deleted the pr_uart_select_for_ets_putc branch September 27, 2019 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants