lwip/linux: Add lwip support for networking component under linux

linux/lwip: Wrap some IO posix functions
* to workaourd the FreeRTOS EINTR issue (when building without lwip)
* to correctly choose the sub-system based on fd (when building with
lwip) -- passing control to either linux/system or to lwip
This commit also addapts tapio-if to provide DHCP client by default and
configurable settings for static IP
This commit is contained in:
David Cermak
2023-04-03 20:31:51 +02:00
committed by David Čermák
parent 0bfffa0160
commit b2af4d9689
31 changed files with 277 additions and 88 deletions

View File

@@ -5,8 +5,7 @@ cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
if(${IDF_TARGET} STREQUAL "linux")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/"
"$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs")
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs)
set(COMPONENTS main)
endif()

View File

@@ -3,7 +3,7 @@
# (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.)
set(requires "")
if(${IDF_TARGET} STREQUAL "linux")
list(APPEND requires esp_stubs esp-tls esp_http_client protocol_examples_common nvs_flash)
list(APPEND requires esp_stubs esp_event esp-tls esp_http_client protocol_examples_common nvs_flash)
endif()
idf_component_register(SRCS "esp_http_client_example.c"
INCLUDE_DIRS "."

View File

@@ -22,11 +22,9 @@
#include "esp_crt_bundle.h"
#endif
#if !CONFIG_IDF_TARGET_LINUX
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#endif
#include "esp_http_client.h"

View File

@@ -5,8 +5,7 @@ cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
if(${IDF_TARGET} STREQUAL "linux")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/"
"$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs")
set(COMPONENTS main)
endif()

View File

@@ -6,9 +6,6 @@
#include <stdlib.h>
#include "esp_err.h"
#include "esp_log.h"
#include "esp_event.h"
extern void app_main(void);
esp_err_t esp_netif_init(void)
{
@@ -19,10 +16,3 @@ esp_err_t example_connect(void)
{
return ESP_OK;
}
int main(void)
{
app_main();
return 0;
}

View File

@@ -1,8 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "esp_err.h"
esp_err_t esp_event_loop_create_default(void);

View File

@@ -8,4 +8,12 @@
#include <ifaddrs.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
esp_err_t esp_netif_init(void);
#ifdef __cplusplus
}
#endif

View File

@@ -4,8 +4,7 @@ cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
if("${IDF_TARGET}" STREQUAL "linux")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/"
"$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs")
set(COMPONENTS main)
endif()

View File

@@ -1,5 +1,5 @@
if(${IDF_TARGET} STREQUAL "linux")
set(requires esp_stubs protocol_examples_common nvs_flash)
set(requires esp_event esp_stubs protocol_examples_common nvs_flash)
endif()
if("${CONFIG_EXAMPLE_IPV4}" STREQUAL y)

View File

@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.16)
if("${IDF_TARGET}" STREQUAL "linux")
# This example uses an extra component with common functionality for lwip's port on linux target
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_tapif_io)
set(COMPONENTS main esp_netif protocol_examples_tapif_io startup esp_hw_support esp_system nvs_flash)
set(COMPONENTS main esp_netif lwip protocol_examples_tapif_io startup esp_hw_support esp_system nvs_flash)
else()
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection on ESP target
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)

View File

@@ -0,0 +1,3 @@
CONFIG_IDF_TARGET="linux"
CONFIG_EXAMPLE_IPV4_ADDR="127.0.0.1"
CONFIG_EXAMPLE_CONNECT_LWIP_TAPIF=n