Skip to content

Commit

Permalink
esp-idf-update
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Nov 3, 2024
1 parent d026f6d commit 4393edf
Show file tree
Hide file tree
Showing 16 changed files with 1,280 additions and 391 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ if (ESP_PLATFORM)
include_directories(
$ENV{IDF_PATH}/components/esp_hw_support/include/soc/
$ENV{IDF_PATH}/components/freertos/include/
$ENV{IDF_PATH}/components/lwip/include/
$ENV{IDF_PATH}/components/freertos/esp_additions/include/
$ENV{IDF_PATH}/components/freertos/esp_additions/include/freertos/
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/
Expand All @@ -98,6 +99,22 @@ if (ESP_PLATFORM)
$ENV{IDF_PATH}/components/hal/${CONFIG_IDF_TARGET}/include/
$ENV{IDF_PATH}/components/app_update/include/
$ENV{IDF_PATH}/components/bootloader_support/include
$ENV{IDF_PATH}/components/lwip/port/include
$ENV{IDF_PATH}/components/lwip/port/freertos/include
$ENV{IDF_PATH}/components/lwip/port/esp32xx/include
$ENV{IDF_PATH}/components/freertos/config/include/freertos/
$ENV{IDF_PATH}/components/freertos/config/${CONFIG_IDF_TARGET_ARCH}/include
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/portable/${CONFIG_IDF_TARGET_ARCH}/include
$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/portable/${CONFIG_IDF_TARGET_ARCH}/include/freertos
$ENV{IDF_PATH}/components/freertos/config/include
$ENV{IDF_PATH}/components/esp_driver_gpio/include
$ENV{IDF_PATH}/components/esp_driver_spi/include
$ENV{IDF_PATH}/components/esp_driver_ledc/include
$ENV{IDF_PATH}/components/esp_partition/include
$ENV{IDF_PATH}/components/spi_flash/include
$ENV{IDF_PATH}/components/esp_app_format/include
$ENV{IDF_PATH}/components/esp_bootloader_format/include
$ENV{IDF_PATH}/components/esp_system/include/
)

if (CONFIG_IDF_TARGET_ARCH_RISCV)
Expand Down
2 changes: 1 addition & 1 deletion include/libwebsockets/lws-freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct pollfd {
//#include "esp_event_loop.h"
#include "nvs.h"
#include "driver/gpio.h"
#include "esp_spi_flash.h"
#include "spi_flash_mmap.h"
#include "freertos/timers.h"

#if defined(LWS_ESP_PLATFORM)
Expand Down
8 changes: 6 additions & 2 deletions lib/misc/romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#include <stdio.h>
#include "romfs.h"
#if defined(LWS_WITH_ESP32)
#include "esp_spi_flash.h"
#include <esp_flash.h>
#include "spi_flash_mmap.h"
#endif

#define RFS_STRING_MAX 96
Expand All @@ -50,7 +51,10 @@ static void
set_cache(romfs_inode_t inode, size_t len)
{
#if defined(LWS_WITH_ESP32)
spi_flash_read((uint32_t)inode, cache, len);
// spi_flash_read((uint32_t)inode, cache, len);
// esp_err_t esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t address, uint32_t length);

esp_flash_read(NULL, (void *)inode, (uint32_t)cache, len);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion lib/plat/freertos/esp32/drivers/netdev/wifi-esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "private-lib-core.h"

#include "esp_system.h"
#include "esp_spi_flash.h"
#include "spi_flash_mmap.h"
#include "esp_wifi.h"
#include <nvs_flash.h>
#include <esp_netif.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/plat/freertos/freertos-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const struct http2_settings lws_h2_defaults_esp32 = { {
1,
/* H2SET_HEADER_TABLE_SIZE */ 512,
/* H2SET_ENABLE_PUSH */ 0,
/* H2SET_MAX_CONCURRENT_STREAMS */ 8,
/* H2SET_MAX_CONCURRENT_STREAMS */ 16,
/* H2SET_INITIAL_WINDOW_SIZE */ 0,
/* H2SET_MAX_FRAME_SIZE */ 16384,
/* H2SET_MAX_HEADER_LIST_SIZE */ 512,
Expand Down
12 changes: 7 additions & 5 deletions lib/plat/freertos/freertos-pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "private-lib-core.h"

#include <lwip/sockets.h>

int
lws_plat_pipe_create(struct lws *wsi)
{
Expand All @@ -41,11 +43,11 @@ lws_plat_pipe_create(struct lws *wsi)
* ephemeral range for us.
*/

fd[0] = socket(AF_INET, SOCK_DGRAM, 0);
fd[0] = lwip_socket(AF_INET, SOCK_DGRAM, 0);
if (fd[0] < 0)
goto bail;

fd[1] = socket(AF_INET, SOCK_DGRAM, 0);
fd[1] = lwip_socket(AF_INET, SOCK_DGRAM, 0);
if (fd[1] < 0)
goto bail;

Expand All @@ -59,7 +61,7 @@ lws_plat_pipe_create(struct lws *wsi)
si->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
si->sin_port = 0;

if (bind(fd[0], (const struct sockaddr *)si, sizeof(*si)) < 0)
if (lwip_bind(fd[0], (const struct sockaddr *)si, sizeof(*si)) < 0)
goto bail;

/*
Expand All @@ -71,7 +73,7 @@ lws_plat_pipe_create(struct lws *wsi)
*/

sl = sizeof(*si);
if (getsockname(fd[0], (struct sockaddr *)si, &sl))
if (lwip_getsockname(fd[0], (struct sockaddr *)si, &sl))
goto bail;

lwsl_info("%s: cancel UDP skt port %d\n", __func__,
Expand Down Expand Up @@ -106,7 +108,7 @@ lws_plat_pipe_signal(struct lws_context *ctx, int tsi)
* (on udp/raw netconn, doing a sendto/recv is currently possible).
*/

n = sendto(fd[1], &u, 1, 0, (struct sockaddr *)si, sizeof(*si));
n = lwip_sendto(fd[1], &u, 1, 0, (struct sockaddr *)si, sizeof(*si));

return n != 1;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/plat/freertos/freertos-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lws_plat_service(struct lws_context *context, int timeout_ms)
{
int n = _lws_plat_service_tsi(context, timeout_ms, 0);

#if !defined(LWS_AMAZON_RTOS)
#if !defined(LWS_AMAZON_RTOS) && defined(LWS_ESP_PLATFORM) && defined(CONFIG_ESP_INT_WDT)
esp_task_wdt_reset();
#endif

Expand Down
18 changes: 9 additions & 9 deletions lib/plat/freertos/freertos-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
if (vhost->ka_time) {
/* enable keepalive on this socket */
optval = 1;
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
if (lwip_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
(const void *)&optval, optlen) < 0)
return 1;

Expand All @@ -115,25 +115,25 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
#else
/* set the keepalive conditions we want on it too */
optval = vhost->ka_time;
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE,
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE,
(const void *)&optval, optlen) < 0)
return 1;

optval = vhost->ka_interval;
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL,
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL,
(const void *)&optval, optlen) < 0)
return 1;

optval = vhost->ka_probes;
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT,
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT,
(const void *)&optval, optlen) < 0)
return 1;
#endif
}

/* Disable Nagle */
optval = 1;
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &optval, optlen) < 0)
if (lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &optval, optlen) < 0)
return 1;

return lws_plat_set_nonblocking(fd);
Expand Down Expand Up @@ -162,7 +162,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)

