Skip to content

Commit 7745e99

Browse files
authored
Revert to nonos-sdk 2.2.1, new sdk-switching option in IDE menu for generic board only (#5763)
This commit allows switching SDK firmware: nonos-sdk-pre-v3 shipped with release 2.5.0 has issues: * Some boards show erratic behavior (radio connection is quickly lost), with an unknown cause. These boards work well with previous nonos-sdk-2.2.1 firmware (#5736) * Overall performances seem to have decreased (#5513) This PR restores sdk2.2.1 (as in core-2.4.2). SDK-pre-3.0 - which has brought long awaited fixes (WiFi sleep modes) - is still available through a menu option available only with generic board. BREAKING * new define `-DNONOSDK221=1` or `-DNONOSDK3V0=1` * for external build systems: new library directory: `tools/sdk/lib/<version>/lib` * PIO: variable `PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3` is needed for sdk-pre-v3. Fix #5736
1 parent 9790e1c commit 7745e99

35 files changed

+74
-191
lines changed

boards.txt

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ menu.vt=VTables
2020
menu.exception=Exceptions
2121
menu.led=Builtin Led
2222
menu.wipe=Erase Flash
23+
menu.sdk=Espressif FW
2324

2425
##############################################################
2526
generic.name=Generic ESP8266 Module
@@ -349,6 +350,10 @@ generic.menu.led.14=14
349350
generic.menu.led.14.build.led=-DLED_BUILTIN=14
350351
generic.menu.led.15=15
351352
generic.menu.led.15.build.led=-DLED_BUILTIN=15
353+
generic.menu.sdk.nonosdk221=nonos-sdk 2.2.1
354+
generic.menu.sdk.nonosdk221.build.sdk=NONOSDK221
355+
generic.menu.sdk.nonosdk3v0=nonos-sdk pre-3
356+
generic.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0
352357
generic.menu.ip.lm2f=v2 Lower Memory
353358
generic.menu.ip.lm2f.build.lwip_include=lwip2/include
354359
generic.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ int32_t ESP8266WiFiGenericClass::channel(void) {
249249
* @param type sleep_type_t
250250
* @return bool
251251
*/
252+
#ifdef NONOSDK221
253+
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
254+
(void)type;
255+
(void)listenInterval;
256+
return false;
257+
}
258+
#else // !defined(NONOSDK221)
252259
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
253260

254261
/**
@@ -315,6 +322,7 @@ bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenI
315322
}
316323
return ret;
317324
}
325+
#endif // !defined(NONOSDK221)
318326

319327
/**
320328
* get Sleep mode
@@ -499,15 +507,23 @@ bool ESP8266WiFiGenericClass::forceSleepWake() {
499507
* @return interval
500508
*/
501509
uint8_t ESP8266WiFiGenericClass::getListenInterval () {
510+
#ifdef NONOSDK221
511+
return 0;
512+
#else
502513
return wifi_get_listen_interval();
514+
#endif
503515
}
504516

505517
/**
506518
* Get sleep level of modem sleep and light sleep
507519
* @return true if max level
508520
*/
509521
bool ESP8266WiFiGenericClass::isSleepLevelMax () {
522+
#ifdef NONOSDK221
523+
return false;
524+
#else
510525
return wifi_get_sleep_level() == MAX_SLEEP_T;
526+
#endif
511527
}
512528

513529

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
138138
}
139139

140140
conf.threshold.rssi = -127;
141+
#ifndef NONOSDK221
141142
conf.open_and_wep_mode_disable = !(_useInsecureWEP || *conf.password == 0);
143+
#endif
142144

143145
if(bssid) {
144146
conf.bssid_set = 1;

platform.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ build.stdcpp_lib=-lstdc++
3434

3535
build.float=-u _printf_float -u _scanf_float
3636
build.led=
37+
build.sdk=NONOSDK221
3738

3839
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
3940
compiler.sdk.path={runtime.platform.path}/tools/sdk
41+
4042
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
4143
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"
4244

@@ -46,7 +48,7 @@ compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implici
4648
compiler.S.cmd=xtensa-lx106-elf-gcc
4749
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
4850

49-
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u app_entry {build.float} -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read
51+
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u app_entry {build.float} -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/lib/{build.sdk}" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read
5052

5153
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
5254
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 {build.stdcpp_lib} -lm -lc -lgcc
@@ -88,13 +90,13 @@ recipe.hooks.core.prebuild.2.pattern="{runtime.tools.python}" "{runtime.tools.ma
8890
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -CC -E -P {build.vtable_flags} "{runtime.platform.path}/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "{build.path}/local.eagle.app.v6.common.ld"
8991

9092
## Compile c files
91-
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
93+
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
9294

9395
## Compile c++ files
94-
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
96+
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
9597

9698
## Compile S files
97-
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
99+
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -D{build.sdk}=1 -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {build.led} {build.flash_flags} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
98100

99101
## Create archives
100102
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

tests/host/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ endif
129129
FLAGS += $(DEBUG) -Wall -coverage $(OPTZ) -fno-common -g $(M32)
130130
FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0
131131
FLAGS += -DLWIP_IPV6=0
132+
FLAGS += -DNONOSDK221=1
132133
FLAGS += $(MKFLAGS)
133134
CXXFLAGS += -std=c++11 $(FLAGS)
134135
CFLAGS += -std=c99 $(FLAGS)

tools/boards.txt.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
'flashmode_menu',
7171
'512K', '1M', '2M', '4M', '8M', '16M',
7272
'led',
73+
'sdk',
7374
],
7475
'desc': [ 'These modules come in different form factors and pinouts. See the page at ESP8266 community wiki for more info: `ESP8266 Module Family <http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family>`__.',
7576
'',
@@ -1326,6 +1327,18 @@ def led (default,max):
13261327
]))
13271328
return { 'led': led }
13281329

