Closed zul00 closed 5 months ago
I forgot to mention that there is no problem on espressif32@6.7.0
if I use USBCDC
as the streamer, i.e. Serial
Do you have this issue if you use the vanilla esp32s3 variant rather than the Nano?
I have an access to an ESP32-S3-EYE, I will test it later
@zul00 - When using PlatformIO + Arduino Core 2.0.16 or 2.0.14, please add ARDUINO_USB_MODE=1
to your PlatformIO.ini setup.
The PlatformIO ESP32 Nano board definition lacks the ARDUINO_USB_MODE
definition. This is the source the the issue.
https://github.com/platformio/platform-espressif32/blob/develop/boards/arduino_nano_esp32.json
ARDUINO_USB_MODE=1 ==> HW USB Serial JTAG interface of the S3 ARDUINO_USB_MODE=0 ==> USB OTG (TinyUSB) interface of the S3
ARDUINO_USB_CDC_ON_BOOT=1 ==> Using this setting, Serial0
is UART0 and Serial
is the USB CDC interface.
ARDUINO_USB_CDC_ON_BOOT=0 ==> Serial
is defined as the UART0 interface. Using this, Serial0
isn't defined and it shall produce a compilation error.
CORE_DEBUG_LEVEL=5 ==> sets a debug level message output. Level: 0 to 5.
[env:arduino_nano_esp32]
; NOTE: We got an issue with Serial0 on v6.7.0
; espressif v6.7.0 uses arduino v2.0.16; idf v4.4.7
; device went into reboot loop
;
; On espressif v6.6.0 which uses arduino v2.0.14; it works fine
platform = espressif32@6.7.0
framework = arduino
board = arduino_nano_esp32
build_flags =
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DCORE_DEBUG_LEVEL=5
I tested the configuration above, but I still got a reboot loop with a report that UART0
is not installed. Below is the snapshot
10:40:19.139 > ESP-ROM:esp32s3-20210327
10:40:19.442 > Build:Mar 27 2021
10:40:19.442 > rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
10:40:19.474 > Saved PC:0x420248d6
10:40:19.474 > SPIWP:0xee
10:40:19.474 > mode:DIO, clock div:1
10:40:19.474 > load:0x3fce3808,len:0x44c
10:40:19.474 > load:0x403c9700,len:0xbe4
10:40:19.474 > load:0x403cc700,len:0x2a68
10:40:19.474 > entry 0x403c98d4
10:40:19.561 > [ 92][V][esp32-hal-ledc.c:231] analogWrite(): GPIO 46 - Using Channel 7, Value = 183
10:40:19.561 > [ 100][V][esp32-hal-ledc.c:231] analogWrite(): GPIO 0 - Using Channel 6, Value = 255
10:40:19.561 > [ 108][V][esp32-hal-ledc.c:231] analogWrite(): GPIO 45 - Using Channel 5, Value = 71
...
10:40:22.444 > [ 3006][V][esp32-hal-ledc.c:231] analogWrite(): GPIO 45 - Using Channel 5, Value = 255
10:40:22.495 > [ 3036][I][esp32-hal-psram.c:96] psramInit(): PSRAM enabled
10:40:22.495 > [ 3046][V][esp32-hal-uart.c:330] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(115) txPin(0)
10:40:22.495 > [ 3055][V][esp32-hal-uart.c:416] uartBegin(): UART0 not installed. Starting installation
10:40:22.495 > ESP-ROM:esp32s3-20210327
10:40:22.828 > Build:Mar 27 2021
10:40:22.828 > rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
10:40:22.828 > Saved PC:0x420248d6
10:40:22.828 > SPIWP:0xee
10:40:22.828 > mode:DIO, clock div:1
10:40:22.828 > load:0x3fce3808,len:0x44c
10:40:22.828 > load:0x403c9700,len:0xbe4
10:40:22.828 > load:0x403cc700,len:0x2a68
10:40:22.828 > entry 0x403c98d4
What is weird is that it mentioned about initializing the uart0 on an incorrect pin.
I adjusted the sketch to
void setup() {
Serial0.begin(115200, SERIAL_8N1, SOC_RX0, SOC_TX0); // or
// Serial0.begin(115200, SERIAL_8N1, 44, 43);
}
But the result is still the same. I am guessing that is happening before it went into the setup
from the sketch, right?
@zul00 - Arduino ESP32 Nano board has an exclusive pin remapping scheme
Please use the pins as defined in the pinout pdf file or/and in this header file: https://github.com/espressif/arduino-esp32/blob/master/variants/arduino_nano_nora/pins_arduino.h
void setup() {
Serial0.begin(115200, SERIAL_8N1, D0, D1); // or
// Serial0.begin(115200, SERIAL_8N1, RX, TX); // this also works for the ESP32 Nano
// Serial0.begin(115200, SERIAL_8N1, 44, 43); <-- remapped
}
Thanks @SuGlider !
Now I understand that there is a remap there. So this one also works :)
Serial0.begin(115200, SERIAL_8N1, 0, 1);
So I think the problem with the sketch below is because in the framework-arduinoespressif32/cores/esp32/HardwareSerial.cpp
the serial pins default to SOC_RX0
and SOC_TX0
.
Serial0.begin(115200);
And those SOC_*
pins are not defined when BOARD_HAS_PIN_REMAP
is set. Where this flag is by default set for this particular board.
Should there be a fix? Maybe HardwareSerial can have an #ifndef
for SOC_* with
#ifdeffor
R/TX? or
#ifdeffor
BOARD_HAS_PIN_REMAP`?
If you think that is a good idea, I am willing to contribute :)
There are a few ways to fix it.
The SOC_*
pins could be defined in the pins_arduino.h
ESP32 Nano board file.
Or the mapping function shall check if the requested pin does exist and return -1
, which means that it shouldn't be changed.
The main problem is that the mapping function defined in the variant folder of this board returns a value from an array, but the array max number of items is shorter than 43 or 44 (Rx/Tx real pins), causing it to return trash values for the "pins" out of the array range.
Looks this ticket was already answered, closing. If needed, you can reopen it.
Board
Arduino Nano ESP32
Device Description
Default devkit from Arduino
Hardware Configuration
The UART0 bus is connected to an FTDI serial adapter
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Ubuntu 22.04
Flash frequency
240Mhz
PSRAM enabled
yes
Upload speed
115200
Description
My platform was on espressif32@6.7.0 which uses arduino@2.0.16. When using the setup above I got a reboot loop upon using Serial0, I expect there is no reboot loop.
Below is the message that was captured from UART0 port
However, if I downgraded the platform to espressif32@6.6.0 which uses arduino@2.0.14, it works as expected.
I am new to both Arduino and PlatformIO, so let me know if I posted in the correct repository.
Thanks, Zul
Sketch
PlatformIO configuration
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide