cpu/esp32: fix and improve UART initialization [backport 2023.01]#19148
Merged
bors[bot] merged 5 commits intoJan 15, 2023
Merged
Conversation
If LOG_LEVEL >= 4, such as in `tests/log_printfnoformat`, the ESP-IDF config function called for the GPIO pins of the UART will output the configuration with `printf` before the `_GLOBAL_REENT` structure is initialized. This causes a crash during system startup. Therefore the initialization by `syscalls_init` must be called earlier in the startup procedure.
Since PR RIOT-OS#19100 it is possible to define: - other pins for `UART_DEV(0)` than the default pins - different `UART_DEV(0)` pins for the bootloader and RIOT To allow correct reinitialization of the UART pins used by the bootloader as well as their usage for other purposes, the pin usage for the default UART0 pins and the UART pins used by the bootloader are reset to `_GPIO`. This is done in `uart_system_init` which has to be called earlier in the startup procedure.
The TX line is set and temporarily configured as a pull-up open-drain output before configuring it as a push-pull output to avoid a several msec long LOW pulse resulting in some garbage.
To avoid garbage on reconfiguring the UART console pins, e.g. in initialization of the `arduino` module, pins that are already configured as UART pins must not be initialized.
Member
|
bors merge |
Contributor
|
Build succeeded: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #19146
Contribution description
This PR fixes issue #19138 that was introduced with PR #19100. It contains the following changes to fix the problems and to improve the UART initialization:
If
LOG_LEVELis greater or equal 4, such as intests/log_printfnoformat, the ESP-IDF config function called for the GPIO pins of the UART will output the configuration withprintfbefore the_GLOBAL_REENTstructure is initialized. This causes a crash during system startup. Therefore the initialization bysyscalls_initmust be called by `earlier in the startup procedure.Since PR cpu/esp_common: allow configuration of UART0 #19100 it is possible to define:
UART_DEV(0)than the default pinsUART_DEV(0)pins for the bootloader and RIOTTo allow correct reinitialization of the UART pins used by the bootloader as well as their usage for other purposes, the pin usage for the default UART0 pins and the UART pinsused by the bootloader are reset to
_GPIO. This is done inuart_system_initwhich has to be called earlier in the startup procedure.To avoid garbage on reconfiguring the UART console pins, e.g. in initialization of the
arduinomodule, pins that are already configured as UART pins must not be initialized.To avoid a several msec long LOW pulse resulting in some garbage during the UART initialization, the TX line is set to HIGH and temporarily configured as a pull-up open-drain output before configuring it as a push-pull output.
The PR requires a backport to 2023.1
Testing procedure
The following tests should work with this PR:
tests/log_colortests/log_printfnoformattests/sys_arduinoIssues/PRs references
Fixes #19138