1330+
################################################################
1331+
# sdk selection
1332+
1333+
def sdk ():
1334+
return { 'sdk': collections.OrderedDict([
1335+
('.menu.sdk.nonosdk221', 'nonos-sdk 2.2.1'),
1336+
('.menu.sdk.nonosdk221.build.sdk', 'NONOSDK221'),
1337+
('.menu.sdk.nonosdk3v0', 'nonos-sdk pre-3'),
1338+
('.menu.sdk.nonosdk3v0.build.sdk', 'NONOSDK3V0'),
1339+
])
1340+
}
1341+
13291342
################################################################
13301343

13311344
def all_boards ():
@@ -1344,6 +1357,7 @@ def all_boards ():
13441357
macros.update(all_flash_map())
13451358
macros.update(all_debug())
13461359
macros.update(led(led_default, led_max))
1360+
macros.update(sdk())
13471361

13481362
print('#')
13491363
print('# Do not create pull-requests for this file only, CI will not accept them.')
@@ -1367,6 +1381,7 @@ def all_boards ():
13671381
print('menu.exception=Exceptions')
13681382
print('menu.led=Builtin Led')
13691383
print('menu.wipe=Erase Flash')
1384+
print('menu.sdk=Espressif FW')
13701385
print('')
13711386

13721387
for id in boards:
@@ -1498,12 +1513,12 @@ def usage (name,ret):
14981513
print("usage: %s [options]" % name)
14991514
print("")
15001515
print(" -h, --help")
1501-
print(" --lwip - preferred default lwIP version (default %d)" % lwip)
1502-
print(" --led - preferred default builtin led for generic boards (default %d)" % led_default)
1503-
print(" --board b - board to modify:")
1504-
print(" --speed s - change default serial speed")
1505-
print(" --customspeed s - new serial speed for all boards")
1506-
print(" --nofloat - disable float support in printf/scanf")
1516+
print(" --lwip - preferred default lwIP version (default %d)" % lwip)
1517+
print(" --led - preferred default builtin led for generic boards (default %d)" % led_default)
1518+
print(" --board <b> - board to modify:")
1519+
print(" --speed <s> - change default serial speed")
1520+
print(" --customspeed <s> - new serial speed for all boards")
1521+
print(" --nofloat - disable float support in printf/scanf")
15071522
print("")
15081523
print(" mandatory option (at least one):")
15091524
print("")
@@ -1610,7 +1625,7 @@ def usage (name,ret):
16101625
elif o in ("--noextra4kheap", "--allowWPS"):
16111626
print('option ' + o + ' is now deprecated, without effect, and will be removed')
16121627

1613-
elif o in ("--ldshow"):
1628+
elif o in ("--ld"):
16141629
ldshow = True
16151630

16161631
elif o in ("--ldgen"):

tools/platformio-build.py

+15
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ def scons_patched_match_splitext(path, suffixes=None):
131131

132132
flatten_cppdefines = env.Flatten(env['CPPDEFINES'])
133133

134+
#
135+
# SDK
136+
#
137+
if "PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3" in flatten_cppdefines:
138+
env.Append(
139+
CPPDEFINES=[("NONOSDK3V0", 1)],
140+
LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK3V0"),]
141+
)
142+
# PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK221 (default)
143+
else:
144+
env.Append(
145+
CPPDEFINES=[("NONOSDK221", 1)],
146+
LIBPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lib", "NONOSDK221"),]
147+
)
148+
134149
#
135150
# lwIP
136151
#

tools/sdk/include/at_custom.h

-180
This file was deleted.

0 commit comments

Comments
 (0)