diff --git a/cpu/esp8266/Makefile.dep b/cpu/esp8266/Makefile.dep
index 8ad433be38b0a3d376b60837ce98526a3a9bc838..cbbab2332446429d2cf3039b184b6d3fb264b536 100644
--- a/cpu/esp8266/Makefile.dep
+++ b/cpu/esp8266/Makefile.dep
@@ -1,5 +1,15 @@
 # additional modules dependencies
 
+ifneq (, $(filter esp_sdk, $(USEMODULE)))
+    USEMODULE += core_thread_flags
+endif
+
+ifneq (, $(filter esp_spiffs, $(USEMODULE)))
+    export SPIFFS_STD_OPTION = -std=c99
+    USEMODULE += spiffs
+    USEMODULE += vfs
+endif
+
 ifneq (, $(filter lua, $(USEPKG)))
     USEMODULE += newlib_syscalls_default
     USEMODULE += xtimer
@@ -35,13 +45,3 @@ endif
 ifneq (, $(filter newlib_syscalls_default, $(USEMODULE)))
     USEMODULE += stdio_uart
 endif
-
-# network interface dependencies
-ifneq (, $(filter netdev_default, $(USEMODULE)))
-    # if NETDEV_DEFAULT is empty, we use module mrf24j40 as default network device
-    ifndef NETDEV_DEFAULT
-        USEMODULE += mrf24j40
-    else
-        USEMODULE += $(NETDEV_DEFAULT)
-    endif
-endif
diff --git a/cpu/esp8266/Makefile.include b/cpu/esp8266/Makefile.include
index b3802d6c9ea63dd41b8f0c84f202a463213d882a..72fcdaace04831400f8c226698d23ccd44f8c3a2 100644
--- a/cpu/esp8266/Makefile.include
+++ b/cpu/esp8266/Makefile.include
@@ -24,6 +24,16 @@ endif
 
 ifeq ($(ENABLE_GDBSTUB), 1)
     USEMODULE += esp_gdbstub
+endif
+
+# SPECIAL module dependencies
+# cannot be done in Makefile.dep since Makefile.dep is included too late
+
+ifneq (, $(filter esp_sw_timer, $(USEMODULE)))
+    USEMODULE += esp_sdk
+endif
+
+ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
     USEMODULE += esp_gdb
 endif
 
@@ -39,7 +49,17 @@ PSEUDOMODULES += esp_sdk_int_handling
 PSEUDOMODULES += esp_sw_timer
 PSEUDOMODULES += esp_spiffs
 
+USEMODULE += esp
+USEMODULE += mtd
+USEMODULE += periph
+USEMODULE += periph_common
+USEMODULE += ps
+USEMODULE += random
+USEMODULE += sdk
+USEMODULE += xtensa
+
 ifneq (, $(filter pthread, $(USEMODULE)))
+    # has to be included before $(ESP8266_NEWLIB_DIR)
     INCLUDES += -I$(RIOTBASE)/sys/posix/pthread/include
 endif
 
@@ -49,13 +69,14 @@ INCLUDES += -I$(RIOTCPU)/$(CPU)
 INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor
 INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/espressif
 
-CFLAGS  += -DESP_OPEN_SDK
+CFLAGS  += -DESP_OPEN_SDK -DSCHED_PRIO_LEVELS=32
 CFLAGS  += -Wno-unused-parameter -Wformat=0
-CFLAGS  += -mlongcalls -mtext-section-literals -fdata-sections
+CFLAGS  += -mlongcalls -mtext-section-literals
+CFLAGS  += -fdata-sections -fzero-initialized-in-bss
 ASFLAGS += --longcalls --text-section-literals
 
-ifneq (, $(filter esp_sw_timer, $(USEMODULE)))
-    USEMODULE += esp_sdk
+ifeq (, $(filter esp_sdk_int_handling, $(USEMODULE)))
+    CFLAGS += -DCONTEXT_SWITCH_BY_INT
 endif
 
 ifneq (, $(filter esp_sdk, $(USEMODULE)))
@@ -70,17 +91,9 @@ ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
 endif
 
 ifneq (, $(filter esp_gdb, $(USEMODULE)))
-    CFLAGS_OPT = -fzero-initialized-in-bss -Og -ggdb -g3
+    CFLAGS += -Og -ggdb -g3
 else
-    CFLAGS_OPT = -fzero-initialized-in-bss -O2
-endif
-
-CFLAGS += $(CFLAGS_OPT)
-
-ifneq (, $(filter esp_spiffs, $(USEMODULE)))
-    export SPIFFS_STD_OPTION = -std=c99
-    USEMODULE += spiffs
-    USEMODULE += vfs
+    CFLAGS += -Os
 endif
 
 ifeq ($(QEMU), 1)
@@ -115,15 +128,6 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/eagle.rom.addr.v6.ld
 LINKFLAGS += -nostdlib -lgcc -u ets_run -Wl,-gc-sections # -Wl,--print-gc-sections
 LINKFLAGS += -Wl,--warn-unresolved-symbols
 
-USEMODULE += esp
-USEMODULE += mtd
-USEMODULE += periph
-USEMODULE += periph_common
-USEMODULE += ps
-USEMODULE += random
-USEMODULE += sdk
-USEMODULE += xtensa
-
 # configure preflasher to convert .elf to .bin before flashing
 FLASH_SIZE = -fs 8m
 export PREFLASHER ?= esptool.py
@@ -143,5 +147,5 @@ else
     export FFLAGS += -p $(PORT) -b $(PROGRAMMER_SPEED) write_flash
     export FFLAGS += -fm $(FLASH_MODE)
     export FFLAGS += 0 $(ELFFILE)-0x00000.bin
-    export FFLAGS += 0x10000 $(ELFFILE)-0x10000.bin
+    export FFLAGS += 0x10000 $(ELFFILE)-0x10000.bin; esptool.py -p $(PORT) run
 endif