B4R Question Error after updating ESP32 boards

janderkan

Well-Known Member
Licensed User
Longtime User
My code is working fine using ESP32 boards version 1.0.6, but after upgrading to version 2.0.0 I get the following error when initializing second hardware serial port,
B4X:
E (64) uart: uart_set_pin(595): tx_io_num error
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x4008ba60
file: "C:\Users\Jan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\cores\esp32\esp32-hal-uart.c" line 135
func: uartBegin
expression: uart_set_pin(uart_nr, txPin, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)
abort() was called at PC 0x4008ba63 on core 1
Backtrace:0x400e9001:0x3ffb25f00x4008ba71:0x3ffb2610 0x400915f1:0x3ffb2630 0x4008ba63:0x3ffb26b0 0x400df02a:0x3ffb26d0 0x400de4d1:0x3ffb2730 0x400d5dbd:0x3ffb2770 0x400d5e77:0x3ffb27a0 0x400d51ac:0x3ffb27c0 0x400d90d6:0x3ffb2800 0x400deddb:0x3ffb2820
ELF file SHA256: 0000000000000000
Rebooting...

using this code
B4X:
#if C
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(9600, SERIAL_8N1, 26, 35);;//<--use pin 26/35 as RX/TX
b4r_modgps::_serialnative->wrappedStream = &::Serial2;
}
#End If

Found a thread that said to initialize Serial2 object first.
B4X:
#if C
HardwareSerial Serial2(2); // Second Hardware Port
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(9600, SERIAL_8N1, 26, 35);;//<--use pin 26/35 as RX/TX
b4r_modgps::_serialnative->wrappedStream = &::Serial2;
}
#End If

But this just gave me another error
B4X:
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\Jan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1

Downgrading to 1.0.6 and all is working again but I would like to use the latest version.

Jan
 

thetahsk

Active Member
Licensed User
Longtime User
But the program will not compile and exits with status 1
B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private SerialNative2 As Stream
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    RunNative("SerialN2", Null)
End Sub


#if C

// HardwareSerial Serial2(2); // Second Hardware Port
void SerialN2(B4R::Object* unused)
{
::Serial2.begin(115200);
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#End If

Please check this.
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Yes, the code works.
But If I try to use this:
B4X:
#if C
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(9600, SERIAL_8N1, 26, 35);;//<--use pin 26/35 as RX/TX
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#End If
I gets this error:
B4X:
AppStart
E (19) uart: uart_set_pin(595): tx_io_num error
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x400879f4
file: "C:\Users\Jan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\cores\esp32\esp32-hal-uart.c" line 135
func: uartBegin
expression: uart_set_pin(uart_nr, txPin, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)
abort() was called at PC 0x400879f7 on core 1
Backtrace:0x400d9531:0x3ffb26300x40087a01:0x3ffb2650 0x4008c7ed:0x3ffb2670 0x400879f7:0x3ffb26f0 0x400d2592:0x3ffb2710 0x400d1919:0x3ffb2770 0x400d15c9:0x3ffb27b0 0x400d15fb:0x3ffb27e0 0x400d1646:0x3ffb2800 0x400d216b:0x3ffb2820
ELF file SHA256: 0000000000000000
Rebooting...

It works on ESP32 1.0.6 but fails on ESP32 2.0.0
 
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Solved !

I only use RX to receive from my GPS.
So I just used the free IO35 as TX.
IO34 and IO35 are readonly.

So by selecting another IO or use -1 as TX, the error disappeared.

B4X:
#if C
void SerialNative2(B4R::Object* unused)
{
::Serial2.begin(9600, SERIAL_8N1, 26, -1);;//<--use pin 26/-1 as RX/TX
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#End If
 
Upvote 1

thetahsk

Active Member
Licensed User
Longtime User
Upvote 0
Top