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

Issue with lwip_hook_ip6_input in Arduino IDE 2.3.2 #10084

Open
1 task done
kunal-nezai opened this issue Jul 29, 2024 · 14 comments
Open
1 task done

Issue with lwip_hook_ip6_input in Arduino IDE 2.3.2 #10084

kunal-nezai opened this issue Jul 29, 2024 · 14 comments
Labels
Resolution: Awaiting response Waiting for response of author Type: Question Only question

Comments

@kunal-nezai
Copy link

Board

ESP32 Dev Module

Device Description

NA

Hardware Configuration

NA

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

Description of Issue

When using Arduino IDE 1.8.19, the code compiles and functions as expected. However, when using Arduino IDE 2.3.2, I encounter the following error:

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-dc859c1e67\esp32/lib\liblwip.a(ip6.c.obj):(.literal.ip6_input+0x0): undefined reference to `lwip_hook_ip6_input'
c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-dc859c1e67\esp32/lib\liblwip.a(ip6.c.obj): in function `ip6_input':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv6/ip6.c:547: undefined reference to `lwip_hook_ip6_input'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Sketch

NA

Debug Message

c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-dc859c1e67\esp32/lib\liblwip.a(ip6.c.obj):(.literal.ip6_input+0x0): undefined reference to `lwip_hook_ip6_input'
c:/users/admin/appdata/local/arduino15/packages/esp32/tools/esp-x32/2302/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Admin\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-dc859c1e67\esp32/lib\liblwip.a(ip6.c.obj): in function `ip6_input':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv6/ip6.c:547: undefined reference to `lwip_hook_ip6_input'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Other Steps to Reproduce

NA

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@kunal-nezai kunal-nezai added the Status: Awaiting triage Issue is waiting for triage label Jul 29, 2024
@me-no-dev
Copy link
Member

please provide minimal sketch to reproduce. This is not expected

@kunal-nezai
Copy link
Author

I am unsure which part of the code is causing this issue. Due to the company's NDA policy, I cannot share any code.

For reference, I can mention that the library was written for ESP-IDF v5.2.2. I used the same header files when making the library compatible with the Arduino IDE.

@Jason2866
Copy link
Collaborator

@kunal-nezai How should anyone help, without a piece of an example! code?
No one says you should provide code which is under NDA.

@VojtechBartoska VojtechBartoska added Type: Question Only question Resolution: Awaiting response Waiting for response of author and removed Status: Awaiting triage Issue is waiting for triage labels Jul 29, 2024
@me-no-dev
Copy link
Member

@kunal-nezai you are using some IDF code in the place of Arduino code. Maybe custom WiFi handling or something of the sort to get this message. You can copy the function from here to your codebase and get to compile.

@kunal-nezai
Copy link
Author

@me-no-dev Hello!

Today, while working, I noticed that the older version of Arduino IDE (1.8.19) uses version 3.0.2 of the ESP32 board, whereas the new Arduino IDE (2.3.2) uses version 3.0.3 of the ESP32 board.

To test my suspicion, I installed version 3.0.2 of the ESP32 board in the new Arduino IDE, and it is now functioning properly.

I suspect there is something in version 3.0.3 that is causing the issue.

@me-no-dev
Copy link
Member

@kunal-nezai it's the fact that you do not use Arduino fully, but instead manage WiFi through the IDF API only. If your network stack was using Arduino's APIs, this would not have happened. Adding the code above will make it work for the future, Else you will be stuck on 3.0.2

@me-no-dev
Copy link
Member

@i-am-shodan
Copy link

I have the same issue. Here is a test case

#include "esp_netif.h"

#define STATIC_IP_ADDR "10.0.0.2"
#define DEFAULT_GATEWAY "10.0.0.1"
#define DEFAULT_NETMASK "255.255.255.0"


void setup() {
  ip4_addr_t ip;
  ip4_addr_t gw;
  ip4_addr_t netmask;
  ip4addr_aton(STATIC_IP_ADDR, &ip);
  ip4addr_aton((const char *)DEFAULT_GATEWAY, &gw);
  ip4addr_aton((const char *)DEFAULT_NETMASK, &netmask);

  esp_netif_ip_info_t ip_info;
  memset(&ip_info, 0, sizeof(esp_netif_ip_info_t));
  ip_info.ip.addr = ip.addr;
  ip_info.gw.addr = gw.addr;
  ip_info.netmask.addr = netmask.addr;

  uint8_t lwip_addr[6] = { 0x02, 0x02, 0x11, 0x22, 0x33, 0x02 };

  esp_netif_inherent_config_t base_cfg = {
    .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_EVENT_IP_MODIFIED | ESP_NETIF_FLAG_AUTOUP),
    .ip_info = &ip_info,
    .get_ip_event = IP_EVENT_ETH_GOT_IP,
    .lost_ip_event = IP_EVENT_ETH_LOST_IP,
    .if_key = "usb_eth",
    .if_desc = "usb ncm config device",
    .route_prio = 10
  };

  esp_netif_driver_ifconfig_t driver_cfg = {
    .handle = (void *)1,
    .transmit = NULL, // just for this example
    .driver_free_rx_buffer = NULL // just for this example
  };

  esp_netif_config_t cfg = {
    .base = &base_cfg,
    .driver = &driver_cfg,
    .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH,  // USB-NCM is an Ethernet netif from lwip perspective, we already have IO definitions for that:
  };
}

void loop() {
  // put your main code here, to run repeatedly:

}

Using .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH or any of the other stacks results in a linker error

/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv6/ip6.c:547: undefined reference to lwip_hook_ip6_input'`

The same code compiles fine on a non-Arduino 3 SDK.

Interestingly this code compiles fine with platformio

@Jason2866
Copy link
Collaborator

Jason2866 commented Jul 31, 2024

Interestingly this code compiles fine with platformio

I doubt that. Probably not using the same Arduino core code base and libs.

@i-am-shodan
Copy link

i-am-shodan commented Jul 31, 2024

platform = https://github.com/platformio/platform-espressif32.git
platform_packages = 
	platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.3
	platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1

I'm running it right now

@Jason2866
Copy link
Collaborator

Jason2866 commented Jul 31, 2024

As said not using same code base. This https://github.com/espressif/arduino-esp32.git#3.0.3 uses Arduino commit of release Core 3.0.3
The change in Arduino was done after
To use all latest use this

[env:development]
platform = https://github.com/pioarduino/platform-espressif32.git#develop
board = ...
...

@i-am-shodan
Copy link

#include "lwip/netif.h"

extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) __attribute__((weak));
extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) {
  if (ip6_addr_isany_val(inp->ip6_addr[0].u_addr.ip6)) {
    // We don't have an LL address -> eat this packet here, so it won't get accepted on input netif
    pbuf_free(p);
    return 1;
  }
  return 0;
}

For my future self this might be a fix

@me-no-dev
Copy link
Member

@i-am-shodan do it together with the #if like I linked above. Different fix will be coming and we might switch this setting. No need to compile code that will not be used

@PureTek-Innovations
Copy link

Thanks @i-am-shodan, I added your #if code to my project, I use this core version:

platform = https://github.com/platformio/platform-espressif32.git#develop
platform_packages =
	platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.4
	platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.4/esp32-arduino-libs-3.0.4.zip

And it compiles, not tried to use it yet but I expect that it will be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Awaiting response Waiting for response of author Type: Question Only question
Projects
None yet
Development

No branches or pull requests

6 participants