From 88dc16737bbf41a531294fe0d0b0a2ba76417ad1 Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Thu, 4 Jun 2015 23:45:03 -0700 Subject: [PATCH] reduce memory consumption --- Makefile | 6 +++--- httpd/httpd.c | 3 ++- serial/serbridge.c | 3 +++ serial/serbridge.h | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fb6c253..78a5f5d 100644 --- a/Makefile +++ b/Makefile @@ -114,14 +114,14 @@ LIBS = c gcc hal phy pp net80211 wpa main lwip # compiler flags using during compilation of source files CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ - -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -D_STDINT_H \ - -Wno-address -DFIRMWARE_SIZE=$(ESP_FLASH_MAX) \ + -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections \ + -D__ets__ -DICACHE_FLASH -D_STDINT_H -Wno-address -DFIRMWARE_SIZE=$(ESP_FLASH_MAX) \ -DMCU_RESET_PIN=$(MCU_RESET_PIN) -DMCU_ISP_PIN=$(MCU_ISP_PIN) \ -DLED_CONN_PIN=$(LED_CONN_PIN) -DLED_SERIAL_PIN=$(LED_SERIAL_PIN) \ "-DVERSION=$(VERSION)" # linker flags used to generate the main object file -LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static +LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--gc-sections # linker script used for the above linker step LD_SCRIPT := build/eagle.esphttpd.v6.ld diff --git a/httpd/httpd.c b/httpd/httpd.c index 61b20cf..1f2d945 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -19,7 +19,7 @@ Esp8266 http server - core routines //Max length of request head #define MAX_HEAD_LEN 1024 //Max amount of connections -#define MAX_CONN 8 +#define MAX_CONN 4 //Max post buffer len #define MAX_POST 1024 //Max send buffer len @@ -543,4 +543,5 @@ void ICACHE_FLASH_ATTR httpdInit(HttpdBuiltInUrl *fixedUrls, int port) { os_printf("Httpd init, conn=%p\n", &httpdConn); espconn_regist_connectcb(&httpdConn, httpdConnectCb); espconn_accept(&httpdConn); + espconn_tcp_set_max_con_allow(&httpdConn, MAX_CONN); } diff --git a/serial/serbridge.c b/serial/serbridge.c index 0cb5f83..2b2d0dc 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -281,6 +281,8 @@ static void ICACHE_FLASH_ATTR serbridgeConnectCb(void *arg) { espconn_regist_reconcb(conn, serbridgeReconCb); espconn_regist_disconcb(conn, serbridgeDisconCb); espconn_regist_sentcb(conn, serbridgeSentCb); + + espconn_set_opt(conn, ESPCONN_REUSEADDR|ESPCONN_NODELAY); } // callback with a buffer of characters that have arrived on the uart @@ -320,5 +322,6 @@ void ICACHE_FLASH_ATTR serbridgeInit(int port, uint8_t reset_pin, uint8_t isp_pi espconn_regist_connectcb(&serbridgeConn, serbridgeConnectCb); espconn_accept(&serbridgeConn); + espconn_tcp_set_max_con_allow(&serbridgeConn, MAX_CONN); espconn_regist_time(&serbridgeConn, SER_BRIDGE_TIMEOUT, 0); } diff --git a/serial/serbridge.h b/serial/serbridge.h index 095b38a..9335238 100644 --- a/serial/serbridge.h +++ b/serial/serbridge.h @@ -5,7 +5,7 @@ #include #include -#define MAX_CONN 5 +#define MAX_CONN 4 #define SER_BRIDGE_TIMEOUT 28799 //Max send buffer len