Skip to content

Commit e346d06

Browse files
committed
new board generator option to enable WPS / disable extra 4k in heap
1 parent 3fddf2a commit e346d06

File tree

7 files changed

+59
-12
lines changed

7 files changed

+59
-12
lines changed

cores/esp8266/core_esp8266_main.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,24 @@ void init_done() {
156156
* Peripherals (except for SPI0 and UART0) are not initialized.
157157
* This function does not return.
158158
*/
159-
#define EXTRA_4K_HEAP 1
160159

161-
#if !EXTRA_4K_HEAP
160+
/* provided or not by boards.txt */
161+
/* #define NO_EXTRA_4K_HEAP */
162+
163+
164+
#ifdef NO_EXTRA_4K_HEAP
165+
/* this is the default NONOS-SDK user's heap location */
162166
cont_t g_cont __attribute__ ((aligned (16)));
163167
#endif
164168

165169
extern "C" void ICACHE_RAM_ATTR app_entry(void)
166170
{
171+
#ifdef NO_EXTRA_4K_HEAP
172+
g_pcont = &g_cont;
173+
#else
167174
/* Allocate continuation context on this stack, and save pointer to it. */
168-
#if EXTRA_4K_HEAP
169175
cont_t s_cont __attribute__((aligned(16)));
170176
g_pcont = &s_cont;
171-
#else
172-
g_pcont = &g_cont;
173177
#endif
174178
/* Call the entry point of the SDK code. */
175179
call_user_start();

doc/faq/readme.rst

+20
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ entering an issue report, please perform initial troubleshooting.
4040

4141
`Read more <a02-my-esp-crashes.rst>`__.
4242

43+
How can I get some extra KBs in flash ?
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45+
46+
Using `*printf()` with floats is enabled by default. Some KBs of flash can
47+
be saved by using the option `--nofloat` with the boards generator:
48+
49+
```
50+
./tools/boards.txt.py --nofloat --allgen
51+
```
52+
53+
Why can't I use WPS ?
54+
~~~~~~~~~~~~~~~~~~~~~
55+
56+
WPS is disabled by default, this offers an extra 4KB in ram/heap. To enable
57+
WPS, use this boards generator option:
58+
59+
```
60+
./tools/boards.txt.py --noextra4kheap --allgen
61+
```
62+
4363
This Arduino library doesn't work on ESP. How do I make it work?
4464
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4565

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ int32_t ESP8266WiFiSTAClass::RSSI(void) {
571571
// -------------------------------------------------- STA remote configure -----------------------------------------------
572572
// -----------------------------------------------------------------------------------------------------------------------
573573

574+
#ifdef NO_EXTRA_4K_HEAP
575+
574576
void wifi_wps_status_cb(wps_cb_status status);
575577

576578
/**
@@ -650,7 +652,7 @@ void wifi_wps_status_cb(wps_cb_status status) {
650652
esp_schedule(); // resume the beginWPSConfig function
651653
}
652654

653-
655+
#endif // NO_EXTRA_4K_HEAP
654656

655657
bool ESP8266WiFiSTAClass::_smartConfigStarted = false;
656658
bool ESP8266WiFiSTAClass::_smartConfigDone = false;

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "ESP8266WiFiType.h"
2828
#include "ESP8266WiFiGeneric.h"
29+
#include "user_interface.h"
2930

3031

3132
class ESP8266WiFiSTAClass {
@@ -92,7 +93,13 @@ class ESP8266WiFiSTAClass {
9293

9394
public:
9495

96+
#ifdef NO_EXTRA_4K_HEAP
9597
bool beginWPSConfig(void);
98+
#else
99+
inline bool beginWPSConfig(void) __attribute__((always_inline)) {
100+
return WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool();
101+
}
102+
#endif
96103

97104
bool beginSmartConfig();
98105
bool stopSmartConfig();

platform.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ build.vtable_flags=-DVTABLES_IN_FLASH
2525

2626
build.float=-u _printf_float -u _scanf_float
2727
build.led=
28+
build.noextra4kheap=
2829

2930
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
3031
compiler.sdk.path={runtime.platform.path}/tools/sdk
3132
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
3233
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"
3334

3435
compiler.c.cmd=xtensa-lx106-elf-gcc
35-
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
36+
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
3637

3738
compiler.S.cmd=xtensa-lx106-elf-gcc
3839
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
@@ -43,7 +44,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
4344
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
4445

4546
compiler.cpp.cmd=xtensa-lx106-elf-g++
46-
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
47+
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
4748

4849
compiler.as.cmd=xtensa-lx106-elf-as
4950

tools/boards.txt.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,9 @@ def all_boards ():
12361236
if nofloat:
12371237
print id + '.build.float='
12381238

1239+
if noextra4kheap:
1240+
print id + '.build.noextra4kheap=-DNO_EXTRA_4K_HEAP'
1241+
12391242
print ''
12401243

12411244
if boardsgen:
@@ -1253,11 +1256,8 @@ def package ():
12531256

12541257
if packagegen:
12551258
pkgfname_read = pkgfname + '.orig'
1256-
# check if backup already exists
12571259
if os.path.isfile(pkgfname_read):
1258-
print "package file is in the way, please move it"
1259-
print " %s" % pkgfname_read
1260-
sys.exit(1)
1260+
os.remove(pkgfname_read)
12611261
os.rename(pkgfname, pkgfname_read)
12621262

12631263
# read package file
@@ -1333,6 +1333,7 @@ def usage (name,ret):
13331333
print " --speed s - change default serial speed"
13341334
print " --customspeed s - new serial speed for all boards"
13351335
print " --nofloat - disable float support in printf/scanf"
1336+
print " --noextra4kheap - disable extra 4k heap (will enable WPS)"
13361337
print ""
13371338
print " mandatory option (at least one):"
13381339
print ""
@@ -1376,6 +1377,7 @@ def usage (name,ret):
13761377
led_default = 2
13771378
led_max = 16
13781379
nofloat = False
1380+
noextra4kheap = False
13791381
ldgen = False
13801382
ldshow = False
13811383
boardsgen = False
@@ -1391,6 +1393,7 @@ def usage (name,ret):
13911393
try:
13921394
opts, args = getopt.getopt(sys.argv[1:], "h",
13931395
[ "help", "lwip=", "led=", "speed=", "board=", "customspeed=", "nofloat",
1396+
"noextra4kheap",
13941397
"ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen",
13951398
"allgen"] )
13961399
except getopt.GetoptError as err:
@@ -1434,6 +1437,9 @@ def usage (name,ret):
14341437
elif o in ("--nofloat"):
14351438
nofloat=True
14361439

1440+
elif o in ("--noextra4kheap"):
1441+
noextra4kheap=True
1442+
14371443
elif o in ("--ldshow"):
14381444
ldshow = True
14391445

tools/sdk/include/user_interface.h

+7
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,16 @@ enum wps_cb_status {
575575
WPS_CB_ST_UNK,
576576
};
577577

578+
#ifdef NO_EXTRA_4K_HEAP
578579
bool wifi_wps_enable(WPS_TYPE_t wps_type);
579580
bool wifi_wps_disable(void);
580581
bool wifi_wps_start(void);
582+
#else
583+
bool WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool ();
584+
#define wifi_wps_enable(...) WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool()
585+
#define wifi_wps_disable() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool()
586+
#define wifi_wps_start() WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool()
587+
#endif
581588

582589
typedef void (*wps_st_cb_t)(int status);
583590
bool wifi_set_wps_cb(wps_st_cb_t cb);

0 commit comments

Comments
 (0)