From c5dc164a9ff0a9972e8ee9b490246f82153b8c01 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Wed, 23 Nov 2022 18:12:52 +0800 Subject: [PATCH 1/4] Add option to favor DRAM allocation over IRAM for 32-bit capable mem --- components/heap/Kconfig | 8 ++++++++ components/heap/port/esp8266/esp_heap_init.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/components/heap/Kconfig b/components/heap/Kconfig index 551cf58d4..9bc8ce7c1 100644 --- a/components/heap/Kconfig +++ b/components/heap/Kconfig @@ -13,4 +13,12 @@ menu "Heap memory" help Enables heap tracing API. + config HEAP_PRIO_8BIT_RAM + bool "Prioritize allocation of 8-bit access capable RAM" + default n + depends on !HEAP_DISABLE_IRAM + help + Set DRAM region ahead of IRAM region during initialization, so that allocations + can be made against it first. + endmenu diff --git a/components/heap/port/esp8266/esp_heap_init.c b/components/heap/port/esp8266/esp_heap_init.c index 8135911be..5d950adbe 100644 --- a/components/heap/port/esp8266/esp_heap_init.c +++ b/components/heap/port/esp8266/esp_heap_init.c @@ -39,6 +39,23 @@ void heap_caps_init(void) extern char _bss_end; size_t heap_region_num = 0; +#if CONFIG_HEAP_PRIO_8BIT_RAM + g_heap_region[heap_region_num].start_addr = (uint8_t *)&_bss_end; + g_heap_region[heap_region_num].total_size = ((size_t)(0x40000000 - (uint32_t)&_bss_end)); + g_heap_region[heap_region_num].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA; + heap_region_num++; + + // CONFIG_HEAP_PRIO_8BIT_RAM is only available when CONFIG_HEAP_DISABLE_IRAM=n + extern char _iram_end; + const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t)&_iram_end); + + if (iram_size > HEAP_REGION_IRAM_MIN && iram_size < HEAP_REGION_IRAM_MAX) { + g_heap_region[heap_region_num].start_addr = (uint8_t *)&_iram_end; + g_heap_region[heap_region_num].total_size = iram_size; + g_heap_region[heap_region_num].caps = MALLOC_CAP_32BIT | MALLOC_CAP_EXEC; + heap_region_num++; + } +#else #ifndef CONFIG_HEAP_DISABLE_IRAM extern char _iram_end; const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t)&_iram_end); @@ -55,6 +72,7 @@ void heap_caps_init(void) g_heap_region[heap_region_num].total_size = ((size_t)(0x40000000 - (uint32_t)&_bss_end)); g_heap_region[heap_region_num].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA; heap_region_num++; +#endif esp_heap_caps_init_region(g_heap_region, heap_region_num); } From 7dd0a43622695fed038f6870837a0d7bbbc56487 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Tue, 15 Nov 2022 11:55:01 +0800 Subject: [PATCH 2/4] Fix CMake inexplicit extension warning --- components/spi_flash/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index 255eff8e7..287e63c13 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -1,4 +1,4 @@ -set(srcs "src/partition" +set(srcs "src/partition.c" "src/spi_flash_raw.c" "src/spi_flash.c") if(BOOTLOADER_BUILD) From 9877e1c147cd70bfea6ae6765814a980376b0046 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Tue, 15 Nov 2022 11:49:12 +0800 Subject: [PATCH 3/4] Fix warnings when LWIP asserts are disabled --- components/lwip/port/esp8266/freertos/sys_arch.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/lwip/port/esp8266/freertos/sys_arch.c b/components/lwip/port/esp8266/freertos/sys_arch.c index 8338a3480..add9a64af 100644 --- a/components/lwip/port/esp8266/freertos/sys_arch.c +++ b/components/lwip/port/esp8266/freertos/sys_arch.c @@ -81,6 +81,7 @@ sys_mutex_lock(sys_mutex_t *pxMutex) BaseType_t ret = xSemaphoreTake(*pxMutex, portMAX_DELAY); LWIP_ASSERT("failed to take the mutex", ret == pdTRUE); + (void)ret; } /** @@ -94,6 +95,7 @@ sys_mutex_unlock(sys_mutex_t *pxMutex) BaseType_t ret = xSemaphoreGive(*pxMutex); LWIP_ASSERT("failed to give the mutex", ret == pdTRUE); + (void)ret; } /** @@ -133,6 +135,7 @@ sys_sem_new(sys_sem_t *sem, u8_t count) if (count == 1) { BaseType_t ret = xSemaphoreGive(*sem); LWIP_ASSERT("sys_sem_new: initial give failed", ret == pdTRUE); + (void)ret; } return ERR_OK; @@ -150,6 +153,7 @@ sys_sem_signal(sys_sem_t *sem) /* queue full is OK, this is a signal only... */ LWIP_ASSERT("sys_sem_signal: sane return value", (ret == pdTRUE) || (ret == errQUEUE_FULL)); + (void)ret; } /*-----------------------------------------------------------------------------------*/ @@ -246,6 +250,7 @@ sys_mbox_post(sys_mbox_t *mbox, void *msg) { BaseType_t ret = xQueueSendToBack((*mbox)->os_mbox, &msg, portMAX_DELAY); LWIP_ASSERT("mbox post failed", ret == pdTRUE); + (void)ret; } /** @@ -385,6 +390,8 @@ sys_mbox_free(sys_mbox_t *mbox) vQueueDelete((*mbox)->os_mbox); free(*mbox); *mbox = NULL; + + (void)msgs_waiting; } /** From fe2c92b497d2d6c5d908e7d1262ed605df193284 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Thu, 5 Jan 2023 16:08:01 +0800 Subject: [PATCH 4/4] Allow configurable max hostname length --- components/tcpip_adapter/Kconfig | 7 +++++++ components/tcpip_adapter/include/tcpip_adapter.h | 1 - components/tcpip_adapter/tcpip_adapter_lwip.c | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/tcpip_adapter/Kconfig b/components/tcpip_adapter/Kconfig index 1c803476e..33be3d2c0 100644 --- a/components/tcpip_adapter/Kconfig +++ b/components/tcpip_adapter/Kconfig @@ -21,4 +21,11 @@ config TCPIP_ADAPTER_GLOBAL_DATA_LINK_IRAM help Link TCPIP adapter global data(.bss .data COMMON) from DRAM to IRAM. +config TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH + int "Max hostname length" + range 1 253 + default 32 + help + Maximum number of characters in the local hostname + endmenu diff --git a/components/tcpip_adapter/include/tcpip_adapter.h b/components/tcpip_adapter/include/tcpip_adapter.h index 8f3a76bcc..7b645ce0b 100644 --- a/components/tcpip_adapter/include/tcpip_adapter.h +++ b/components/tcpip_adapter/include/tcpip_adapter.h @@ -609,7 +609,6 @@ esp_interface_t tcpip_adapter_get_esp_if(void *dev); */ esp_err_t tcpip_adapter_get_sta_list(wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list); -#define TCPIP_HOSTNAME_MAX_SIZE 32 /** * @brief Set the hostname to the interface * diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index bf3f8bad9..e4cbd5b36 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -46,6 +46,8 @@ #include "FreeRTOS.h" #include "timers.h" +#include "sdkconfig.h" + struct tcpip_adapter_pbuf { struct pbuf_custom pbuf; @@ -1217,13 +1219,13 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho { #if LWIP_NETIF_HOSTNAME struct netif *p_netif; - static char hostinfo[TCPIP_ADAPTER_IF_MAX][TCPIP_HOSTNAME_MAX_SIZE + 1]; + static char hostinfo[TCPIP_ADAPTER_IF_MAX][CONFIG_TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH + 1]; if (tcpip_if >= TCPIP_ADAPTER_IF_MAX || hostname == NULL) { return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS; } - if (strlen(hostname) > TCPIP_HOSTNAME_MAX_SIZE) { + if (strlen(hostname) > CONFIG_TCPIP_ADAPTER_HOSTNAME_MAX_LENGTH) { return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS; }