ARP request is crashing on esp32c3

ray1050
Posts: 10
Joined: Tue Aug 08, 2023 2:10 pm

ARP request is crashing on esp32c3

Postby ray1050 » Wed Apr 03, 2024 9:01 pm

I want to send ARP request and it's crashing at etharp_request() function call.
If I comment ARP function, it does not crash and can successful connection to WiFi.
Tried with both ESP IDF 5.1.2 and 5.1.1.
ESP32c3

assert failed: etharp_raw /IDF/components/lwip/lwip/src/core/ipv4/etharp.c:1145 (netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!)

Need to add SSID, PASS and update the ip address for ARP
update: add wifi_connected_flag flag

Code: Select all

#include "esp_log.h"
#include "esp_mac.h"
#include "esp_system.h"
#include "esp_task_wdt.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "lwip/err.h"
#include "lwip/etharp.h"
#include "lwip/netdb.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include "nvs_flash.h"

#include <string.h>
#include <wifi_provisioning/manager.h>
#include <wifi_provisioning/scheme_ble.h>

#define TAG "app_main"

esp_netif_t * netif;
static EventGroupHandle_t s_wifi_event_group;
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT      BIT1

//Insert SSID & pass
#define SSID         ""
#define PASS         ""
#define MAC_ADDR_LEN 6
bool wifi_connected_flag = false;

void send_arp(ip4_addr_t * ip_ptr)
{
    esp_err_t retval = etharp_request((struct netif *) netif, ip_ptr);
    if (retval == ESP_OK)
    {
        ESP_LOGI(TAG, "retval %d", retval);
    }
}

static void send_arp_request(char * cut_ip_ptr)
{
    uint8_t sent_count = 0;
    for (uint8_t i = 0; i < 255; i++)
    {
        char curr_ip_str[17];
        ip4_addr_t curr_ip4;
        sprintf(curr_ip_str, "%s%d", cut_ip_ptr, i);
        ip4addr_aton(curr_ip_str, &curr_ip4);
        // arp requst
        send_arp(&curr_ip4);
        vTaskDelay(60000 / portTICK_PERIOD_MS);
    }
}

void query_task(void * params)
{
    while (1)
    {
        char arp_src[17];
        // change according ex1) 10.0.0.1 -> 10.0.0, ex2) 192.168.1.1 -> 192.168.1
        sprintf(arp_src, "10.0.0."); //TODO: make it dynamic based on gateway
        send_arp_request(arp_src);

        vTaskDelay(60000 / portTICK_PERIOD_MS);
    }
}

static void wifi_event_handler(void * arg, esp_event_base_t event_base, int32_t event_id,
                               void * event_data)
{
    if (event_base == WIFI_EVENT)
    {
        switch (event_id)
        {
            case WIFI_EVENT_STA_START: {
                wifi_connected_flag = true;
                esp_wifi_connect();
                break;
            }
            case WIFI_EVENT_STA_DISCONNECTED: {
                esp_wifi_connect();
                break;
            }
            default:
                break;
        }
    }
}

/**
 * @brief Initialize wifi station mode
 *
 */
void init_wifi_sta()
{
    s_wifi_event_group = xEventGroupCreate();

    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    netif = esp_netif_create_default_wifi_sta();
    char hostname[14]; // custom string esp_XX_XX_XX
    memset(hostname, 0, sizeof(hostname));
    uint8_t mac_addr[MAC_ADDR_LEN];
    esp_efuse_mac_get_default(&mac_addr[0]);
    sprintf(hostname, "esp_%02X%02X%02X", mac_addr[3], mac_addr[4], mac_addr[5]);

    ESP_LOGI(TAG, "self hostname set to %s", hostname);
    // specific hostname not set yet, get_hostname should fail
    esp_err_t test_err = esp_netif_set_hostname(netif, hostname);
    if (test_err != ESP_OK)
    {
        ESP_LOGW(TAG, "Unable to set hostname due to error 0x%02X, using default %s", test_err,
                 CONFIG_LWIP_LOCAL_HOSTNAME);
    }

    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));
    ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));

    ESP_ERROR_CHECK(
        esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));

    wifi_country_t country_config = {
        .cc = "01",
        .schan = 1,
        .nchan = 11,
        .policy = WIFI_COUNTRY_POLICY_AUTO,
    };

    wifi_config_t wifi_config = {
        .sta =
            {
                .ssid = SSID,
                .password = PASS,
            },
    };

    ESP_ERROR_CHECK(esp_wifi_set_country(&country_config));
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
    ESP_ERROR_CHECK(esp_wifi_start());

    /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or
     * connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The
     * bits are set by event_handler() (see above) */
    xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE,
                        255);
}

void app_main(void)
{
    ESP_ERROR_CHECK(nvs_flash_init()); // initializing NVS (Non-Volatile Storage)
    init_wifi_sta();
    while(wifi_connected_flag == false)
    {
    //wait util wifi connects
    }
    xTaskCreate(query_task, "QUERY", 4096, NULL, tskIDLE_PRIORITY, NULL);
}
Last edited by ray1050 on Wed Apr 03, 2024 10:26 pm, edited 1 time in total.

MicroController
Posts: 1705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ARP request is crashing on esp32c3

Postby MicroController » Wed Apr 03, 2024 9:53 pm

Code: Select all

    xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE,
                        255);
You're waiting for about 2.5 seconds on an event which never happens, then continue unconditionally and start the query task. This may be part of the problem, i.e. WiFi not being connected yet when you start ARPing.

ray1050
Posts: 10
Joined: Tue Aug 08, 2023 2:10 pm

Re: ARP request is crashing on esp32c3

Postby ray1050 » Wed Apr 03, 2024 10:23 pm

I added a flag check set when wifi connects and check before calling query task. It has same issue.
Updated a above code to reflect changes.
MicroController wrote:
Wed Apr 03, 2024 9:53 pm

Code: Select all

    xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE,
                        255);
You're waiting for about 2.5 seconds on an event which never happens, then continue unconditionally and start the query task. This may be part of the problem, i.e. WiFi not being connected yet when you start ARPing.

MicroController
Posts: 1705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ARP request is crashing on esp32c3

Postby MicroController » Wed Apr 03, 2024 10:42 pm

ray1050 wrote:
Wed Apr 03, 2024 10:23 pm
I added a flag check set when wifi connects and check before calling query task. It has same issue.
Probably because the flag check doesn't work the way you think it would. I suggest following the code from the WiFi examples, setting the event bits in the event handler, using a big-enough timeout value, and checking the result of xEventGroupWaitBits().

ray1050
Posts: 10
Joined: Tue Aug 08, 2023 2:10 pm

Re: ARP request is crashing on esp32c3

Postby ray1050 » Thu Apr 04, 2024 12:32 am

I took station example as reference and add piece regarding ARPing. Having same failure.

Code: Select all

/* WiFi station Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "lwip/etharp.h"
#include "nvs_flash.h"
#include <string.h>

#include "lwip/err.h"
#include "lwip/sys.h"
esp_netif_t *netif;
 EventBits_t bits;
 
/* The examples use WiFi configuration that you can set via project
   configuration menu

   If you'd rather not, just change the below entries to strings with
   the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
*/
#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY

#if CONFIG_ESP_WPA3_SAE_PWE_HUNT_AND_PECK
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_HUNT_AND_PECK
#define EXAMPLE_H2E_IDENTIFIER ""
#elif CONFIG_ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_HASH_TO_ELEMENT
#define EXAMPLE_H2E_IDENTIFIER CONFIG_ESP_WIFI_PW_ID
#elif CONFIG_ESP_WPA3_SAE_PWE_BOTH
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
#define EXAMPLE_H2E_IDENTIFIER CONFIG_ESP_WIFI_PW_ID
#endif
#if CONFIG_ESP_WIFI_AUTH_OPEN
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
#elif CONFIG_ESP_WIFI_AUTH_WEP
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
#elif CONFIG_ESP_WIFI_AUTH_WPA_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WAPI_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
#endif

/* FreeRTOS event group to signal when we are connected*/
static EventGroupHandle_t s_wifi_event_group;

/* The event group allows multiple bits for each event, but we only care about
 * two events:
 * - we are connected to the AP with an IP
 * - we failed to connect after the maximum amount of retries */
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1

static const char *TAG = "wifi station";

static int s_retry_num = 0;

static void event_handler(void *arg, esp_event_base_t event_base,
                          int32_t event_id, void *event_data) {
  if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
    esp_wifi_connect();
  } else if (event_base == WIFI_EVENT &&
             event_id == WIFI_EVENT_STA_DISCONNECTED) {
    if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
      esp_wifi_connect();
      s_retry_num++;
      ESP_LOGI(TAG, "retry to connect to the AP");
    } else {
      xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
    }
    ESP_LOGI(TAG, "connect to the AP fail");
  } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
    ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
    ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
    s_retry_num = 0;
    xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
  }
}

void wifi_init_sta(void) {
  s_wifi_event_group = xEventGroupCreate();

  ESP_ERROR_CHECK(esp_netif_init());

  ESP_ERROR_CHECK(esp_event_loop_create_default());
  netif = esp_netif_create_default_wifi_sta();

  wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  ESP_ERROR_CHECK(esp_wifi_init(&cfg));

  esp_event_handler_instance_t instance_any_id;
  esp_event_handler_instance_t instance_got_ip;
  ESP_ERROR_CHECK(esp_event_handler_instance_register(
      WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL, &instance_any_id));
  ESP_ERROR_CHECK(esp_event_handler_instance_register(
      IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL, &instance_got_ip));

  wifi_config_t wifi_config = {
      .sta =
          {
              .ssid = EXAMPLE_ESP_WIFI_SSID,
              .password = EXAMPLE_ESP_WIFI_PASS,
              /* Authmode threshold resets to WPA2 as default if password
               * matches WPA2 standards (pasword len => 8). If you want to
               * connect the device to deprecated WEP/WPA networks, Please set
               * the threshold value to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set
               * the password with length and format matching to
               * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
               */
              .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
              .sae_pwe_h2e = ESP_WIFI_SAE_MODE,
              .sae_h2e_identifier = EXAMPLE_H2E_IDENTIFIER,
          },
  };
  ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
  ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
  ESP_ERROR_CHECK(esp_wifi_start());

  ESP_LOGI(TAG, "wifi_init_sta finished.");

  /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or
   * connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The
   * bits are set by event_handler() (see above) */
  bits = xEventGroupWaitBits(s_wifi_event_group,
                                         WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
                                         pdFALSE, pdFALSE, portMAX_DELAY);

  /* xEventGroupWaitBits() returns the bits before the call returned, hence we
   * can test which event actually happened. */
  if (bits & WIFI_CONNECTED_BIT) {
    ESP_LOGI(TAG, "connected to ap");
  } else if (bits & WIFI_FAIL_BIT) {
    ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
             EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
  } else {
    ESP_LOGE(TAG, "UNEXPECTED EVENT");
  }
}

void send_arp(ip4_addr_t *ip_ptr) {
  // tcpip_adapter_get_netif(0, &t_netif);
  // struct netif * netif_interface = (struct netif *) netif;

  // ESP_LOGI(TAG, "out %d", netif_interface->hwaddr_len);
  // if (netif_interface->hwaddr_len == 6)
  // {

  // esp_netif_t * esp_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
  // if (esp_netif)
  // {
  // esp_netif_t * t_netif = esp_netif_get_netif_impl_index(esp_netif);
  esp_err_t retval = etharp_request((struct netif *)netif, ip_ptr);
  // arp requst
  if (retval == ESP_OK) {
    ESP_LOGI(TAG, "retval %d", retval);
  }
  // }

  // netif * netif = netif_list;

  // while (netif)
  // {
  //     if (netif->hwaddr_len == 6)
  //     {
  //         etharp_request((char *) (netif), (char *) netif_ip4_addr(netif));
  //     }
  //     netif = netif->next;
  // }
}

static void send_arp_request(char *cut_ip_ptr) {
  uint8_t sent_count = 0;
  for (uint8_t i = 0; i < 255; i++) {
    char curr_ip_str[17];
    ip4_addr_t curr_ip4;
    sprintf(curr_ip_str, "%s%d", cut_ip_ptr, i);
    ip4addr_aton(curr_ip_str, &curr_ip4);
    if (bits & WIFI_CONNECTED_BIT) {
        // arp requst
    	send_arp(&curr_ip4);
    }
    vTaskDelay(60000 / portTICK_PERIOD_MS);
  }
}

void query_task(void *params) {
  while (1) {
    char arp_src[17];
    sprintf(arp_src, "10.0.0.");
    send_arp_request(arp_src);

    vTaskDelay(60000 / portTICK_PERIOD_MS);
  }
}

void app_main(void) {
  // Initialize NVS
  esp_err_t ret = nvs_flash_init();
  if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
      ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
    ESP_ERROR_CHECK(nvs_flash_erase());
    ret = nvs_flash_init();
  }
  ESP_ERROR_CHECK(ret);

  ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
  wifi_init_sta();
  xTaskCreate(query_task, "QUERY", 4096, NULL, tskIDLE_PRIORITY, NULL);
}
Terminal Output

Code: Select all

I (1689) esp_netif_handlers: sta ip: 10.0.0.130, mask: 255.255.255.0, gw: 10.0.0.1
I (1689) wifi station: got ip:10.0.0.130
I (1689) wifi station: connected to ap
I (1689) main_task: Returned from app_main()

assert failed: etharp_raw /IDF/components/lwip/lwip/src/core/ipv4/etharp.c:1145 (netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!)
Core  0 register dump:
MEPC    : 0x40380700  RA      : 0x40385aec  SP      : 0x3fca7bf0  GP      : 0x3fc90a00  
TP      : 0x3fc895a8  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000035  S1      : 0x00000001  A0      : 0x3fca7c2c  A1      : 0x3fc91d11  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc97000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fca7d92  
S4      : 0x3fc91d10  S5      : 0x3fc9ccdc  S6      : 0x3fc9ccd8  S7      : 0x3fc9cdb0  
S8      : 0x3c098974  S9      : 0x00000001  S10     : 0x00000000  S11     : 0x00000000  
Stack dump detected
0x40380700: panic_abort at /home/test/Documents/esp-idf-v5.1.2/components/esp_system/panic.c:452
0x40385aec: __ubsan_include at /home/test/Documents/esp-idf-v5.1.2/components/esp_system/ubsan.c:313

T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000  


Backtrace:


panic_abort (details=details@entry=0x3fca7c2c "assert failed: etharp_raw /IDF/components/lwip/lwip/src/core/ipv4/etharp.c:1145 (netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!)") at /home/test/Documents/esp-idf-v5.1.2/components/esp_system/panic.c:452
452	    *((volatile int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
#0  panic_abort (details=details@entry=0x3fca7c2c "assert failed: etharp_raw /IDF/components/lwip/lwip/src/core/ipv4/etharp.c:1145 (netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!)") at /home/test/Documents/esp-idf-v5.1.2/components/esp_system/panic.c:452
#1  0x40385aec in esp_system_abort (details=details@entry=0x3fca7c2c "assert failed: etharp_raw /IDF/components/lwip/lwip/src/core/ipv4/etharp.c:1145 (netif->hwaddr_len must be the same as ETH_HWADDR_LEN for etharp!)") at /home/test/Documents/esp-idf-v5.1.2/components/esp_system/port/esp_system_chip.c:84
#2  0x4038cb9c in __assert_func (file=file@entry=0x3c098608 "", line=line@entry=1145, func=<optimized out>, func@entry=0x3c098830 <__func__.3> "", expr=expr@entry=0x3c09870c "") at /home/test/Documents/esp-idf-v5.1.2/components/newlib/assert.c:81
#3  0x420106a6 in etharp_raw (netif=0x3fc9ccd8, ethsrc_addr=0x3fc9cdb0, ethdst_addr=0x3c098974 <ethbroadcast>, hwsrc_addr=0x3fc9cdb0, ipsrc_addr=0x3fc9ccdc, hwdst_addr=0x3c09896c <ethzero>, ipdst_addr=ipdst_addr@entry=0x3fca7d88, opcode=opcode@entry=1) at /home/test/Documents/esp-idf-v5.1.2/components/lwip/lwip/src/core/ipv4/etharp.c:1145
#4  0x420106c8 in etharp_request_dst (netif=<optimized out>, ipaddr=ipaddr@entry=0x3fca7d88, hw_dst_addr=<optimized out>) at /home/test/Documents/esp-idf-v5.1.2/components/lwip/lwip/src/core/ipv4/etharp.c:1199
#5  0x4201085c in etharp_request (netif=<optimized out>, ipaddr=ipaddr@entry=0x3fca7d88) at /home/test/Documents/esp-idf-v5.1.2/components/lwip/lwip/src/core/ipv4/etharp.c:1217
#6  0x420082ea in send_arp (ip_ptr=ip_ptr@entry=0x3fca7d88) at /home/test/Documents/esp-idf-v5.1.2/examples/wifi/getting_started/station/main/station_example_main.c:170
#7  0x42008350 in send_arp_request (cut_ip_ptr=cut_ip_ptr@entry=0x3fca7dbc "10.0.0.") at /home/test/Documents/esp-idf-v5.1.2/examples/wifi/getting_started/station/main/station_example_main.c:197
#8  0x42008394 in query_task (params=<error reading variable: value has been optimized out>) at /home/test/Documents/esp-idf-v5.1.2/examples/wifi/getting_started/station/main/station_example_main.c:206
#9  0x403882a0 in vPortTaskWrapper (pxCode=<optimized out>, pvParameters=<optimized out>) at /home/test/Documents/esp-idf-v5.1.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:202
ELF file SHA256: 66f40d2887a83879

Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048b82
0x40048b82: software_reset in ROM

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x170c
load:0x403cc710,len:0x968
load:0x403ce710,len:0x2f9c
entry 0x403cc710
MicroController wrote:
Wed Apr 03, 2024 10:42 pm
ray1050 wrote:
Wed Apr 03, 2024 10:23 pm
I added a flag check set when wifi connects and check before calling query task. It has same issue.
Probably because the flag check doesn't work the way you think it would. I suggest following the code from the WiFi examples, setting the event bits in the event handler, using a big-enough timeout value, and checking the result of xEventGroupWaitBits().

ray1050
Posts: 10
Joined: Tue Aug 08, 2023 2:10 pm

Re: ARP request is crashing on esp32c3

Postby ray1050 » Tue Apr 09, 2024 2:40 pm

Any help appreciated.

MicroController
Posts: 1705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ARP request is crashing on esp32c3

Postby MicroController » Wed Apr 10, 2024 8:45 pm

Code: Select all

etharp_request((struct netif *)netif, ip_ptr);
I think this is not going to work: *netif is of type esp_netif_t, a.k.a. struct esp_netif_obj, which is not the same as lwIP's struct netif.
Try it like this:

Code: Select all

struct netif* const lwip_netif = (struct netif*)esp_netif_get_netif_impl(esp_netif);
etharp_request(lwip_netif, ip_ptr);

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 64 guests