Skip to content

Commit 24e2aa7

Browse files
committed
add --allowWPS option as a synonym, add history of this patch in sources
1 parent 852b6a8 commit 24e2aa7

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

cores/esp8266/core_esp8266_main.cpp

+40-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,40 @@ void init_done() {
156156
* Peripherals (except for SPI0 and UART0) are not initialized.
157157
* This function does not return.
158158
*/
159+
/*
160+
A bit of explanation for this entry point:
161+
162+
SYS is the RTOS task/context used by the upperlying system to run its
163+
administrative tasks (at least WLAN and lwip's receive callbacks and
164+
Ticker). NONOS-SDK is designed to run users's non-threaded code in
165+
another specific task/context with its own stack in BSS.
166+
167+
Some clever fellows found that the SYS stack was a large and quite unused
168+
piece of ram that we could use for the user stack, and proposed to use it
169+
to store the user stack instead of using the users' main memory, thus
170+
saving around 4KB or ram/heap.
171+
172+
A problem arose later, which is that this stack is heavily used by the
173+
system for some features. One of these features is WPS. We still don't
174+
know if other features are using this, or if this memory is going to be
175+
used in future releases.
176+
177+
WPS beeing flawed by its poor security, or not beeing used by lots of
178+
users, it has been decided that we are still going to use that memory for
179+
the users's stack and disable the use of WPS, with an option to revert
180+
that back at the user's discretion. This selection can be done by using
181+
the board generator script. This could be also done by setting up a new
182+
option in the IDE's Tools menu.
183+
184+
The behavior is controlled by the globally NO_EXTRA_4K_HEAP define below.
159185
160-
/* provided or not by boards.txt */
161-
/* #define NO_EXTRA_4K_HEAP */
186+
References:
187+
https://github.com/esp8266/Arduino/pull/4553
188+
https://github.com/esp8266/Arduino/pull/4622
189+
https://github.com/esp8266/Arduino/issues/4779
190+
https://github.com/esp8266/Arduino/pull/4889
162191
192+
*/
163193

164194
#ifdef NO_EXTRA_4K_HEAP
165195
/* this is the default NONOS-SDK user's heap location */
@@ -169,12 +199,19 @@ cont_t g_cont __attribute__ ((aligned (16)));
169199
extern "C" void ICACHE_RAM_ATTR app_entry(void)
170200
{
171201
#ifdef NO_EXTRA_4K_HEAP
202+
203+
/* this is the default NONOS-SDK user's heap location */
172204
g_pcont = &g_cont;
205+
173206
#else
174-
/* Allocate continuation context on this stack, and save pointer to it. */
207+
208+
/* Allocate continuation context on this SYS stack,
209+
and save pointer to it. */
175210
cont_t s_cont __attribute__((aligned(16)));
176211
g_pcont = &s_cont;
212+
177213
#endif
214+
178215
/* Call the entry point of the SDK code. */
179216
call_user_start();
180217
}

doc/faq/readme.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Why can't I use WPS ?
5454
WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable
5555
WPS, use this boards generator option:
5656

57-
``./tools/boards.txt.py --noextra4kheap --allgen``
57+
``./tools/boards.txt.py --allowWPS --allgen``
5858

5959
This Arduino library doesn't work on ESP. How do I make it work?
6060
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/boards.txt.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ def usage (name,ret):
13341334
print " --customspeed s - new serial speed for all boards"
13351335
print " --nofloat - disable float support in printf/scanf"
13361336
print " --noextra4kheap - disable extra 4k heap (will enable WPS)"
1337+
print " --allowWPS - synonym for --noextra4kheap"
13371338
print ""
13381339
print " mandatory option (at least one):"
13391340
print ""
@@ -1393,7 +1394,7 @@ def usage (name,ret):
13931394
try:
13941395
opts, args = getopt.getopt(sys.argv[1:], "h",
13951396
[ "help", "lwip=", "led=", "speed=", "board=", "customspeed=", "nofloat",
1396-
"noextra4kheap",
1397+
"noextra4kheap", "allowWPS",
13971398
"ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen",
13981399
"allgen"] )
13991400
except getopt.GetoptError as err:
@@ -1437,7 +1438,7 @@ def usage (name,ret):
14371438
elif o in ("--nofloat"):
14381439
nofloat=True
14391440

1440-
elif o in ("--noextra4kheap"):
1441+
elif o in ("--noextra4kheap", "--allowWPS"):
14411442
noextra4kheap=True
14421443

14431444
elif o in ("--ldshow"):

0 commit comments

Comments
 (0)