#if defined(SO_PRIORITY)
if (pri) { /* 0 is the default already */
if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY,
if (lwip_setsockopt(fd, SOL_SOCKET, SO_PRIORITY,
(const void *)&optval, optlen) < 0) {
#if !defined(LWS_WITH_NO_LOGS)
en = errno;
Expand All @@ -177,7 +177,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)

if (lws_flags & LCCSCF_ALLOW_REUSE_ADDR) {
optval = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
if (lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval, optlen) < 0) {
#if !defined(LWS_WITH_NO_LOGS)
en = errno;
Expand All @@ -194,7 +194,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
continue;

optval = (int)ip_opt_val[n];
if (setsockopt(fd, IPPROTO_IP, IP_TOS, (const void *)&optval,
if (lwip_setsockopt(fd, IPPROTO_IP, IP_TOS, (const void *)&optval,
optlen) < 0) {
#if !defined(LWS_WITH_NO_LOGS)
en = errno;
Expand Down Expand Up @@ -288,7 +288,7 @@ lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
const char *
lws_plat_inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
{
return inet_ntop(af, src, dst, cnt);
return lwip_inet_ntop(af, src, dst, cnt);
}

int
Expand Down
3 changes: 3 additions & 0 deletions lib/plat/freertos/private-lib-plat-freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
#include "freertos/timers.h"
#if defined(LWS_ESP_PLATFORM)
#include <esp_attr.h>
#if !defined(ETHER_ADDR_LEN)
#define ETHER_ADDR_LEN 6
#endif
#endif
#include <esp_system.h>
#include <esp_task_wdt.h>
Expand Down
4 changes: 4 additions & 0 deletions lib/roles/http/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ _lws_vhost_init_server_af(struct vh_sock_args *a)
GetCurrentProcess(), (HANDLE*)&sockfd, 0,
FALSE, DUPLICATE_SAME_ACCESS))
sockfd = LWS_SOCK_INVALID;
#else
#if defined(LWS_PLAT_FREERTOS)
sockfd = a->info->vh_listen_sockfd;
#else
sockfd = dup(a->info->vh_listen_sockfd);
#endif
#endif
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ gai_strerror(int);
#endif

#if defined(LWS_WITH_ESP32)
#include "lwip/port/include/lwipopts.h"
#include "lwip/apps/sntp.h"
#include <errno.h>
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ESP_PLATFORM)
project(lws-minimal-esp32 C)
enable_testing()

target_link_libraries(lws-minimal-esp32.elf websockets)
target_link_libraries(lws-minimal-esp32.elf PRIVATE websockets)

option(LWS_WITH_DRIVERS "With generic drivers for gpio, i2c, display etc" ON)
set(LWS_WITH_DRIVERS ON)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
idf_component_register(SRCS
lws-minimal-esp32.c
devices.c
INCLUDE_DIRS "../libwebsockets/include;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include;${IDF_PATH}/components/mdns/include")
INCLUDE_DIRS "../libwebsockets/include;${IDF_PATH}/components/spi_flash/include;${IDF_PATH}/components/nvs_flash/include;${IDF_PATH}/components/lwip/port/include")
#;${IDF_PATH}/components/mdns/include")

target_link_libraries(${COMPONENT_LIB} websockets)
include_directories(../build/libwebsockets)
4 changes: 2 additions & 2 deletions minimal-examples/embedded/esp32/esp-wrover-kit/main/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ init_plat_devices(struct lws_context *ctx)

memset(&creds, 0, sizeof(creds));

lws_strncpy(creds.ssid, "xxx", sizeof(creds.ssid));
lws_strncpy(creds.passphrase, "yyy", sizeof(creds.passphrase));
// lws_strncpy(creds.ssid, "Ulxxxx", sizeof(creds.ssid));
// lws_strncpy(creds.passphrase, "secret", sizeof(creds.passphrase));
lws_dll2_add_tail(&creds.list, &netdevs->owner_creds);

if (lws_netdev_credentials_settings_set(netdevs)) {
Expand Down
Loading

0 comments on commit 4393edf

Please sign in to comment.