From 3fddf2a0e1e53e7df1413c2d331584e9ac0c7418 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Fri, 29 Jun 2018 13:13:55 +0200 Subject: [PATCH 1/9] allow to disable SYS continuation stack --- cores/esp8266/core_esp8266_main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 52ba57857b..e72240cb54 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -156,11 +156,21 @@ void init_done() { * Peripherals (except for SPI0 and UART0) are not initialized. * This function does not return. */ +#define EXTRA_4K_HEAP 1 + +#if !EXTRA_4K_HEAP +cont_t g_cont __attribute__ ((aligned (16))); +#endif + extern "C" void ICACHE_RAM_ATTR app_entry(void) { /* Allocate continuation context on this stack, and save pointer to it. */ +#if EXTRA_4K_HEAP cont_t s_cont __attribute__((aligned(16))); g_pcont = &s_cont; +#else + g_pcont = &g_cont; +#endif /* Call the entry point of the SDK code. */ call_user_start(); } From e346d06c120d354b988bf1a4761b6cab241d9fd2 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Wed, 4 Jul 2018 13:05:28 +0200 Subject: [PATCH 2/9] new board generator option to enable WPS / disable extra 4k in heap --- cores/esp8266/core_esp8266_main.cpp | 14 +++++++++----- doc/faq/readme.rst | 20 ++++++++++++++++++++ libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 4 +++- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h | 7 +++++++ platform.txt | 5 +++-- tools/boards.txt.py | 14 ++++++++++---- tools/sdk/include/user_interface.h | 7 +++++++ 7 files changed, 59 insertions(+), 12 deletions(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index e72240cb54..1b7777feb2 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -156,20 +156,24 @@ void init_done() { * Peripherals (except for SPI0 and UART0) are not initialized. * This function does not return. */ -#define EXTRA_4K_HEAP 1 -#if !EXTRA_4K_HEAP +/* provided or not by boards.txt */ +/* #define NO_EXTRA_4K_HEAP */ + + +#ifdef NO_EXTRA_4K_HEAP +/* this is the default NONOS-SDK user's heap location */ cont_t g_cont __attribute__ ((aligned (16))); #endif extern "C" void ICACHE_RAM_ATTR app_entry(void) { +#ifdef NO_EXTRA_4K_HEAP + g_pcont = &g_cont; +#else /* Allocate continuation context on this stack, and save pointer to it. */ -#if EXTRA_4K_HEAP cont_t s_cont __attribute__((aligned(16))); g_pcont = &s_cont; -#else - g_pcont = &g_cont; #endif /* Call the entry point of the SDK code. */ call_user_start(); diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 2f469ddda2..7c78b0b4fb 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -40,6 +40,26 @@ entering an issue report, please perform initial troubleshooting. `Read more `__. +How can I get some extra KBs in flash ? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Using `*printf()` with floats is enabled by default. Some KBs of flash can +be saved by using the option `--nofloat` with the boards generator: + +``` +./tools/boards.txt.py --nofloat --allgen +``` + +Why can't I use WPS ? +~~~~~~~~~~~~~~~~~~~~~ + +WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable +WPS, use this boards generator option: + +``` +./tools/boards.txt.py --noextra4kheap --allgen +``` + This Arduino library doesn't work on ESP. How do I make it work? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 1d8cadfdb1..5d6f249c64 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -571,6 +571,8 @@ int32_t ESP8266WiFiSTAClass::RSSI(void) { // -------------------------------------------------- STA remote configure ----------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- +#ifdef NO_EXTRA_4K_HEAP + void wifi_wps_status_cb(wps_cb_status status); /** @@ -650,7 +652,7 @@ void wifi_wps_status_cb(wps_cb_status status) { esp_schedule(); // resume the beginWPSConfig function } - +#endif // NO_EXTRA_4K_HEAP bool ESP8266WiFiSTAClass::_smartConfigStarted = false; bool ESP8266WiFiSTAClass::_smartConfigDone = false; diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h index f08c179b5b..f94ba0a4d3 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h @@ -26,6 +26,7 @@ #include "ESP8266WiFiType.h" #include "ESP8266WiFiGeneric.h" +#include "user_interface.h" class ESP8266WiFiSTAClass { @@ -92,7 +93,13 @@ class ESP8266WiFiSTAClass { public: +#ifdef NO_EXTRA_4K_HEAP bool beginWPSConfig(void); +#else + inline bool beginWPSConfig(void) __attribute__((always_inline)) { + return WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool(); + } +#endif bool beginSmartConfig(); bool stopSmartConfig(); diff --git a/platform.txt b/platform.txt index 429cea6ec2..69b2d6536c 100644 --- a/platform.txt +++ b/platform.txt @@ -25,6 +25,7 @@ build.vtable_flags=-DVTABLES_IN_FLASH build.float=-u _printf_float -u _scanf_float build.led= +build.noextra4kheap= compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/ compiler.sdk.path={runtime.platform.path}/tools/sdk @@ -32,7 +33,7 @@ compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core" compiler.c.cmd=xtensa-lx106-elf-gcc -compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections +compiler.c.flags=-c {compiler.warning_flags} {build.noextra4kheap} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections compiler.S.cmd=xtensa-lx106-elf-gcc compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls @@ -43,7 +44,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc compiler.cpp.cmd=xtensa-lx106-elf-g++ -compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections +compiler.cpp.flags=-c {compiler.warning_flags} {build.noextra4kheap} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections compiler.as.cmd=xtensa-lx106-elf-as diff --git a/tools/boards.txt.py b/tools/boards.txt.py index 7da8dac54e..b4ed0352d7 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -1236,6 +1236,9 @@ def all_boards (): if nofloat: print id + '.build.float=' + if noextra4kheap: + print id + '.build.noextra4kheap=-DNO_EXTRA_4K_HEAP' + print '' if boardsgen: @@ -1253,11 +1256,8 @@ def package (): if packagegen: pkgfname_read = pkgfname + '.orig' - # check if backup already exists if os.path.isfile(pkgfname_read): - print "package file is in the way, please move it" - print " %s" % pkgfname_read - sys.exit(1) + os.remove(pkgfname_read) os.rename(pkgfname, pkgfname_read) # read package file @@ -1333,6 +1333,7 @@ def usage (name,ret): print " --speed s - change default serial speed" print " --customspeed s - new serial speed for all boards" print " --nofloat - disable float support in printf/scanf" + print " --noextra4kheap - disable extra 4k heap (will enable WPS)" print "" print " mandatory option (at least one):" print "" @@ -1376,6 +1377,7 @@ def usage (name,ret): led_default = 2 led_max = 16 nofloat = False +noextra4kheap = False ldgen = False ldshow = False boardsgen = False @@ -1391,6 +1393,7 @@ def usage (name,ret): try: opts, args = getopt.getopt(sys.argv[1:], "h", [ "help", "lwip=", "led=", "speed=", "board=", "customspeed=", "nofloat", + "noextra4kheap", "ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen", "allgen"] ) except getopt.GetoptError as err: @@ -1434,6 +1437,9 @@ def usage (name,ret): elif o in ("--nofloat"): nofloat=True + elif o in ("--noextra4kheap"): + noextra4kheap=True + elif o in ("--ldshow"): ldshow = True diff --git a/tools/sdk/include/user_interface.h b/tools/sdk/include/user_interface.h index 4d12133b1e..97cc4e515b 100644 --- a/tools/sdk/include/user_interface.h +++ b/tools/sdk/include/user_interface.h @@ -575,9 +575,16 @@ enum wps_cb_status { WPS_CB_ST_UNK, }; +#ifdef NO_EXTRA_4K_HEAP bool wifi_wps_enable(WPS_TYPE_t wps_type); bool wifi_wps_disable(void); bool wifi_wps_start(void); +#else +bool WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool (); +#define wifi_wps_enable(...) WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() +#define wifi_wps_disable() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() +#define wifi_wps_start() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() +#endif typedef void (*wps_st_cb_t)(int status); bool wifi_set_wps_cb(wps_st_cb_t cb); From 852b6a88fc3da95dc31443eccef2d53d8d38447b Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Wed, 4 Jul 2018 13:11:51 +0200 Subject: [PATCH 3/9] doc formatting --- doc/faq/readme.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 7c78b0b4fb..351b94a22e 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -43,12 +43,10 @@ entering an issue report, please perform initial troubleshooting. How can I get some extra KBs in flash ? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Using `*printf()` with floats is enabled by default. Some KBs of flash can -be saved by using the option `--nofloat` with the boards generator: +Using ``*printf()`` with floats is enabled by default. Some KBs of flash can +be saved by using the option ``--nofloat`` with the boards generator: -``` -./tools/boards.txt.py --nofloat --allgen -``` +``./tools/boards.txt.py --nofloat --allgen`` Why can't I use WPS ? ~~~~~~~~~~~~~~~~~~~~~ @@ -56,9 +54,7 @@ Why can't I use WPS ? WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable WPS, use this boards generator option: -``` -./tools/boards.txt.py --noextra4kheap --allgen -``` +``./tools/boards.txt.py --noextra4kheap --allgen`` This Arduino library doesn't work on ESP. How do I make it work? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 24e2aa709969d00f87388de7988cad8a7b079a24 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 5 Jul 2018 11:55:06 +0200 Subject: [PATCH 4/9] add --allowWPS option as a synonym, add history of this patch in sources --- cores/esp8266/core_esp8266_main.cpp | 43 +++++++++++++++++++++++++++-- doc/faq/readme.rst | 2 +- tools/boards.txt.py | 5 ++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 1b7777feb2..dc73656fee 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -156,10 +156,40 @@ void init_done() { * Peripherals (except for SPI0 and UART0) are not initialized. * This function does not return. */ +/* + A bit of explanation for this entry point: + + SYS is the RTOS task/context used by the upperlying system to run its + administrative tasks (at least WLAN and lwip's receive callbacks and + Ticker). NONOS-SDK is designed to run users's non-threaded code in + another specific task/context with its own stack in BSS. + + Some clever fellows found that the SYS stack was a large and quite unused + piece of ram that we could use for the user stack, and proposed to use it + to store the user stack instead of using the users' main memory, thus + saving around 4KB or ram/heap. + + A problem arose later, which is that this stack is heavily used by the + system for some features. One of these features is WPS. We still don't + know if other features are using this, or if this memory is going to be + used in future releases. + + WPS beeing flawed by its poor security, or not beeing used by lots of + users, it has been decided that we are still going to use that memory for + the users's stack and disable the use of WPS, with an option to revert + that back at the user's discretion. This selection can be done by using + the board generator script. This could be also done by setting up a new + option in the IDE's Tools menu. + + The behavior is controlled by the globally NO_EXTRA_4K_HEAP define below. -/* provided or not by boards.txt */ -/* #define NO_EXTRA_4K_HEAP */ + References: + https://github.com/esp8266/Arduino/pull/4553 + https://github.com/esp8266/Arduino/pull/4622 + https://github.com/esp8266/Arduino/issues/4779 + https://github.com/esp8266/Arduino/pull/4889 +*/ #ifdef NO_EXTRA_4K_HEAP /* this is the default NONOS-SDK user's heap location */ @@ -169,12 +199,19 @@ cont_t g_cont __attribute__ ((aligned (16))); extern "C" void ICACHE_RAM_ATTR app_entry(void) { #ifdef NO_EXTRA_4K_HEAP + + /* this is the default NONOS-SDK user's heap location */ g_pcont = &g_cont; + #else - /* Allocate continuation context on this stack, and save pointer to it. */ + + /* Allocate continuation context on this SYS stack, + and save pointer to it. */ cont_t s_cont __attribute__((aligned(16))); g_pcont = &s_cont; + #endif + /* Call the entry point of the SDK code. */ call_user_start(); } diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 351b94a22e..528ed92139 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -54,7 +54,7 @@ Why can't I use WPS ? WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable WPS, use this boards generator option: -``./tools/boards.txt.py --noextra4kheap --allgen`` +``./tools/boards.txt.py --allowWPS --allgen`` This Arduino library doesn't work on ESP. How do I make it work? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/boards.txt.py b/tools/boards.txt.py index b4ed0352d7..b79dc21933 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -1334,6 +1334,7 @@ def usage (name,ret): print " --customspeed s - new serial speed for all boards" print " --nofloat - disable float support in printf/scanf" print " --noextra4kheap - disable extra 4k heap (will enable WPS)" + print " --allowWPS - synonym for --noextra4kheap" print "" print " mandatory option (at least one):" print "" @@ -1393,7 +1394,7 @@ def usage (name,ret): try: opts, args = getopt.getopt(sys.argv[1:], "h", [ "help", "lwip=", "led=", "speed=", "board=", "customspeed=", "nofloat", - "noextra4kheap", + "noextra4kheap", "allowWPS", "ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen", "allgen"] ) except getopt.GetoptError as err: @@ -1437,7 +1438,7 @@ def usage (name,ret): elif o in ("--nofloat"): nofloat=True - elif o in ("--noextra4kheap"): + elif o in ("--noextra4kheap", "--allowWPS"): noextra4kheap=True elif o in ("--ldshow"): From a962930aed48ee11941688dfe525b80bd2531fff Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 5 Jul 2018 12:17:38 +0200 Subject: [PATCH 5/9] typo --- cores/esp8266/core_esp8266_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index dc73656fee..2ec4b3e152 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -167,7 +167,7 @@ void init_done() { Some clever fellows found that the SYS stack was a large and quite unused piece of ram that we could use for the user stack, and proposed to use it to store the user stack instead of using the users' main memory, thus - saving around 4KB or ram/heap. + saving around 4KB on ram/heap. A problem arose later, which is that this stack is heavily used by the system for some features. One of these features is WPS. We still don't From 69a185b656f1419b79f5b0d45c26a42ea1b919de Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 5 Jul 2018 12:22:52 +0200 Subject: [PATCH 6/9] add wifi_set_wps_cb() to protected calls --- tools/sdk/include/user_interface.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/sdk/include/user_interface.h b/tools/sdk/include/user_interface.h index 97cc4e515b..d2a4152ef7 100644 --- a/tools/sdk/include/user_interface.h +++ b/tools/sdk/include/user_interface.h @@ -575,19 +575,26 @@ enum wps_cb_status { WPS_CB_ST_UNK, }; +typedef void (*wps_st_cb_t)(int status); + #ifdef NO_EXTRA_4K_HEAP +/* check cores/esp8266/core_esp8266_main.cpp for comments about this */ + bool wifi_wps_enable(WPS_TYPE_t wps_type); bool wifi_wps_disable(void); bool wifi_wps_start(void); +bool wifi_set_wps_cb(wps_st_cb_t cb); + #else + bool WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool (); #define wifi_wps_enable(...) WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() #define wifi_wps_disable() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() #define wifi_wps_start() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() +#define wifi_set_wps_cb(...) WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool() + #endif -typedef void (*wps_st_cb_t)(int status); -bool wifi_set_wps_cb(wps_st_cb_t cb); typedef void (*freedom_outside_cb_t)(uint8 status); int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb); From 9614781832b6c4321f14817432eacfa16b8e01c1 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 5 Jul 2018 12:27:01 +0200 Subject: [PATCH 7/9] update faq --- doc/faq/readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 528ed92139..96e6ffaa98 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -52,7 +52,7 @@ Why can't I use WPS ? ~~~~~~~~~~~~~~~~~~~~~ WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable -WPS, use this boards generator option: +WPS (and loose 4KB of useable ram), use this boards generator option: ``./tools/boards.txt.py --allowWPS --allgen`` From 54396984ccc0ce8f9380c285bf2f21dd469fa593 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 5 Jul 2018 12:30:30 +0200 Subject: [PATCH 8/9] WPS source doc update --- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 5d6f249c64..730b52886a 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -572,6 +572,7 @@ int32_t ESP8266WiFiSTAClass::RSSI(void) { // ----------------------------------------------------------------------------------------------------------------------- #ifdef NO_EXTRA_4K_HEAP +/* NO_EXTRA_4K_HEAP's description in cores/esp8266/core_esp8266_main.cpp */ void wifi_wps_status_cb(wps_cb_status status); From a049162174207cf597ed6dd1454e5b9399dd7479 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Fri, 6 Jul 2018 10:03:08 +0200 Subject: [PATCH 9/9] doc typo & update --- cores/esp8266/core_esp8266_main.cpp | 25 +++++++++++-------------- doc/faq/readme.rst | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 2ec4b3e152..ba878b5679 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -159,29 +159,26 @@ void init_done() { /* A bit of explanation for this entry point: - SYS is the RTOS task/context used by the upperlying system to run its + SYS is the SDK task/context used by the upperlying system to run its administrative tasks (at least WLAN and lwip's receive callbacks and - Ticker). NONOS-SDK is designed to run users's non-threaded code in + Ticker). NONOS-SDK is designed to run user's non-threaded code in another specific task/context with its own stack in BSS. Some clever fellows found that the SYS stack was a large and quite unused - piece of ram that we could use for the user stack, and proposed to use it - to store the user stack instead of using the users' main memory, thus - saving around 4KB on ram/heap. + piece of ram that we could use for the user's stack instead of using user's + main memory, thus saving around 4KB on ram/heap. - A problem arose later, which is that this stack is heavily used by the - system for some features. One of these features is WPS. We still don't + A problem arose later, which is that this stack can heavily be used by + the SDK for some features. One of these features is WPS. We still don't know if other features are using this, or if this memory is going to be - used in future releases. + used in future SDK releases. WPS beeing flawed by its poor security, or not beeing used by lots of users, it has been decided that we are still going to use that memory for - the users's stack and disable the use of WPS, with an option to revert - that back at the user's discretion. This selection can be done by using - the board generator script. This could be also done by setting up a new - option in the IDE's Tools menu. - - The behavior is controlled by the globally NO_EXTRA_4K_HEAP define below. + user's stack and disable the use of WPS, with an option to revert that + back at the user's discretion. This selection can be done with the + global define NO_EXTRA_4K_HEAP. An option has been added to the board + generator script. References: https://github.com/esp8266/Arduino/pull/4553 diff --git a/doc/faq/readme.rst b/doc/faq/readme.rst index 96e6ffaa98..e21f83b707 100644 --- a/doc/faq/readme.rst +++ b/doc/faq/readme.rst @@ -52,7 +52,7 @@ Why can't I use WPS ? ~~~~~~~~~~~~~~~~~~~~~ WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable -WPS (and loose 4KB of useable ram), use this boards generator option: +WPS (and lose 4KB of useable ram), use this boards generator option: ``./tools/boards.txt.py --allowWPS --allgen``