Skip to content

fix(uart): Permit UART speeds over 460800 on ESP32 Arduino 3.0 #11025

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

Closed

Conversation

ewpa
Copy link

@ewpa ewpa commented Mar 1, 2025

Description of Change

Regression fix: Permit UART speeds over 460800 on ESP32 Arduino 3.0 and later. UART speeds above 460800 were functional on ESP32 Arduino 2.0.

Tests scenarios

Tested on ESP32 Arduino 3.0.5.

Related links

  • b1ackviking: "Console sets UART clock source to REF_TICK on ESP32 and ESP32S2 by default, however, APB clock frequency does not change when power management is disabled. Using APB clock source allows higher baud rates for UART console."
  • Merge espressif/esp-idf PR#8572: "fix(console): use apb clock source for uart when power management is disabled (IDFGH-6952)"
  • Closes Issue UART speeds above 460800 on ESP32 no longer functional since v3.0. #11024.

@CLAassistant
Copy link

CLAassistant commented Mar 1, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Mar 1, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "fix(uart): Permit UART speeds over 460800 on ESP32 Arduino 3.0 and later.":
    • footer must have leading blank line
    • summary should not end with a period (full stop)

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

⚠️
	The **target branch** for this Pull Request **must be the default branch** of the project (`master`).

	If you would like to add this feature to a different branch, please state this in the PR description and we will consider it.

👋 Hello ewpa, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 03e3bed

…ter.

  - UART speeds above 460800 were functional on ESP32 Arduino 2.0.
  - b1ackviking: Console sets UART clock source to REF_TICK on ESP32
    and ESP32S2 by default, however, APB clock frequency does not change
    when power management is disabled. Using APB clock source allows
    higher baud rates for UART console.
  - Merge espressif/esp-idf PR#8572: "fix(console): use apb clock source
    for uart when power management is disabled"
@ewpa ewpa force-pushed the allow-higher-console-baud-rates branch from df528e7 to 87a5d73 Compare March 1, 2025 16:12
@ewpa ewpa changed the title Regression fix: Permit UART speeds over 460800 on ESP32 Arduino 3.0 fix(uart): Permit UART speeds over 460800 on ESP32 Arduino 3.0 Mar 1, 2025
@me-no-dev me-no-dev requested a review from SuGlider March 2, 2025 12:35
@SuGlider
Copy link
Collaborator

SuGlider commented Mar 2, 2025

@ewpa -
ESP32 Arduino has all SoC with CONFIG_PM_ENABLE disabled:
sdkconfig

#
# Power Management
#
# CONFIG_PM_ENABLE is not set
# CONFIG_PM_SLP_IRAM_OPT is not set
# end of Power Management

The suggested change (testing #elif defined(CONFIG_PM_ENABLE) && SOC_UART_SUPPORT_REF_TICK) would simply remove part of the code forever:

  // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
  // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
#if SOC_UART_SUPPORT_XTAL_CLK
  uart_config.source_clk = UART_SCLK_XTAL;  // valid for C2, S3, C3, C6, H2 and P4
#elif defined(CONFIG_PM_ENABLE) && SOC_UART_SUPPORT_REF_TICK
  if (baudrate <= REF_TICK_BAUDRATE_LIMIT) {
    uart_config.source_clk = UART_SCLK_REF_TICK;  // valid for ESP32, S2 - MAX supported baud rate is 250 Kbps
  } else {
    uart_config.source_clk = UART_SCLK_APB;  // if power management is enabled baudrate may change with the APB Frequency!
  }
#else
  // Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6
  uart_config.source_clk = UART_SCLK_DEFAULT;  // baudrate may change with the APB Frequency!
#endif

If the baudrate is set to 460,800, it will be over REF_TICK_BAUDRATE_LIMIT (250,000) and the UART Source Clock will be set as UART_SCLK_APB, which is the same as UART_SCLK_DEFAULT.

Please explain how this PR would be effective for the issue you have presented.

@ewpa
Copy link
Author

ewpa commented Mar 2, 2025

Hi @SuGlider, thank you for taking a look. What you are saying makes sense so I will need to review this PR further to see why it appears to make a positive impact in my case (i.e. UART rate of 921600 and above).

Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

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

This change is not recommended.

@ewpa
Copy link
Author

ewpa commented Mar 5, 2025

Agreed, I withdraw this PR. See Issue #11024 for alternatives.

@ewpa ewpa closed this Mar 5, 2025
@ewpa ewpa deleted the allow-higher-console-baud-rates branch March 5, 2025 17:28
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