diff --git a/lib/plat/esp32/esp32-fds.c b/lib/plat/esp32/esp32-fds.c
index e23192e3f21479879d86a603f447f8448778d899..7551f1f8dca045a213d080cefd80005394efb711 100644
--- a/lib/plat/esp32/esp32-fds.c
+++ b/lib/plat/esp32/esp32-fds.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-#include <esp_task_wdt.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
 
 void
 lws_plat_insert_socket_into_fds(struct lws_context *context, struct lws *wsi)
diff --git a/lib/plat/esp32/esp32-file.c b/lib/plat/esp32/esp32-file.c
index 41bca2210afc6ac036cd199d99845ff0e08481f8..92d7dd5844326b2459cd4e5aea5866cbda9a4629 100644
--- a/lib/plat/esp32/esp32-file.c
+++ b/lib/plat/esp32/esp32-file.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
 
 int lws_plat_apply_FD_CLOEXEC(int n)
 {
diff --git a/lib/plat/esp32/esp32-helpers.c b/lib/plat/esp32/esp32-helpers.c
index cf60784e507448703e49bfbc9cf0cf42d22cd9ac..9bd4cd4e7083c374e5d00a84d362ca4d1b4abfce 100644
--- a/lib/plat/esp32/esp32-helpers.c
+++ b/lib/plat/esp32/esp32-helpers.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
 
 #include "misc/romfs.h"
 #include <esp_ota_ops.h>
diff --git a/lib/plat/esp32/esp32-init.c b/lib/plat/esp32/esp32-init.c
index 8cf4ee1b2a50e12ab0a515564f5e1691122be561..eac556d07f76c0274a9544bcb7eb8acdacc9fdfb 100644
--- a/lib/plat/esp32/esp32-init.c
+++ b/lib/plat/esp32/esp32-init.c
@@ -20,15 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
-
 
 int
 lws_plat_context_early_init(void)
diff --git a/lib/plat/esp32/esp32-misc.c b/lib/plat/esp32/esp32-misc.c
index 1360d2f5b49f104d2b593e11f1d41594f4feed60..3dfb0288c92fb1ed21e9fdbdf8557e17fdeda9f1 100644
--- a/lib/plat/esp32/esp32-misc.c
+++ b/lib/plat/esp32/esp32-misc.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
 
 unsigned long long time_in_microseconds(void)
 {
diff --git a/lib/plat/esp32/esp32-pipe.c b/lib/plat/esp32/esp32-pipe.c
index 2f1cd6babce9218cb3b570dc2e440b7c73f51384..c8e11c8c668e02dbb1ffc000e7de9e58c8add2c1 100644
--- a/lib/plat/esp32/esp32-pipe.c
+++ b/lib/plat/esp32/esp32-pipe.c
@@ -20,15 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
-
 
 int
 lws_plat_pipe_create(struct lws *wsi)
diff --git a/lib/plat/esp32/esp32-service.c b/lib/plat/esp32/esp32-service.c
index fcf3488eb872d5c4e00925b8b79b11826886ef32..2f7f05e268fd91d5075a59f4f9b271aae6b3c689 100644
--- a/lib/plat/esp32/esp32-service.c
+++ b/lib/plat/esp32/esp32-service.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
 
 int
 lws_plat_service(struct lws_context *context, int timeout_ms)
diff --git a/lib/plat/esp32/esp32-sockets.c b/lib/plat/esp32/esp32-sockets.c
index 7a592d797027547d6381e819a97d7981b1f6da12..060d72508bd68874a0cbb685f469a0b23ebb5f53 100644
--- a/lib/plat/esp32/esp32-sockets.c
+++ b/lib/plat/esp32/esp32-sockets.c
@@ -20,14 +20,6 @@
  */
 
 #include "core/private.h"
-#include "freertos/timers.h"
-#include <esp_attr.h>
-#include <esp_system.h>
-
-#include "apps/sntp/sntp.h"
-
-#include <lwip/sockets.h>
-#include <esp_task_wdt.h>
 
 int
 lws_send_pipe_choked(struct lws *wsi)
diff --git a/lib/plat/esp32/private.h b/lib/plat/esp32/private.h
index 3d32d4460b7b7b2a09bc11342bd2404223648c28..74de11c7d89f2bc9b1137bf68c5fbcfdf405763c 100644
--- a/lib/plat/esp32/private.h
+++ b/lib/plat/esp32/private.h
@@ -39,6 +39,15 @@
  #include <signal.h>
  #include <sys/socket.h>
 
+#include "freertos/timers.h"
+#include <esp_attr.h>
+#include <esp_system.h>
+#include <esp_task_wdt.h>
+
+#include "lwip/apps/sntp.h"
+
+#include <lwip/sockets.h>
+
  #if defined(LWS_BUILTIN_GETIFADDRS)
   #include "./misc/getifaddrs.h"
  #endif
diff --git a/scripts/esp32.mk b/scripts/esp32.mk
index f2728a70777ff53f1910b00aef56e81da46cd094..4a4de2b657eeafee513c7a9741dd205d2c4534b7 100644
--- a/scripts/esp32.mk
+++ b/scripts/esp32.mk
@@ -98,14 +98,14 @@ lws_flash_ota: $(LWS_BUILD_PATH)/pack.img
 		--chip esp32 \
 		--port $(ESPPORT) \
 		--baud $(CONFIG_ESPTOOLPY_BAUD) \
-		write_flash 0x110000 $(LWS_BUILD_PATH)/$(PROJECT_NAME).bin
+		write_flash 0x120000 $(LWS_BUILD_PATH)/$(PROJECT_NAME).bin
 
 lws_erase_ota:
 	$(IDF_PATH)/components/esptool_py/esptool/esptool.py \
 	        --chip esp32 \
 	        --port $(ESPPORT) \
 	        --baud $(CONFIG_ESPTOOLPY_BAUD) \
-	        erase_region 0x110000 0x2f0000
+	        erase_region 0x120000 0x2e0000
 
 
 export A