esp-rs / esp-mbedtls

mbedtls for ESP32 bare-metal
Apache License 2.0
17 stars 7 forks source link

Update esp-wifi and esp-hal #8

Closed AnthonyGrondin closed 1 year ago

AnthonyGrondin commented 1 year ago

Update esp-wifi and esp-hal to the latest version.

I've currently only done esp32s3, because it's the only chip that I have on hand.

I'm getting multiple crashes, for many different reasons, like illegal instructions, or index out of bounds.. I'm also getting this kind of error on another project using this library, so it feels like it's specific to esp-wifi and / or esp-mbedtls. I can't figure this one out.

Tested on both 1.69.0 and 1.70.0.

bjoernQ commented 1 year ago

I can reproduce the IllegalInstruction with the sync example - results in this (1.70, 1.69 is similar with slightly different addresses)

Exception occured 'IllegalInstruction'
Context
PC=0x4037dacf       PS=0x00060011
0x4037dacf - hal_pwr_interrupt_clr_event
    at ??:??
0x00060011 - PS_WOE
    at ??:??
A0=0x8037da21       A1=0x3fcd9e70       A2=0x00000000       A3=0x00000001       A4=0x60038004
0x8037da21 - _rtc_fast_bss_start
    at ??:??
0x3fcd9e70 - _heap_end
...

With 1.68 it works however.

Given the PC is in IRAM I suspect something increased stack usage (plus maybe 1.69 and 1.70 reserve more stack somehow)

Not sure if this is caused by esp-hal or esp-wifi (probably it's esp-wifi). I had a look at the diff but there is nothing really obvious wasting stack.

Also https://github.com/esp-rs/esp-wifi/issues/196 suggests it's not an Xtensa-only thing.

However, I cannot reproduce it with the example here for ESP32-C3

bjoernQ commented 1 year ago

Update: Most probably not a problem with the stack BUT a linker script problem

4037dacf:   f01d        retw.n

3fc8dad0 A _data_start
3fc8dad0 d _ZN8esp_wifi4wifi10os_adapter14FAKE_SPIN_LOCK17h713b30e6a3223c01E
bjoernQ commented 1 year ago

I can confirm it's a linker script issue. Needs some more testing and then I can hopefully create a PR for esp-hal tomorrow.

AnthonyGrondin commented 1 year ago

I've added the examples for esp32 and esp32c3. I haven't tested if they run, as I don't have those chips on hand, but I've tested for esp32s3 and everything works fine, except for sync_client which seems to hang for me, at Making HTTP request

bjoernQ commented 1 year ago

The problem on ESP32-S3 should be fixed in https://github.com/esp-rs/esp-hal/pull/616 - maybe you want to check it by patching the dependency

bjoernQ commented 1 year ago

Seems like it's working for all the targets now with a patched HAL. We plan to have new HAL releases soon (and update esp-wifi as soon as the HALs are released)

AnthonyGrondin commented 1 year ago

Great! Thanks for taking care of it. I'll wait until esp-hal and esp-wifi get updated, then update the changes in this PR.

AnthonyGrondin commented 1 year ago

Needs testing on esp32 and esp32c3, but I've tested esp32s3 and everything works.

This gives me errors when I compile without --release

bjoernQ commented 1 year ago

Compiles fine now for ESP32-C3. I had some problems with the ESP32-C3 async_client example since it seems that something (probably the WiFi drivers) now allocate more memory and I had to remove the last certificate in CERT to make it work.

I will merge this anyways to not block you from making progress in #9