|
| 1 | +From 710c104882cd151c7f461d1cf4dfa01f793fde54 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Vikram Dattu <vikram.dattu@espressif.com> |
| 3 | +Date: Tue, 6 Aug 2024 11:55:22 +0530 |
| 4 | +Subject: [PATCH 1/2] Fixes for IDF deep sleep and lwip_split_for_esp_hosted |
| 5 | + |
| 6 | +--- |
| 7 | + components/lwip/port/include/lwipopts.h | 46 +++++++++++++++++++ |
| 8 | + .../components/cmd_system/cmd_system.c | 1 + |
| 9 | + .../components/cmd_system/cmd_system_sleep.c | 6 ++- |
| 10 | + 3 files changed, 51 insertions(+), 2 deletions(-) |
| 11 | + |
| 12 | +diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h |
| 13 | +index d150106f81..0ec2f3883e 100644 |
| 14 | +--- a/components/lwip/port/include/lwipopts.h |
| 15 | ++++ b/components/lwip/port/include/lwipopts.h |
| 16 | +@@ -1673,6 +1673,52 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) |
| 17 | + #define mem_clib_calloc calloc |
| 18 | + #endif /* CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP */ |
| 19 | + |
| 20 | ++#ifdef CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_START |
| 21 | ++#define TCP_LOCAL_PORT_RANGE_START CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_START |
| 22 | ++#define TCP_LOCAL_PORT_RANGE_END CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END |
| 23 | ++#define TCP_ENSURE_LOCAL_PORT_RANGE(port) ((port)%(TCP_LOCAL_PORT_RANGE_END+1-TCP_LOCAL_PORT_RANGE_START)+TCP_LOCAL_PORT_RANGE_START) |
| 24 | ++#if CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END == 0xffff |
| 25 | ++ #define IS_LOCAL_TCP_PORT(port) (port>=TCP_LOCAL_PORT_RANGE_START) |
| 26 | ++#else |
| 27 | ++ #define IS_LOCAL_TCP_PORT(port) (port>=TCP_LOCAL_PORT_RANGE_START && (port<=CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END)) |
| 28 | ++#endif |
| 29 | ++#endif |
| 30 | ++ |
| 31 | ++#ifdef CONFIG_LWIP_TCP_REMOTE_PORT_RANGE_START |
| 32 | ++#define TCP_REMOTE_PORT_RANGE_START CONFIG_LWIP_TCP_REMOTE_PORT_RANGE_START |
| 33 | ++#define TCP_REMOTE_PORT_RANGE_END CONFIG_LWIP_TCP_REMOTE_PORT_RANGE_END |
| 34 | ++#define TCP_ENSURE_REMOTE_PORT_RANGE(port) ((port)%(TCP_REMOTE_PORT_RANGE_END+1-TCP_REMOTE_PORT_RANGE_START)+TCP_REMOTE_PORT_RANGE_START) |
| 35 | ++#if CONFIG_LWIP_TCP_REMOTE_PORT_RANGE_END == 0xffff |
| 36 | ++ #define IS_REMOTE_TCP_PORT(port) (port>=TCP_REMOTE_PORT_RANGE_START) |
| 37 | ++#else |
| 38 | ++ #define IS_REMOTE_TCP_PORT(port) (port>=TCP_REMOTE_PORT_RANGE_START && (port<=CONFIG_LWIP_TCP_REMOTE_PORT_RANGE_END)) |
| 39 | ++#endif |
| 40 | ++#endif |
| 41 | ++ |
| 42 | ++#ifdef CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_START |
| 43 | ++#define UDP_LOCAL_PORT_RANGE_START CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_START |
| 44 | ++#define UDP_LOCAL_PORT_RANGE_END CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END |
| 45 | ++#define UDP_ENSURE_LOCAL_PORT_RANGE(port) ((u16_t)(((port) & (u16_t)~UDP_LOCAL_PORT_RANGE_START) + UDP_LOCAL_PORT_RANGE_START)) |
| 46 | ++ |
| 47 | ++#if CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END == 0xffff |
| 48 | ++ #define IS_LOCAL_UDP_PORT(port) (port>=UDP_LOCAL_PORT_RANGE_START) |
| 49 | ++#else |
| 50 | ++ #define IS_LOCAL_UDP_PORT(port) (port>=UDP_LOCAL_PORT_RANGE_START && (port<=CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END)) |
| 51 | ++#endif |
| 52 | ++#define DNS_PORT_ALLOWED(port) IS_LOCAL_UDP_PORT(port) |
| 53 | ++#endif |
| 54 | ++ |
| 55 | ++#ifdef CONFIG_LWIP_UDP_REMOTE_PORT_RANGE_START |
| 56 | ++#define UDP_REMOTE_PORT_RANGE_START CONFIG_LWIP_UDP_REMOTE_PORT_RANGE_START |
| 57 | ++#define UDP_REMOTE_PORT_RANGE_END CONFIG_LWIP_UDP_REMOTE_PORT_RANGE_END |
| 58 | ++#define UDP_ENSURE_REMOTE_PORT_RANGE(port) ((u16_t)(((port) & (u16_t)~UDP_REMOTE_PORT_RANGE_START) + UDP_REMOTE_PORT_RANGE_START)) |
| 59 | ++ |
| 60 | ++#if CONFIG_LWIP_UDP_REMOTE_PORT_RANGE_END == 0xffff |
| 61 | ++ #define IS_REMOTE_UDP_PORT(port) (port>=UDP_REMOTE_PORT_RANGE_START) |
| 62 | ++#else |
| 63 | ++ #define IS_REMOTE_UDP_PORT(port) (port>=UDP_REMOTE_PORT_RANGE_START && (port<=CONFIG_LWIP_UDP_REMOTE_PORT_RANGE_END)) |
| 64 | ++#endif |
| 65 | ++#endif |
| 66 | + |
| 67 | + /* |
| 68 | + * Check if the lwIP configuration is sane |
| 69 | +diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system.c b/examples/system/console/advanced/components/cmd_system/cmd_system.c |
| 70 | +index 761053ff98..f1867e5f96 100644 |
| 71 | +--- a/examples/system/console/advanced/components/cmd_system/cmd_system.c |
| 72 | ++++ b/examples/system/console/advanced/components/cmd_system/cmd_system.c |
| 73 | +@@ -10,6 +10,7 @@ |
| 74 | + |
| 75 | + #include "cmd_system.h" |
| 76 | + #include "sdkconfig.h" |
| 77 | ++#include "soc/soc_caps.h" |
| 78 | + |
| 79 | + void register_system(void) |
| 80 | + { |
| 81 | +diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c |
| 82 | +index 4aad14d6f3..f8bd5c6b7e 100644 |
| 83 | +--- a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c |
| 84 | ++++ b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c |
| 85 | +@@ -29,7 +29,7 @@ |
| 86 | + |
| 87 | + static const char *TAG = "cmd_system_sleep"; |
| 88 | + |
| 89 | +-#if SOC_DEEP_SLEEP_SUPPORTED |
| 90 | ++#if CONFIG_SOC_DEEP_SLEEP_SUPPORTED |
| 91 | + /** 'deep_sleep' command puts the chip into deep sleep mode */ |
| 92 | + static struct { |
| 93 | + struct arg_int *wakeup_time; |
| 94 | +@@ -41,6 +41,7 @@ static struct { |
| 95 | + } deep_sleep_args; |
| 96 | + |
| 97 | + |
| 98 | ++extern int send_slave_power_save(int ps); |
| 99 | + static int deep_sleep(int argc, char **argv) |
| 100 | + { |
| 101 | + int nerrors = arg_parse(argc, argv, (void **) &deep_sleep_args); |
| 102 | +@@ -80,6 +81,7 @@ static int deep_sleep(int argc, char **argv) |
| 103 | + #if CONFIG_IDF_TARGET_ESP32 |
| 104 | + rtc_gpio_isolate(GPIO_NUM_12); |
| 105 | + #endif //CONFIG_IDF_TARGET_ESP32 |
| 106 | ++ send_slave_power_save(1); |
| 107 | + esp_deep_sleep_start(); |
| 108 | + return 1; |
| 109 | + } |
| 110 | +@@ -116,7 +118,7 @@ void register_system_deep_sleep(void) |
| 111 | + } |
| 112 | + #endif // SOC_DEEP_SLEEP_SUPPORTED |
| 113 | + |
| 114 | +-#if SOC_LIGHT_SLEEP_SUPPORTED |
| 115 | ++#if CONFIG_SOC_LIGHT_SLEEP_SUPPORTED |
| 116 | + /** 'light_sleep' command puts the chip into light sleep mode */ |
| 117 | + static struct { |
| 118 | + struct arg_int *wakeup_time; |
| 119 | +-- |
| 120 | +2.39.3 (Apple Git-146) |
| 121 | + |
0 commit comments