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

Fix compiler error for ESP32-C3 and mbed TLS v2.7.0+ #970

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

khoih-prog
Copy link

Compile error on ESP32-C3 for even simplest example simple_server

/home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp: In member function 'IPAddress AsyncWebSocketClient::remoteIP()':
/home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp:843:28: error: call of overloaded 'IPAddress(unsigned int)' is ambiguous
         return IPAddress(0U);
                            ^

Compile error on ESP32-C3 for even simplest example [simple_server](https://github.com/me-no-dev/ESPAsyncWebServer/tree/master/examples/simple_server)

```
/home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp: In member function 'IPAddress AsyncWebSocketClient::remoteIP()':
/home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp:843:28: error: call of overloaded 'IPAddress(unsigned int)' is ambiguous
         return IPAddress(0U);
                            ^
```
@@ -840,7 +840,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer)

IPAddress AsyncWebSocketClient::remoteIP() {
if(!_client) {
return IPAddress(0U);
return IPAddress((uint32_t) 0);
Copy link

@agners agners Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a type cast I'd just use a more specific type suffix:

Suggested change
return IPAddress((uint32_t) 0);
return IPAddress(0UL);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, using 0UL breaks ESP32. I think the only proper way to fix this is using a static type cast.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return IPADDR_ANY or IPADDR_NONE here? IPADDR_ANY looks good for this, no?

Fix deprecated functions superseded from mbed TLS v2.7.0
- mbedtls_md5_starts()
- mbedtls_md5_update() 
- mbedtls_md5_finish()

leading to following compiling error

```
/home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o:(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts'
/home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o: in function `getMD5(unsigned char*, unsigned short, char*)':
/home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/WebAuthentication.cpp:73: undefined reference to `mbedtls_md5_starts'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board ESP32S2 Dev Module.
```
@khoih-prog khoih-prog changed the title Fix compiler error for ESP32-C3 Fix compiler error for ESP32-C3 and mbed TLS v2.7.0+ Aug 2, 2021
khoih-prog added a commit to khoih-prog/ESPAsync_WiFiManager that referenced this pull request Aug 2, 2021
### Releases v1.9.2

1. Fix MultiWiFi connection issue with ESP32 core v2.0.0-rc1+
2. Fix AsyncWebServer library compile error with ESP32 core v2.0.0-rc1+. Check [Fix compiler error for ESP32-C3 and mbed TLS v2.7.0+ #970](me-no-dev/ESPAsyncWebServer#970)
3. Verify compatibility with new ESP32 core v2.0.0-rc1+
4. Verify compatibility with new ESP8266 core v3.0.2
khoih-prog added a commit to khoih-prog/AsyncWebServer_WT32_ETH01 that referenced this pull request Aug 3, 2021
#### Releases v1.2.4

1. Fix library compile error with ESP32 core v2.0.0-rc1+. Check [Fix compiler error for ESP32-C3 and mbed TLS v2.7.0+ #970](me-no-dev/ESPAsyncWebServer#970)
2. Verify compatibility with new ESP32 core v2.0.0-rc1+
@bluet
Copy link

bluet commented Nov 23, 2021

Hi wanna know if there's any update?

I'm experiencing the same issue.

Arduino: 1.8.16 (Linux), Board: "ESP32C3 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 160MHz (WiFi), QIO, 80MHz, 4MB (32Mb), 115200, None"

/home/bluet/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp: In member function 'IPAddress AsyncWebSocketClient::remoteIP()':
/home/bluet/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp:832:28: error: call of overloaded 'IPAddress(unsigned int)' is ambiguous
         return IPAddress(0U);
                            ^
In file included from /home/bluet/.arduino15/packages/esp32/hardware/esp32/2.0.1/cores/esp32/Arduino.h:163,
                 from /home/bluet/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp:21:
/home/bluet/.arduino15/packages/esp32/hardware/esp32/2.0.1/cores/esp32/IPAddress.h:51:5: note: candidate: 'IPAddress::IPAddress(const uint8_t*)'
     IPAddress(const uint8_t *address);
     ^~~~~~~~~
/home/bluet/.arduino15/packages/esp32/hardware/esp32/2.0.1/cores/esp32/IPAddress.h:50:5: note: candidate: 'IPAddress::IPAddress(uint32_t)'
     IPAddress(uint32_t address);
     ^~~~~~~~~
/home/bluet/.arduino15/packages/esp32/hardware/esp32/2.0.1/cores/esp32/IPAddress.h:29:7: note: candidate: 'constexpr IPAddress::IPAddress(const IPAddress&)'
 class IPAddress: public Printable
       ^~~~~~~~~
Multiple libraries were found for "WiFi.h"
 Used: /home/bluet/.arduino15/packages/esp32/hardware/esp32/2.0.1/libraries/WiFi
 Not used: /home/bluet/local/arduino-1.8.16/libraries/WiFi
exit status 1
Error compiling for board ESP32C3 Dev Module.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@bluet
Copy link

bluet commented Nov 23, 2021

Got it fixed by manually modify AsyncWebSocket.cpp:832,
from return IPAddress(0U); to return IPAddress((uint32_t) 0u);.

Tested on both ESP32-C3 and ESP32-S2.

@FedericoBusero
Copy link

This little issue breaks compilation on ESP32C3, no idea why it doesn't get merged

@ndastur
Copy link

ndastur commented May 1, 2022

This does seem like a fairly important fix. Any update or timeline please ?

@maxgerhardt
Copy link

maxgerhardt commented May 17, 2022

People are also running in this bug when using PlatformIO and using the latest Arduino-ESP32 core here in the forums. This fix PR is valid.

@MikeyMoMo
Copy link

Here is is May 19, 2022 and I just had to fix this, too. Thanks to those who found it. I hope it can be fixed soon in the library for real. Been known for only 1 year.

vortigont added a commit to vortigont/ESPAsyncWebServer that referenced this pull request May 28, 2022
@maxgerhardt
Copy link

Yet another person running into this here.

@ayushsharma82
Copy link

Somebody merge this :) It's very due and fixes the problem.

@miloit
Copy link

miloit commented Nov 6, 2022

Can someone merge this?

@Nailik
Copy link

Nailik commented Dec 11, 2022

Issue still exists !!

@ncmreynolds
Copy link

Just had to fix this manually myself after encountering it, seems like a trivial merge that would fix this for a whole load of people. Any chance this can be merged?

@FedericoBusero
Copy link

The problem with this PR is that most of the code changes are about mbed TLS, but most of the comments and requests are about one little trivial change in one line of the code to fix the compilation error on RISC-V (ESP32-C3). Probably it is better to split the two issues.
Remark that there is another PR with only this one line of code: #1142

@Adminius
Copy link

run also into this issue.
return IPAddress((uint32_t)0); fixes the problem.

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

Successfully merging this pull request may close these issues.

None yet