Skip to content
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

ESP32S2 could not reassign Serial pins #9363

Closed
1 task done
dzungpv opened this issue Mar 12, 2024 · 16 comments · Fixed by #9373
Closed
1 task done

ESP32S2 could not reassign Serial pins #9363

dzungpv opened this issue Mar 12, 2024 · 16 comments · Fixed by #9373
Assignees
Milestone

Comments

@dzungpv
Copy link

dzungpv commented Mar 12, 2024

Board

Lolin S2 Mini

Device Description

Lolin S2 Mini

Hardware Configuration

GPIO 9 and 11 as UART pins

Version

v2.0.14

IDE Name

Arduino, IDF 4.4.6

Operating System

Macos 13, Windows 10

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

I use Serial1.begin(9600, SERIAL_8E1, 11, 9) it work but not with
Serial.begin(9600, SERIAL_8E1, 11, 9)

Sketch

Serial.begin(9600, SERIAL_8E1, 11, 9)

Debug Message

No debug

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@dzungpv dzungpv added the Status: Awaiting triage Issue is waiting for triage label Mar 12, 2024
@SuGlider SuGlider self-assigned this Mar 12, 2024
@SuGlider
Copy link
Collaborator

SuGlider commented Mar 13, 2024

@dzungpv - The Lolin S2 Mini has an USB port in the board that is actually the USB OTG CDC peripheral.
When this board is selected in the Arduino IDE, it will automatically enable the "CDC on Boot", therefore, Serial will be actually the USB CDC Serial.

In order to use UART0, please use Serial0 instead of Serial (USB CDC).
Serial will be the USB CDC port.
Serial0 will be the UART0 port.
Serial1 will be the UART1 port.

@SuGlider SuGlider added Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels Mar 13, 2024
@dzungpv
Copy link
Author

dzungpv commented Mar 13, 2024

@SuGlider as mention in in #9326 I still could not enable USB CDC on ESP EDF, so it only have Serial and Serial1. the S2 too limit compare to ESP32 and ESP32S3.
So this is a bug of the Core 2.0.

@SuGlider
Copy link
Collaborator

Are you using the Arduino IDE?

@SuGlider
Copy link
Collaborator

It works fine with the Arduino IDE, but enabling "USB CDC on Boot" in the tools menu.

If you need to use Arduino as IDF Component, please follow the instructions in #9326 (comment)

@dzungpv
Copy link
Author

dzungpv commented Mar 14, 2024

It works fine with the Arduino IDE, but enabling "USB CDC on Boot" in the tools menu.

If you need to use Arduino as IDF Component, please follow the instructions in #9326 (comment)

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

@SuGlider
Copy link
Collaborator

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

No, ESP32-S2 Arduino has 2 possible configurations:

  1. USB CDC on Boot is Enabled:
  • Serial is the USB CDC port and the pins can't be changed.
  • UART0 is Serial0 and UART1 is Serial1. The pins can be changed for both.
  1. USB CDC on Boot is Disabled:
  • UART0 is the Serial and UART1 is Serial1. The pins can be changed for both.

@dzungpv
Copy link
Author

dzungpv commented Mar 14, 2024

So as you say I must enable USB CDC on Boot to use UART0 on the ESP32S2 with Arduino? I mean I can assign other pin for it? I use ESP IDF with Arduino component.

No, ESP32-S2 Arduino has 2 possible configurations:

1. USB CDC on Boot is **Enabled**:


* `Serial` is the USB CDC port and the pins can't be changed.

* UART0 is `Serial0` and UART1 is `Serial1`. The pins can be changed for both.


2. USB CDC on Boot is **Disabled**:


* UART0 is the  `Serial` and UART1 is `Serial1`. The pins can be changed for both.

Yes, but my problem: could not re-assign UART0 Pin with Arduino, I test with Arduino and ESP IDF with Kaluga dev board and Lolin S2 mini. So it is impossible running 2 UART at same time, My previous design running ESP32 without any problem because it has three UART

@dzungpv
Copy link
Author

dzungpv commented Mar 14, 2024

I try with this sample for UART0 https://github.com/ncmreynolds/ld2410/blob/main/examples/basicSensor/basicSensor.ino
But I change it to use Serial when USB CDC on Boot is Disabled:

    #elif CONFIG_IDF_TARGET_ESP32S2
      #define MONITOR_SERIAL Serial1
      #define RADAR_SERIAL Serial
      #define RADAR_RX_PIN 11
      #define RADAR_TX_PIN 9

@SuGlider
Copy link
Collaborator

Ok, the issue is about reassigning UART0 pins using Arduino Core 2.0.14.
There is an improvement/fix in the PR #9176 about pin attachment.

Could you please apply this PR or just replace all 4 files: HardwareSerial.cpp, HardwareSerial.h, esp32-hal-uart.c and esp32-hal-uart.h within your Arduino Core installation?

I think that it will solve the issue. This shall be released soon within the Arduino Core 2.0.15.
Please let me know.

@dzungpv
Copy link
Author

dzungpv commented Mar 14, 2024

Ok, the issue is about reassigning UART0 pins using Arduino Core 2.0.14. There is an improvement/fix in the PR #9176 about pin attachment.

Could you please apply this PR or just replace all 4 files: HardwareSerial.cpp, HardwareSerial.h, esp32-hal-uart.c and esp32-hal-uart.h within your Arduino Core installation?

I think that it will solve the issue. This shall be released soon within the Arduino Core 2.0.15. Please let me know.

I will pull this branch and it will be OK: https://github.com/espressif/arduino-esp32/tree/release/v2.x

@SuGlider
Copy link
Collaborator

@dzungpv - Please let me know if the code from release/v2.x solves this issue. Thanks!

@dzungpv
Copy link
Author

dzungpv commented Mar 14, 2024

@dzungpv - Please let me know if the code from release/v2.x solves this issue. Thanks!

It seem not working, I tested same code but with Serial1 it work but everytime I change to Serial (cdc not enable) it not work again, same pins, same code. You should retest the code on real device.

@SuGlider
Copy link
Collaborator

@dzungpv - Issue confirmed. There is a problem with UART0 pin setup. I'll work on a PR and submit it by today.

@SuGlider SuGlider added Type: Bug 🐛 All bugs and removed Type: Question Only question labels Mar 14, 2024
@SuGlider SuGlider added this to the 2.0.15 milestone Mar 14, 2024
@SuGlider
Copy link
Collaborator

@dzungpv - Fix by #9373 - Please apply the fix to your local develoment environment and let me know if this works fine now.

@SuGlider SuGlider linked a pull request Mar 14, 2024 that will close this issue
@dzungpv
Copy link
Author

dzungpv commented Mar 15, 2024

@dzungpv - Fix by #9373 - Please apply the fix to your local develoment environment and let me know if this works fine now.

It is OK now. I tested and it work fine.

@SuGlider
Copy link
Collaborator

Closed by #9373 - ready for Core 2.0.15 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants