Skip to content

Commit 247d5f1

Browse files
Merge branch 'master' into stdnothrow
2 parents 3ee6710 + b9db944 commit 247d5f1

File tree

14 files changed

+119
-63
lines changed

14 files changed

+119
-63
lines changed

.github/workflows/pull-request.yml

+7
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,16 @@ jobs:
251251
- uses: actions/setup-python@v2
252252
with:
253253
python-version: '3.x'
254+
- name: Cache Linux toolchain
255+
id: cache-linux
256+
uses: actions/cache@v2
257+
with:
258+
path: ./tools/dist
259+
key: key-linux-toolchain
254260
- name: Boards.txt diff
255261
env:
256262
TRAVIS_BUILD_DIR: ${{ github.workspace }}
257263
TRAVIS_TAG: ${{ github.ref }}
258264
run: |
259265
bash ./tests/ci/build_boards.sh
266+
bash ./tests/ci/eboot_test.sh

boards.txt

+12
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,18 @@ esp8285.menu.led.15=15
712712
esp8285.menu.led.15.build.led=-DLED_BUILTIN=15
713713
esp8285.menu.led.16=16
714714
esp8285.menu.led.16.build.led=-DLED_BUILTIN=16
715+
esp8285.menu.sdk.nonosdk_190703=nonos-sdk 2.2.1+100 (190703)
716+
esp8285.menu.sdk.nonosdk_190703.build.sdk=NONOSDK22x_190703
717+
esp8285.menu.sdk.nonosdk_191122=nonos-sdk 2.2.1+119 (191122)
718+
esp8285.menu.sdk.nonosdk_191122.build.sdk=NONOSDK22x_191122
719+
esp8285.menu.sdk.nonosdk_191105=nonos-sdk 2.2.1+113 (191105)
720+
esp8285.menu.sdk.nonosdk_191105.build.sdk=NONOSDK22x_191105
721+
esp8285.menu.sdk.nonosdk_191024=nonos-sdk 2.2.1+111 (191024)
722+
esp8285.menu.sdk.nonosdk_191024.build.sdk=NONOSDK22x_191024
723+
esp8285.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy)
724+
esp8285.menu.sdk.nonosdk221.build.sdk=NONOSDK221
725+
esp8285.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues)
726+
esp8285.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0
715727
esp8285.menu.ip.lm2f=v2 Lower Memory
716728
esp8285.menu.ip.lm2f.build.lwip_include=lwip2/include
717729
esp8285.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat

cores/esp8266/Esp.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ class EspClass {
127127
return esp_get_cpu_freq_mhz();
128128
}
129129
#else
130-
uint8_t getCpuFreqMHz() const
131-
{
132-
return esp_get_cpu_freq_mhz();
133-
}
130+
uint8_t getCpuFreqMHz() const;
134131
#endif
135132

136133
uint32_t getFlashChipId();

cores/esp8266/Stream.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ float Stream::parseFloat(char skipChar) {
173173
boolean isFraction = false;
174174
long value = 0;
175175
int c;
176-
float fraction = 1.0;
176+
float fraction = 1.0f;
177177

178178
c = peekNextDigit();
179179
// ignore non numeric leading characters
@@ -190,7 +190,7 @@ float Stream::parseFloat(char skipChar) {
190190
else if(c >= '0' && c <= '9') { // is c a digit?
191191
value = value * 10 + c - '0';
192192
if(isFraction)
193-
fraction *= 0.1;
193+
fraction *= 0.1f;
194194
}
195195
read(); // consume the character we got with peek
196196
c = timedPeek();

libraries/ArduinoOTA/ArduinoOTA.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ extern "C" {
3131
#endif
3232

3333
ArduinoOTAClass::ArduinoOTAClass()
34-
: _port(0)
35-
, _udp_ota(0)
36-
, _initialized(false)
37-
, _rebootOnSuccess(true)
38-
, _useMDNS(true)
39-
, _state(OTA_IDLE)
40-
, _size(0)
41-
, _cmd(0)
42-
, _ota_port(0)
43-
, _start_callback(NULL)
44-
, _end_callback(NULL)
45-
, _error_callback(NULL)
46-
, _progress_callback(NULL)
4734
{
4835
}
4936

libraries/ArduinoOTA/ArduinoOTA.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,31 @@ class ArduinoOTAClass
6969
int getCommand();
7070

7171
private:
72-
int _port;
72+
void _runUpdate(void);
73+
void _onRx(void);
74+
int parseInt(void);
75+
String readStringUntil(char end);
76+
77+
int _port = 0;
7378
String _password;
7479
String _hostname;
7580
String _nonce;
76-
UdpContext *_udp_ota;
77-
bool _initialized;
78-
bool _rebootOnSuccess;
79-
bool _useMDNS;
80-
ota_state_t _state;
81-
int _size;
82-
int _cmd;
83-
uint16_t _ota_port;
84-
uint16_t _ota_udp_port;
81+
UdpContext *_udp_ota = nullptr;
82+
bool _initialized = false;
83+
bool _rebootOnSuccess = true;
84+
bool _useMDNS = true;
85+
ota_state_t _state = OTA_IDLE;
86+
int _size = 0;
87+
int _cmd = 0;
88+
uint16_t _ota_port = 0;
89+
uint16_t _ota_udp_port = 0;
8590
IPAddress _ota_ip;
8691
String _md5;
8792

88-
THandlerFunction _start_callback;
89-
THandlerFunction _end_callback;
90-
THandlerFunction_Error _error_callback;
91-
THandlerFunction_Progress _progress_callback;
92-
93-
void _runUpdate(void);
94-
void _onRx(void);
95-
int parseInt(void);
96-
String readStringUntil(char end);
93+
THandlerFunction _start_callback = nullptr;
94+
THandlerFunction _end_callback = nullptr;
95+
THandlerFunction_Error _error_callback = nullptr;
96+
THandlerFunction_Progress _progress_callback = nullptr;
9797
};
9898

9999
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ WiFiPhyMode_t ESP8266WiFiGenericClass::getPhyMode() {
369369
*/
370370
void ESP8266WiFiGenericClass::setOutputPower(float dBm) {
371371

372-
if(dBm > 20.5) {
373-
dBm = 20.5;
374-
} else if(dBm < 0) {
375-
dBm = 0;
372+
if(dBm > 20.5f) {
373+
dBm = 20.5f;
374+
} else if(dBm < 0.0f) {
375+
dBm = 0.0f;
376376
}
377377

378378
uint8_t val = (dBm*4.0f);

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ extern "C" uint32_t _FS_start;
3030
extern "C" uint32_t _FS_end;
3131

3232
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
33-
: _httpClientTimeout(8000), _followRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS), _ledPin(-1)
33+
: _httpClientTimeout(8000)
3434
{
3535
}
3636

3737
ESP8266HTTPUpdate::ESP8266HTTPUpdate(int httpClientTimeout)
38-
: _httpClientTimeout(httpClientTimeout), _followRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS), _ledPin(-1)
38+
: _httpClientTimeout(httpClientTimeout)
3939
{
4040
}
4141

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ class ESP8266HTTPUpdate
184184

185185
private:
186186
int _httpClientTimeout;
187-
followRedirects_t _followRedirects;
187+
followRedirects_t _followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
188188

189189
// Callbacks
190190
HTTPUpdateStartCB _cbStart;
191191
HTTPUpdateEndCB _cbEnd;
192192
HTTPUpdateErrorCB _cbError;
193193
HTTPUpdateProgressCB _cbProgress;
194194

195-
int _ledPin;
195+
int _ledPin = -1;
196196
uint8_t _ledOn;
197197
};
198198

tests/ci/eboot_test.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
READELF="$TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-readelf"
4+
5+
set -ev
6+
7+
cd $TRAVIS_BUILD_DIR/tools
8+
python3 get.py -q
9+
10+
cd $TRAVIS_BUILD_DIR/bootloaders/eboot
11+
12+
"$READELF" -x .data -x .text eboot.elf > git.txt
13+
make clean
14+
make
15+
"$READELF" -x .data -x .text eboot.elf > build.txt
16+
diff git.txt build.txt
17+
if [ $? -ne 0 ]; then
18+
echo ERROR: eboot.elf in repo does not match output from compile.
19+
echo ERROR: Need to rebuild and check in updated eboot.
20+
exit 1
21+
fi

tests/host/Makefile

+39-14
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@ LIBRARIES_PATH := ../../libraries
66
FORCE32 ?= 1
77
OPTZ ?= -Os
88
V ?= 0
9+
R ?= noexec
910
DEFSYM_FS ?= -Wl,--defsym,_FS_start=0x40300000 -Wl,--defsym,_FS_end=0x411FA000 -Wl,--defsym,_FS_page=0x100 -Wl,--defsym,_FS_block=0x2000 -Wl,--defsym,_EEPROM_start=0x411fb000
1011

1112
MAKEFILE = $(word 1, $(MAKEFILE_LIST))
1213

14+
CXX = $(shell for i in g++-10 g++-9 g++-8 g++; do which $$i > /dev/null && { echo $$i; break; } done)
15+
CC = $(shell for i in gcc-10 gcc-9 gcc-8 gcc; do which $$i > /dev/null && { echo $$i; break; } done)
16+
GCOV = $(shell for i in gcov-10 gcov-9 gcov-8 gcov; do which $$i > /dev/null && { echo $$i; break; } done)
17+
$(warning using $(CXX))
18+
ifeq ($(CXX),g++)
19+
CXXFLAGS += -std=gnu++11
20+
else
21+
CXXFLAGS += -std=gnu++17
22+
endif
23+
ifeq ($(CC),gcc)
24+
CFLAGS += -std=gnu11
25+
else
26+
CFLAGS += -std=gnu17
27+
endif
28+
1329
# I wasn't able to build with clang when -coverage flag is enabled, forcing GCC on OS X
1430
ifeq ($(shell uname -s),Darwin)
1531
CC ?= gcc
@@ -23,7 +39,7 @@ GENHTML ?= genhtml
2339
ifeq ($(FORCE32),1)
2440
SIZEOFLONG = $(shell echo 'int main(){return sizeof(long);}'|$(CXX) -m32 -x c++ - -o sizeoflong 2>/dev/null && ./sizeoflong; echo $$?; rm -f sizeoflong;)
2541
ifneq ($(SIZEOFLONG),4)
26-
$(warning Cannot compile in 32 bit mode, switching to native mode)
42+
$(warning Cannot compile in 32 bit mode (g++-multilib is missing?), switching to native mode)
2743
else
2844
N32 = 32
2945
M32 = -m32
@@ -160,9 +176,11 @@ FLAGS += -DHOST_MOCK=1
160176
FLAGS += -DNONOSDK221=1
161177
FLAGS += $(MKFLAGS)
162178
FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings
163-
CXXFLAGS += -std=c++11 -fno-rtti $(FLAGS) -funsigned-char
164-
CFLAGS += -std=c99 $(FLAGS) -funsigned-char
179+
FLAGS += $(USERCFLAGS)
180+
CXXFLAGS += -fno-rtti $(FLAGS) -funsigned-char
181+
CFLAGS += $(FLAGS) -funsigned-char
165182
LDFLAGS += -coverage $(OPTZ) -g $(M32)
183+
LDFLAGS += $(USERLDFLAGS)
166184
VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999
167185
CXXFLAGS += -Wno-error=format-security # cores/esp8266/Print.cpp:42:24: error: format not a string literal and no format arguments [-Werror=format-security] -- (os_printf_plus(not_the_best_way))
168186
#CXXFLAGS += -Wno-format-security # cores/esp8266/Print.cpp:42:40: warning: format not a string literal and no format arguments [-Wformat-security] -- (os_printf_plus(not_the_best_way))
@@ -219,13 +237,14 @@ build-info: # show toolchain version
219237
$(CC) -v
220238
@echo "CXX: " $(CXX)
221239
$(CXX) -v
222-
@echo "GCOV: " $(GCOV)
223-
$(GCOV) -v
240+
@echo "CFLAGS: " $(CFLAGS)
241+
@echo "CXXFLAGS: " $(CXXFLAGS)
224242
@echo "----------------------------------"
225243

226244
-include $(BINDIR)/.*.d
227245
.SUFFIXES:
228246

247+
.PRECIOUS: %.c$(E32).o
229248
%.c$(E32).o: %.c
230249
$(VERBC) $(CC) $(PREINCLUDES) $(CFLAGS) $(INC_PATHS) -MD -MF $(BINDIR)/.$(notdir $<).d -c -o $@ $<
231250

@@ -235,7 +254,7 @@ build-info: # show toolchain version
235254

236255
$(BINDIR)/core.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE)
237256
ar -rcu $@ $^
238-
ranlib -c $@
257+
ranlib $@
239258

240259
$(OUTPUT_BINARY): $(CPP_OBJECTS_TESTS) $(BINDIR)/core.a
241260
$(VERBLD) $(CXX) $(DEFSYM_FS) $(LDFLAGS) $^ -o $@
@@ -313,18 +332,19 @@ ssl: # download source and build BearSSL
313332
cd ../../tools/sdk/ssl && make native$(N32)
314333

315334
ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g')
316-
USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/src; do test -d $$dd && { echo -I$$dd; echo "userlib: using directory '$$dd'" 1>&2; } done; done)
317-
USERLIBSRCS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for ss in $$d/*.cpp $$d/src/*.cpp; do test -r $$ss && echo $$ss; done; done)
335+
USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/src $$d/src/libmad; do test -d $$dd && { echo -I$$dd; echo "userlib: using directory '$$dd'" 1>&2; } done; done)
336+
USERLIBSRCS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for ss in $$d/*.cpp $$d/src/*.cpp $$d/src/libmad/*.c; do test -r $$ss && echo $$ss; done; done)
318337
INC_PATHS += $(USERLIBDIRS)
319338
INC_PATHS += -I$(INODIR)/..
320-
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp$(E32).o) $(USERLIBSRCS:.cpp=.cpp$(E32).o)
339+
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp$(E32).o) $(USERLIBSRCS:.cpp=.cpp$(E32).o) $(USERCXXSOURCES:.cpp=.cpp$(E32).o)
340+
C_OBJECTS_CORE_EMU = $(USERCSOURCES:.c=.c$(E32).o)
321341

322-
bin/fullcore.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU)
342+
bin/fullcore$(E32).a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU) $(C_OBJECTS_CORE_EMU)
323343
$(VERBAR) ar -rcu $@ $^
324-
$(VERBAR) ranlib -c $@
344+
$(VERBAR) ranlib $@
325345

326-
%: %.ino.cpp$(E32).o bin/fullcore.a
327-
$(VERBLD) $(CXX) $(LDFLAGS) $< bin/fullcore.a $(LIBSSL) -o $@
346+
%: %.ino.cpp$(E32).o bin/fullcore$(E32).a
347+
$(VERBLD) $(CXX) $(LDFLAGS) $< bin/fullcore$(E32).a $(LIBSSL) -o $@
328348
@echo "----> $@ <----"
329349

330350
#################################################
@@ -333,7 +353,12 @@ ifeq ($(INO),)
333353

334354
%: %.ino
335355
@# recursive 'make' with paths
336-
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Wextra INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@)
356+
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Wextra INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@) \
357+
USERCFLAGS="$(USERCFLAGS)" \
358+
USERCSOURCES="$(USERCSOURCES)" \
359+
USERCXXSOURCES="$(USERCXXSOURCES)" \
360+
USERLDFLAGS="$(USERLDFLAGS)"
361+
test "$(R)" = noexec || $(BINDIR)/$(notdir $@)/$(notdir $@) $(R)
337362
@# see below the new build rule with fixed output path outside from core location
338363

339364
#####################

tests/host/README.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Optional 'V=1' enables makefile verbosity
4545
Optional 'D=1' enables core debug (same as IDE's tools menu)
4646
Optional 'OPTZ=-O2' will update gcc -O option (default is -Os, D=1 implies -O0)
4747
Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gcc-multilib is not detected)
48-
48+
Optional 'R="<options>"' (ex: R="-b -v") runs the executable with given options after build
4949

5050
Non exhaustive list of working examples:
5151
make D=1 ../../libraries/ESP8266WiFi/examples/udp/udp
@@ -64,14 +64,20 @@ Compile other sketches:
6464
or:
6565
ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 make D=1 /path/to/your/sketchdir/sketch/sketch
6666

67-
or (preferred):
67+
or:
6868
export ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2
6969
export D=1
7070
export OPTZ=-O2
7171
make clean
7272
make /path/to/your/sketchdir/sketch/sketch
7373
./bin/sketch/sketch
7474

75+
Additional flags:
76+
make USERCFLAGS="-I some/where -I some/where/else" \
77+
USERCSOURCES="some/where/file1.c some/where/file2.c ..." \
78+
USERCXXSOURCES="some/where/file3.cpp some/where/file4.cpp ..." \
79+
USERLDFLAGS="-L some/where/around" \
80+
...
7581

7682
Executable location is always in bin/. Once a sketch is compiled, just run it:
7783
bin/sketch/sketch

tests/platformio.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function install_platformio()
1414
rm -rf ~/.platformio/packages/toolchain-xtensa
1515
mv $TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf ~/.platformio/packages/toolchain-xtensa
1616
mv .save ~/.platformio/packages/toolchain-xtensa/package.json
17-
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif8266/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif8266']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
17+
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif8266/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif8266']['version'] = '*'; del data['packages']['framework-arduinoespressif8266']['owner'];fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
1818
ln -sf $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
1919
# Install dependencies:
2020
# - esp8266/examples/ConfigFile

tools/boards.txt.py

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@
288288
'flashfreq_40',
289289
'1M', '2M',
290290
'led',
291+
'sdk',
291292
],
292293
'desc': [ 'ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) is a multi-chip package which contains ESP8266 and 1MB flash. All points related to bootstrapping resistors and recommended circuits listed above apply to ESP8285 as well.',
293294
'',

0 commit comments

Comments
 (0)