arduino-esp32
arduino-esp32 copied to clipboard
3.0.0 version Migration related issues
Hello,
purpose of this issue is to cover problems related to migration from 2.X (at the moment of writing the latest version is 2.0.14) to 3.X version.
💥 If you have any problems, please add comment to this issue. :boom:
3.0.0 version introduces breaking changes in those APIs:
- ADC
- BLE
- Hall Sensor
- I2S
- LEDC
- RMT
- SigmaDelta
- TIMER
- UART
- WiFi
🎉 For more details plese take a look on MIGRATION GUIDE FROM 2.X TO 3.X. 🎉
List of all related issues: (will be updated)
Please take a look on those issue before adding comment to this ticket.
- #8776
- #8737
- #8746
- #8765
- #8780
- #8783
- #8774
- #8809
- #9169
I think this is also related: #8774
The OneWire lib does not compile anymore, because GPIO is not defined.
libs/OneWire/OneWire.h:167:17: error: 'GPIO' was not declared in this scope; did you mean 'PI'?
167 | return (GPIO.in >> pin) & 0x1;
| ^~~~
| PI
~This can be fixed by including:~
#if ESP_ARDUINO_VERSION_MAJOR >= 3
#include <driver/gpio.h>
#include <hal/rtc_io_ll.h>
#else
#include <driver/rtc_io.h>
#endif
~And then using the functions:~
~rtcio_ll_get_level, rtcio_ll_set_level, rtcio_ll_input_enable and rtcio_ll_output_enable~
~where appropriate.~
Real fix is:
#if ESP_ARDUINO_VERSION_MAJOR >= 3
#include <soc/gpio_struct.h>
#else
#include <driver/rtc_io.h>
#endif
The OneWire lib does not compile anymore, because GPIO is not defined.
Probably needs particular include. Some have changed in IDF5
I have difficulty porting the following code to IDF5. Please look at the line below FIXME! HELP NEEDED!.
error: cannot convert 'wifi_interface_t' to 'esp_netif_t*' {aka 'esp_netif_obj*'}
esp_netif_get_ip_info(WIFI_IF_AP, &info);
Snippet:
#ifdef ESP32
#ifdef IDF5
typedef esp_netif_ip_info_t ip_info_t;
#else
typedef tcpip_adapter_ip_info_t ip_info_t;
#endif
#endif
#ifdef ESP8266
typedef struct ip_info ip_info_t;
#endif
static ip_info_t ap_ip_info(void) {
ip_info_t info = { 0 };
#ifdef ESP32
#ifdef IDF5
// FIXME! HELP NEEDED!
// esp_netif_get_ip_info(WIFI_IF_AP, &info);
#else // !IDF5
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &info);
#endif // !IDF5
#endif // ESP32
#ifdef ESP8266
wifi_get_ip_info(SOFTAP_IF, &info);
#endif
return (info);
}
Are wifi_interface_t and esp_netif_t incompatible types or can I just take the address of the former and cast it to the latter?
@everslick https://github.com/espressif/esp-idf/blob/v5.1/examples/protocols/http_server/captive_portal/main/dns_server.c#L152
One VERY peculiar thing I just witnessed: Calling yield() in a very tight loop seems to crash with exception 29 (LoadProhibited), while PC points to a few lines above the call to yield() which makes it especially difficult to debug. Luckily I have yield() wrapped in my own system_yield() so I can switch codepaths between versions (and work around the bug). Like:
void system_yield(void) {
#ifdef IDF5
delay(1);
#else
yield();
#endif
#ifdef HAVE_WATCHDOG
watchdog_feed();
#endif
}
When the tight loop, yield() is called in, gets slowed down enough (with e.g. debug prints) it does not crash.
@everslick I am rewriting/restructuring the whole network stack in order to decouple WiFi from the rest of the network functions. Many things have changed and will be fixed/rewritten to work. Some APIs will change/get deprecated, but it's for the better.
@everslick I am rewriting/restructuring the whole network stack in order to decouple WiFi from the rest of the network functions. Many things have changed and will be fixed/rewritten to work. Some APIs will change/get deprecated, but it's for the better.
Yes, I've seen the issue for it. I'm very much looking forward to it!
While we are at it. One of the things I do not really like about the Arduino API is the omnipresent instantiation of singleton like APIs. We have NO_GLOBAL_INSTANCES for that, but this is not always implemented for all interfaces. In case of WiFi, it is so baked in, that nothing works anymore if the global WiFi object is not there. Maybe, if possible, this is something to consider, when reworking the API.
WiFi would be able to not be global, but beware a new Network class will be, though it's very light and has only events and dns queries.
@me-no-dev Are you going to implement IPv6 with the rework of the network / wifi part? Nice to have a working DNS when Ethernet and WiFi is used together in the future;-)
@Jason2866 IPv6 is planned for 3.0.0/1 it's coming for sure :)
Not sure if this belongs here, w5500+ETH using latest git version, installed manually on windows 11. Running Example ETH_W5500_Arduino_SPI. I have two boards, very possible they have two different versions of W5500. One works fine, but one gives the following very randomly.
E (127) w5500.mac: W5500 version mismatched, expected 0x04, got 0xfe
E (128) w5500.mac: emac_w5500_init(795): vefiry chip ID failed
E (128) esp_eth: esp_eth_driver_install(228): init mac failed
E (3033) w5500.mac: w5500_send_command(204): send command timeout
E (3033) w5500.mac: emac_w5500_receive(675): issue RECV command failed
E (3034) w5500.mac: frame read from module failed
E (4139) w5500.mac: w5500_send_command(204): send command timeout
E (4139) w5500.mac: emac_w5500_receive(675): issue RECV command failed
E (4140) w5500.mac: frame read from module failed
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00380038 PS : 0x00060930 A0 : 0x00000000 A1 : 0x3ffb5140
A2 : 0x3ffb4960 A3 : 0x00380038 A4 : 0x40110378 A5 : 0x3ffb5ac4
A6 : 0x000005f2 A7 : 0x00000000 A8 : 0x80110778 A9 : 0x3ffb5100
A10 : 0x3ffb59d0 A11 : 0x3ffb5ac4 A12 : 0x0000fffc A13 : 0x0000fffc
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x00000014
EXCVADDR: 0x00380038 LBEG : 0x40089948 LEND : 0x4008995e LCOUNT : 0xffffffff
Backtrace: 0x00380035:0x3ffb5140
ELF file SHA256: 2dd9d9d7fcebe907
Rebooting...
ets Jun 8 2016 00:22:57
If I repower the board, Sometimes it starts working. Other times, it may give a different set of error messages, like this one.
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1256
load:0x40078000,len:13832
load:0x40080400,len:4
load:0x40080404,len:3048
entry 0x40080590
E (127) w5500.mac: w5500_reset(302): reset timeout
E (128) w5500.mac: emac_w5500_init(793): reset w5500 failed
E (128) esp_eth: esp_eth_driver_install(228): init mac failed
E (3033) w5500.mac: w5500_send_command(204): send command timeout
E (3033) w5500.mac: emac_w5500_receive(675): issue RECV command failed
E (3034) w5500.mac: frame read from module failed
E (4139) w5500.mac: w5500_send_command(204): send command timeout
E (4139) w5500.mac: emac_w5500_receive(675): issue RECV command failed
E (4140) w5500.mac: frame read from module failed
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00380038 PS : 0x00060930 A0 : 0x00000000 A1 : 0x3ffb5140
A2 : 0x3ffb4960 A3 : 0x00380038 A4 : 0x40110378 A5 : 0x3ffb5ac4
A6 : 0x000005f2 A7 : 0x00000000 A8 : 0x80110778 A9 : 0x3ffb5100
A10 : 0x3ffb59d0 A11 : 0x3ffb5ac4 A12 : 0x0000fffd A13 : 0x0000fffd
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x00000014
EXCVADDR: 0x00380038 LBEG : 0x40089948 LEND : 0x4008995e LCOUNT : 0xffffffff
Backtrace: 0x00380035:0x3ffb5140
ELF file SHA256: 2dd9d9d7fcebe907
Rebooting...
ets Jun 8 2016 00:22:57
And when it works, it connects and works fine, goes like this.
ETH Started
ETH Connected
ETH Got IP: 'eth0'
eth0: <UP,100M,FULL_DUPLEX,AUTO>
ether 36:AB:95:6B:07:90 phy 0x1
inet 192.168.2.30 netmask 255.255.255.0 broadcast 192.168.2.255
gateway 192.168.2.1 dns 192.168.2.1
1
connecting to arduino.tips
HTTP/1.1 200 OK
Date: Tue, 02 Jan 2024 18:41:16 GMT....
And the rest of the contents are printed from /asciilogo.txt. I use wificlientsecure to do https.
Does https://github.com/espressif/esp-idf/issues/11331 has any bearing on this?
@kostaond could you please comment on @kapyaar issue? Here the "bad" version is 0xFE
@kapyaar how is the W5500 to the ESP32? Is it custom board or is it connected via wires? It seems to me like some SPI connection issue. You can also try to decrease SPI CLK frequency to see if it helps.
@kostaond @me-no-dev Board is good, it is an assembled pcb, but the issue is totally on our side. This ETH section is part of a larger board, and the new version had a few additional SPI chips, CS of one of those chips was floating, likely responding to requests meant for W5500. Took me a while to think outside my section of the board, Fixed that part, and the ETH part works consistently. Really sorry. I have an ETH question, but unrelated to this. To keep this thread clean, let me know if you want me to delete my post and comment, I will be happy to do that.
@kapyaar if you have Ethernet related question, please ask at forum.
@kapyaar One tip for designing your board with Ethernet. Please include a ferrite bead in the power line to the ETH power and make sure you only have a single point where GND of Ethernet and the rest is connected. In my own designs I used a beefy 0 Ohm resistor (0805 or 1206) to connect both grounds.
You can have a look at the schematics provided by Olimex to get inspiration on how to implement the power nets when using Ethernet. N.B. this is regardless of the used Ethernet chip as this is just typical for all Ethernet modules/chips.
Found another issue, where the DHCP service doesn't seem to work when starting softAP. See: https://github.com/espressif/arduino-esp32/issues/9069
~I2C HAL fails to compile if HAL LOCKS are disabled.~ this has been fixed. See: #9073
Hello in latest git / 3.0.0 alpha I cannot find the API equivalent API of
/**
* @brief Compatible version of former tcpip_adapter API of esp_netif_get_sta_list
*/
esp_err_t tcpip_adapter_get_sta_list(const wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list);
to get IP of connected clients
It seems now a component in IDF : https://github.com/espressif/esp-idf/blob/release/v5.1/components/esp_wifi/include/esp_wifi_ap_get_sta_list.h
But cannot find it in latest arduino-esp32 git
Will this API be ported / available in esp32-arduino for final 3.0.0 ?
@luc-github no. IDF 5.x has many changes since 4.x. There should be something else that would work the same way though
so you mean esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list); I linked ?
but I cannot find it in latest git, so it is may be a miss ?
@P-R-O-C-H-Y @me-no-dev Should we add the changes of the network refactoring to the migration guide ?
@lucasssvaz not one of the tagged, but from my side a clear YES. This changes have broken currently before well running Tasmota with alpha 3.0.0 completely ;-) It is by far the greatest breaking change of all.
@Jason2866 can you elaborate a bit more on what actually broke on your end? We did rename a couple of IPv6 methods, but that should be mostly it. I tried to keep all other old methods working as before.
@me-no-dev It crashes already at start. bootloop
Dereferencing a NULL pointer
00:00:00.061 Project tasmota - Tasmota Version 13.4.0.3(tasmota)-3_0_0(2024-03-20T18:35:13)
00:00:00.222 WIF: Attempting connection...
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
The call chain seems to be in:
NetworkEvents::removeEvent(std::function<void (arduino_event_id_t, arduino_event_info_t)>, arduino_event_id_t)
STAClass::end()
WiFiSTAClass::disconnect(bool, bool, unsigned long)
@Jason2866 this is unexpected. Can you give more info on how you get to WiFi.disconnect(true)? Do you call it first on boot, or do you call other WiFi APIs before that? I want to replicate the problem.
@me-no-dev
@s-hadinger is investigating this. His finding so far
struggling with the Core3 Wifi. It connects but Tasmota considers it's not connected because the status remains stuck on
WL_STOPPED. It looks like theSTAClassnever receivesWIFI_EVENT_STA_START/ARDUINO_EVENT_WIFI_STA_STARTthat changes the status fromWL_STOPPEDtoWL_DISCONNECTEDbecause theSTAClassis initialized too late, long after STA more was set and long after eventWIFI_EVENT_STA_START.
I'm still struggling whether it uses
STAClassorWiFiSTAClass(or worse both). Confirmed, WiFiGenericmode()is triggered beforeSTAexists
@Jason2866 this is hard to believe, because event listeners are attached before STA is started. WiFiSTAClass is there just for compatibility and it always calls the STAClass in the background. STAClass is the one that manages the interface and receives and handles it's events. https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/STA.cpp#L293-L302
If you can provide a chain of calls that can reproduce an issue, I can investigate further as well.
@me-no-dev Thx, we will do. We need some time.