Skip to content

Commit

Permalink
Merge branch 'master' into stdnothrow
Browse files Browse the repository at this point in the history
  • Loading branch information
earlephilhower authored Aug 30, 2020
2 parents 3ee6710 + b9db944 commit 247d5f1
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,16 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Cache Linux toolchain
id: cache-linux
uses: actions/cache@v2
with:
path: ./tools/dist
key: key-linux-toolchain
- name: Boards.txt diff
env:
TRAVIS_BUILD_DIR: ${{ github.workspace }}
TRAVIS_TAG: ${{ github.ref }}
run: |
bash ./tests/ci/build_boards.sh
bash ./tests/ci/eboot_test.sh
12 changes: 12 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,18 @@ esp8285.menu.led.15=15
esp8285.menu.led.15.build.led=-DLED_BUILTIN=15
esp8285.menu.led.16=16
esp8285.menu.led.16.build.led=-DLED_BUILTIN=16
esp8285.menu.sdk.nonosdk_190703=nonos-sdk 2.2.1+100 (190703)
esp8285.menu.sdk.nonosdk_190703.build.sdk=NONOSDK22x_190703
esp8285.menu.sdk.nonosdk_191122=nonos-sdk 2.2.1+119 (191122)
esp8285.menu.sdk.nonosdk_191122.build.sdk=NONOSDK22x_191122
esp8285.menu.sdk.nonosdk_191105=nonos-sdk 2.2.1+113 (191105)
esp8285.menu.sdk.nonosdk_191105.build.sdk=NONOSDK22x_191105
esp8285.menu.sdk.nonosdk_191024=nonos-sdk 2.2.1+111 (191024)
esp8285.menu.sdk.nonosdk_191024.build.sdk=NONOSDK22x_191024
esp8285.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy)
esp8285.menu.sdk.nonosdk221.build.sdk=NONOSDK221
esp8285.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues)
esp8285.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0
esp8285.menu.ip.lm2f=v2 Lower Memory
esp8285.menu.ip.lm2f.build.lwip_include=lwip2/include
esp8285.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat
Expand Down
5 changes: 1 addition & 4 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ class EspClass {
return esp_get_cpu_freq_mhz();
}
#else
uint8_t getCpuFreqMHz() const
{
return esp_get_cpu_freq_mhz();
}
uint8_t getCpuFreqMHz() const;
#endif

uint32_t getFlashChipId();
Expand Down
4 changes: 2 additions & 2 deletions cores/esp8266/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ float Stream::parseFloat(char skipChar) {
boolean isFraction = false;
long value = 0;
int c;
float fraction = 1.0;
float fraction = 1.0f;

c = peekNextDigit();
// ignore non numeric leading characters
Expand All @@ -190,7 +190,7 @@ float Stream::parseFloat(char skipChar) {
else if(c >= '0' && c <= '9') { // is c a digit?
value = value * 10 + c - '0';
if(isFraction)
fraction *= 0.1;
fraction *= 0.1f;
}
read(); // consume the character we got with peek
c = timedPeek();
Expand Down
13 changes: 0 additions & 13 deletions libraries/ArduinoOTA/ArduinoOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ extern "C" {
#endif

ArduinoOTAClass::ArduinoOTAClass()
: _port(0)
, _udp_ota(0)
, _initialized(false)
, _rebootOnSuccess(true)
, _useMDNS(true)
, _state(OTA_IDLE)
, _size(0)
, _cmd(0)
, _ota_port(0)
, _start_callback(NULL)
, _end_callback(NULL)
, _error_callback(NULL)
, _progress_callback(NULL)
{
}

Expand Down
38 changes: 19 additions & 19 deletions libraries/ArduinoOTA/ArduinoOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,31 @@ class ArduinoOTAClass
int getCommand();

private:
int _port;
void _runUpdate(void);
void _onRx(void);
int parseInt(void);
String readStringUntil(char end);

int _port = 0;
String _password;
String _hostname;
String _nonce;
UdpContext *_udp_ota;
bool _initialized;
bool _rebootOnSuccess;
bool _useMDNS;
ota_state_t _state;
int _size;
int _cmd;
uint16_t _ota_port;
uint16_t _ota_udp_port;
UdpContext *_udp_ota = nullptr;
bool _initialized = false;
bool _rebootOnSuccess = true;
bool _useMDNS = true;
ota_state_t _state = OTA_IDLE;
int _size = 0;
int _cmd = 0;
uint16_t _ota_port = 0;
uint16_t _ota_udp_port = 0;
IPAddress _ota_ip;
String _md5;

THandlerFunction _start_callback;
THandlerFunction _end_callback;
THandlerFunction_Error _error_callback;
THandlerFunction_Progress _progress_callback;

void _runUpdate(void);
void _onRx(void);
int parseInt(void);
String readStringUntil(char end);
THandlerFunction _start_callback = nullptr;
THandlerFunction _end_callback = nullptr;
THandlerFunction_Error _error_callback = nullptr;
THandlerFunction_Progress _progress_callback = nullptr;
};

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
Expand Down
8 changes: 4 additions & 4 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ WiFiPhyMode_t ESP8266WiFiGenericClass::getPhyMode() {
*/
void ESP8266WiFiGenericClass::setOutputPower(float dBm) {

if(dBm > 20.5) {
dBm = 20.5;
} else if(dBm < 0) {
dBm = 0;
if(dBm > 20.5f) {
dBm = 20.5f;
} else if(dBm < 0.0f) {
dBm = 0.0f;
}

uint8_t val = (dBm*4.0f);
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ extern "C" uint32_t _FS_start;
extern "C" uint32_t _FS_end;

ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
: _httpClientTimeout(8000), _followRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS), _ledPin(-1)
: _httpClientTimeout(8000)
{
}

ESP8266HTTPUpdate::ESP8266HTTPUpdate(int httpClientTimeout)
: _httpClientTimeout(httpClientTimeout), _followRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS), _ledPin(-1)
: _httpClientTimeout(httpClientTimeout)
{
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ class ESP8266HTTPUpdate

private:
int _httpClientTimeout;
followRedirects_t _followRedirects;
followRedirects_t _followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;

// Callbacks
HTTPUpdateStartCB _cbStart;
HTTPUpdateEndCB _cbEnd;
HTTPUpdateErrorCB _cbError;
HTTPUpdateProgressCB _cbProgress;

int _ledPin;
int _ledPin = -1;
uint8_t _ledOn;
};

Expand Down
21 changes: 21 additions & 0 deletions tests/ci/eboot_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

READELF="$TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-readelf"

set -ev

cd $TRAVIS_BUILD_DIR/tools
python3 get.py -q

cd $TRAVIS_BUILD_DIR/bootloaders/eboot

"$READELF" -x .data -x .text eboot.elf > git.txt
make clean
make
"$READELF" -x .data -x .text eboot.elf > build.txt
diff git.txt build.txt
if [ $? -ne 0 ]; then
echo ERROR: eboot.elf in repo does not match output from compile.
echo ERROR: Need to rebuild and check in updated eboot.
exit 1
fi
53 changes: 39 additions & 14 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,26 @@ LIBRARIES_PATH := ../../libraries
FORCE32 ?= 1
OPTZ ?= -Os
V ?= 0
R ?= noexec
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

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

CXX = $(shell for i in g++-10 g++-9 g++-8 g++; do which $$i > /dev/null && { echo $$i; break; } done)
CC = $(shell for i in gcc-10 gcc-9 gcc-8 gcc; do which $$i > /dev/null && { echo $$i; break; } done)
GCOV = $(shell for i in gcov-10 gcov-9 gcov-8 gcov; do which $$i > /dev/null && { echo $$i; break; } done)
$(warning using $(CXX))
ifeq ($(CXX),g++)
CXXFLAGS += -std=gnu++11
else
CXXFLAGS += -std=gnu++17
endif
ifeq ($(CC),gcc)
CFLAGS += -std=gnu11
else
CFLAGS += -std=gnu17
endif

# I wasn't able to build with clang when -coverage flag is enabled, forcing GCC on OS X
ifeq ($(shell uname -s),Darwin)
CC ?= gcc
Expand All @@ -23,7 +39,7 @@ GENHTML ?= genhtml
ifeq ($(FORCE32),1)
SIZEOFLONG = $(shell echo 'int main(){return sizeof(long);}'|$(CXX) -m32 -x c++ - -o sizeoflong 2>/dev/null && ./sizeoflong; echo $$?; rm -f sizeoflong;)
ifneq ($(SIZEOFLONG),4)
$(warning Cannot compile in 32 bit mode, switching to native mode)
$(warning Cannot compile in 32 bit mode (g++-multilib is missing?), switching to native mode)
else
N32 = 32
M32 = -m32
Expand Down Expand Up @@ -160,9 +176,11 @@ FLAGS += -DHOST_MOCK=1
FLAGS += -DNONOSDK221=1
FLAGS += $(MKFLAGS)
FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings
CXXFLAGS += -std=c++11 -fno-rtti $(FLAGS) -funsigned-char
CFLAGS += -std=c99 $(FLAGS) -funsigned-char
FLAGS += $(USERCFLAGS)
CXXFLAGS += -fno-rtti $(FLAGS) -funsigned-char
CFLAGS += $(FLAGS) -funsigned-char
LDFLAGS += -coverage $(OPTZ) -g $(M32)
LDFLAGS += $(USERLDFLAGS)
VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999
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))
#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))
Expand Down Expand Up @@ -219,13 +237,14 @@ build-info: # show toolchain version
$(CC) -v
@echo "CXX: " $(CXX)
$(CXX) -v
@echo "GCOV: " $(GCOV)
$(GCOV) -v
@echo "CFLAGS: " $(CFLAGS)
@echo "CXXFLAGS: " $(CXXFLAGS)
@echo "----------------------------------"

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

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

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

$(BINDIR)/core.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE)
ar -rcu $@ $^
ranlib -c $@
ranlib $@

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

ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g')
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)
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)
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)
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)
INC_PATHS += $(USERLIBDIRS)
INC_PATHS += -I$(INODIR)/..
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp$(E32).o) $(USERLIBSRCS:.cpp=.cpp$(E32).o)
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp$(E32).o) $(USERLIBSRCS:.cpp=.cpp$(E32).o) $(USERCXXSOURCES:.cpp=.cpp$(E32).o)
C_OBJECTS_CORE_EMU = $(USERCSOURCES:.c=.c$(E32).o)

bin/fullcore.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU)
bin/fullcore$(E32).a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU) $(C_OBJECTS_CORE_EMU)
$(VERBAR) ar -rcu $@ $^
$(VERBAR) ranlib -c $@
$(VERBAR) ranlib $@

%: %.ino.cpp$(E32).o bin/fullcore.a
$(VERBLD) $(CXX) $(LDFLAGS) $< bin/fullcore.a $(LIBSSL) -o $@
%: %.ino.cpp$(E32).o bin/fullcore$(E32).a
$(VERBLD) $(CXX) $(LDFLAGS) $< bin/fullcore$(E32).a $(LIBSSL) -o $@
@echo "----> $@ <----"

#################################################
Expand All @@ -333,7 +353,12 @@ ifeq ($(INO),)

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

#####################
Expand Down
10 changes: 8 additions & 2 deletions tests/host/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Optional 'V=1' enables makefile verbosity
Optional 'D=1' enables core debug (same as IDE's tools menu)
Optional 'OPTZ=-O2' will update gcc -O option (default is -Os, D=1 implies -O0)
Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gcc-multilib is not detected)

Optional 'R="<options>"' (ex: R="-b -v") runs the executable with given options after build

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

or (preferred):
or:
export ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2
export D=1
export OPTZ=-O2
make clean
make /path/to/your/sketchdir/sketch/sketch
./bin/sketch/sketch

Additional flags:
make USERCFLAGS="-I some/where -I some/where/else" \
USERCSOURCES="some/where/file1.c some/where/file2.c ..." \
USERCXXSOURCES="some/where/file3.cpp some/where/file4.cpp ..." \
USERLDFLAGS="-L some/where/around" \
...

Executable location is always in bin/. Once a sketch is compiled, just run it:
bin/sketch/sketch
Expand Down
2 changes: 1 addition & 1 deletion tests/platformio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function install_platformio()
rm -rf ~/.platformio/packages/toolchain-xtensa
mv $TRAVIS_BUILD_DIR/tools/xtensa-lx106-elf ~/.platformio/packages/toolchain-xtensa
mv .save ~/.platformio/packages/toolchain-xtensa/package.json
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()"
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()"
ln -sf $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
# Install dependencies:
# - esp8266/examples/ConfigFile
Expand Down
1 change: 1 addition & 0 deletions tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
'flashfreq_40',
'1M', '2M',
'led',
'sdk',
],
'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.',
'',
Expand Down

0 comments on commit 247d5f1

Please sign in to comment.