Skip to content

Commit 652415d

Browse files
authored
Merge branch 'master' into SDFS
2 parents 0a0bbc4 + 9790e1c commit 652415d

36 files changed

+617
-261
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.DS_Store
22
tools/dist/
33
tools/xtensa-lx106-elf/
4-
tools/esptool/
54
tools/mkspiffs/
65
package/versions/
76
exclude.txt

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@
1010
[submodule "libraries/ESP8266SdFat"]
1111
path = libraries/ESP8266SdFat
1212
url = https://github.com/earlephilhower/ESP8266SdFat.git
13+
[submodule "tools/pyserial"]
14+
path = tools/pyserial
15+
url = https://github.com/pyserial/pyserial.git
16+
[submodule "tools/esptool"]
17+
path = tools/esptool
18+
url = https://github.com/espressif/esptool.git

boards.txt

+120-120
Large diffs are not rendered by default.

cores/esp8266/Updater.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ UpdaterClass::UpdaterClass()
3737
, _command(U_FLASH)
3838
, _hash(nullptr)
3939
, _verify(nullptr)
40+
, _progress_callback(nullptr)
4041
{
4142
#if ARDUINO_SIGNING
4243
installSignature(&hash, &sign);
4344
#endif
4445
}
4546

47+
UpdaterClass& UpdaterClass::onProgress(THandlerFunction_Progress fn) {
48+
_progress_callback = fn;
49+
return *this;
50+
}
51+
4652
void UpdaterClass::_reset() {
4753
if (_buffer)
4854
delete[] _buffer;
@@ -440,7 +446,9 @@ size_t UpdaterClass::writeStream(Stream &data) {
440446
_reset();
441447
return 0;
442448
}
443-
449+
if (_progress_callback) {
450+
_progress_callback(0, _size);
451+
}
444452
if(_ledPin != -1) {
445453
pinMode(_ledPin, OUTPUT);
446454
}
@@ -471,8 +479,14 @@ size_t UpdaterClass::writeStream(Stream &data) {
471479
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())
472480
return written;
473481
written += toRead;
482+
if(_progress_callback) {
483+
_progress_callback(progress(), _size);
484+
}
474485
yield();
475486
}
487+
if(_progress_callback) {
488+
_progress_callback(progress(), _size);
489+
}
476490
return written;
477491
}
478492

cores/esp8266/Updater.h

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Arduino.h>
55
#include <flash_utils.h>
66
#include <MD5Builder.h>
7+
#include <functional>
78

89
#define UPDATE_ERROR_OK (0)
910
#define UPDATE_ERROR_WRITE (1)
@@ -48,6 +49,8 @@ class UpdaterVerifyClass {
4849

4950
class UpdaterClass {
5051
public:
52+
typedef std::function<void(size_t, size_t)> THandlerFunction_Progress;
53+
5154
UpdaterClass();
5255

5356
/* Optionally add a cryptographic signature verification hash and method */
@@ -111,6 +114,11 @@ class UpdaterClass {
111114
*/
112115
void md5(uint8_t * result){ return _md5.getBytes(result); }
113116

117+
/*
118+
This callback will be called when Updater is receiving data
119+
*/
120+
UpdaterClass& onProgress(THandlerFunction_Progress fn);
121+
114122
//Helpers
115123
uint8_t getError(){ return _error; }
116124
void clearError(){ _error = UPDATE_ERROR_OK; }
@@ -191,6 +199,8 @@ class UpdaterClass {
191199
// Optional signed binary verification
192200
UpdaterHashClass *_hash;
193201
UpdaterVerifyClass *_verify;
202+
// Optional progress callback function
203+
THandlerFunction_Progress _progress_callback;
194204
};
195205

196206
extern UpdaterClass Update;

libraries/ArduinoOTA/ArduinoOTA.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ extern "C" {
1919
#include "lwip/igmp.h"
2020
#include "lwip/mem.h"
2121
#include "include/UdpContext.h"
22-
#include <ESP8266mDNS.h>
2322

23+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
24+
#include <ESP8266mDNS.h>
25+
#endif
2426

2527
#ifdef DEBUG_ESP_OTA
2628
#ifdef DEBUG_ESP_PORT
@@ -130,7 +132,8 @@ void ArduinoOTAClass::begin(bool useMDNS) {
130132
if(!_udp_ota->listen(IP_ADDR_ANY, _port))
131133
return;
132134
_udp_ota->onRx(std::bind(&ArduinoOTAClass::_onRx, this));
133-
135+
136+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
134137
if(_useMDNS) {
135138
MDNS.begin(_hostname.c_str());
136139

@@ -140,6 +143,7 @@ void ArduinoOTAClass::begin(bool useMDNS) {
140143
MDNS.enableArduino(_port);
141144
}
142145
}
146+
#endif
143147
_initialized = true;
144148
_state = OTA_IDLE;
145149
#ifdef OTA_DEBUG
@@ -361,8 +365,10 @@ void ArduinoOTAClass::handle() {
361365
_state = OTA_IDLE;
362366
}
363367

368+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
364369
if(_useMDNS)
365370
MDNS.update(); //handle MDNS update as well, given that ArduinoOTA relies on it anyways
371+
#endif
366372
}
367373

368374
int ArduinoOTAClass::getCommand() {

libraries/ESP8266WiFi/src/include/UdpContext.h

+23-3
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,40 @@ class UdpContext
9090
}
9191
}
9292

93-
bool connect(const ip_addr_t* addr, uint16_t port)
93+
#if LWIP_VERSION_MAJOR == 1
94+
95+
bool connect(IPAddress addr, uint16_t port)
9496
{
95-
_pcb->remote_ip = *addr;
97+
_pcb->remote_ip = addr;
9698
_pcb->remote_port = port;
9799
return true;
98100
}
99101

100-
bool listen(CONST ip_addr_t* addr, uint16_t port)
102+
bool listen(IPAddress addr, uint16_t port)
101103
{
102104
udp_recv(_pcb, &_s_recv, (void *) this);
103105
err_t err = udp_bind(_pcb, addr, port);
104106
return err == ERR_OK;
105107
}
106108

109+
#else // lwIP-v2
110+
111+
bool connect(const IPAddress& addr, uint16_t port)
112+
{
113+
_pcb->remote_ip = addr;
114+
_pcb->remote_port = port;
115+
return true;
116+
}
117+
118+
bool listen(const IPAddress& addr, uint16_t port)
119+
{
120+
udp_recv(_pcb, &_s_recv, (void *) this);
121+
err_t err = udp_bind(_pcb, addr, port);
122+
return err == ERR_OK;
123+
}
124+
125+
#endif // lwIP-v2
126+
107127
void disconnect()
108128
{
109129
udp_disconnect(_pcb);

package/build_boards_manager_package.sh

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ $SED 's/runtime.tools.esptool.path={runtime.platform.path}\/tools\/esptool//g' |
7878
$SED 's/tools.esptool.path={runtime.platform.path}\/tools\/esptool/tools.esptool.path=\{runtime.tools.esptool.path\}/g' | \
7979
$SED 's/tools.mkspiffs.path={runtime.platform.path}\/tools\/mkspiffs/tools.mkspiffs.path=\{runtime.tools.mkspiffs.path\}/g' |\
8080
$SED 's/recipe.hooks.core.prebuild.2.pattern.*//g' |\
81-
$SED 's/recipe.hooks.core.prebuild.3.pattern.*//g' |\
8281
$SED "s/version=.*/version=$ver/g" |\
8382
$SED -E "s/name=([a-zA-Z0-9\ -]+).*/name=\1($ver)/g"\
8483
> $outdir/platform.txt

package/package_esp8266com_index.template.json

+19-54
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"packages": [
33
{
4+
"name": "esp8266",
45
"maintainer": "ESP8266 Community",
6+
"websiteURL": "https://github.com/esp8266/Arduino",
7+
"email": "[email protected]",
58
"help": {
69
"online": "http://esp8266.com/arduino"
710
},
8-
"websiteURL": "https://github.com/esp8266/Arduino",
911
"platforms": [
1012
{
1113
"category": "ESP8266",
@@ -110,17 +112,17 @@
110112
{
111113
"packager": "esp8266",
112114
"version": "2.5.0-3-20ed2b9",
113-
"name": "esptool"
115+
"name": "xtensa-lx106-elf-gcc"
114116
},
115117
{
116118
"packager": "esp8266",
117119
"version": "2.5.0-3-20ed2b9",
118-
"name": "xtensa-lx106-elf-gcc"
120+
"name": "mkspiffs"
119121
},
120122
{
121123
"packager": "esp8266",
122-
"version": "2.5.0-3-20ed2b9",
123-
"name": "mkspiffs"
124+
"version": "3.7.2-post1",
125+
"name": "python"
124126
}
125127
],
126128
"help": {
@@ -130,57 +132,22 @@
130132
],
131133
"tools": [
132134
{
133-
"version": "2.5.0-3-20ed2b9",
134-
"name": "esptool",
135+
"version": "3.7.2-post1",
136+
"name": "python",
135137
"systems": [
136138
{
137-
"host": "aarch64-linux-gnu",
138-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/aarch64-linux-gnu.esptool-f80ae31.tar.gz",
139-
"archiveFileName": "aarch64-linux-gnu.esptool-f80ae31.tar.gz",
140-
"checksum": "SHA-256:888425ff1e33a97ea155b6f128de6b578c34468895ba9b4acd1e4f28608d917a",
141-
"size": "14681"
142-
},
143-
{
144-
"host": "arm-linux-gnueabihf",
145-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/arm-linux-gnueabihf.esptool-f80ae31.tar.gz",
146-
"archiveFileName": "arm-linux-gnueabihf.esptool-f80ae31.tar.gz",
147-
"checksum": "SHA-256:71c878ac6a21ee69dcd615cd28f2dccd29a87079e0b3069eba625089d89e5058",
148-
"size": "13873"
139+
"host": "x86_64-mingw32",
140+
"url": "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-win32.zip",
141+
"archiveFileName": "python-3.7.2.post1-embed-win32.zip",
142+
"checksum": "SHA-256:ceb06a5244e93e7e7523e26e1354447b79a9e6fd8c45891d81df9c7da1e02d05",
143+
"size": "6533256"
149144
},
150145
{
151146
"host": "i686-mingw32",
152-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/i686-w64-mingw32.esptool-f80ae31.zip",
153-
"archiveFileName": "i686-w64-mingw32.esptool-f80ae31.zip",
154-
"checksum": "SHA-256:e30f25a19a78635000401b083b479e111d591bac20cfd89b1bfdf36a60e9ee20",
155-
"size": "16466"
156-
},
157-
{
158-
"host": "i686-pc-linux-gnu",
159-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/i686-linux-gnu.esptool-f80ae31.tar.gz",
160-
"archiveFileName": "i686-linux-gnu.esptool-f80ae31.tar.gz",
161-
"checksum": "SHA-256:fe632f4602d02b6a9425c5bf95074095cb6d3c57912168a0f6b796fddd8ce991",
162-
"size": "16543"
163-
},
164-
{
165-
"host": "x86_64-apple-darwin",
166-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/x86_64-apple-darwin14.esptool-f80ae31.tar.gz",
167-
"archiveFileName": "x86_64-apple-darwin14.esptool-f80ae31.tar.gz",
168-
"checksum": "SHA-256:0f51e487706a476b0b87299a769282ad65623774770655168a79d1748d2506e7",
169-
"size": "15003"
170-
},
171-
{
172-
"host": "x86_64-pc-linux-gnu",
173-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/x86_64-linux-gnu.esptool-f80ae31.tar.gz",
174-
"archiveFileName": "x86_64-linux-gnu.esptool-f80ae31.tar.gz",
175-
"checksum": "SHA-256:bded1dca953377838b6086a9bcd40a1dc5286ba5f69f2372c22a1d1819baad24",
176-
"size": "16526"
177-
},
178-
{
179-
"host": "x86_64-mingw32",
180-
"url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/2.5.0-3/x86_64-w64-mingw32.esptool-f80ae31.zip",
181-
"archiveFileName": "x86_64-w64-mingw32.esptool-f80ae31.zip",
182-
"checksum": "SHA-256:d6d5976fde82d07e93d5a01f38bbb4f84a7796187ff0541ee62650041791d0e8",
183-
"size": "19724"
147+
"url": "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-win32.zip",
148+
"archiveFileName": "python-3.7.2.post1-embed-win32.zip",
149+
"checksum": "SHA-256:ceb06a5244e93e7e7523e26e1354447b79a9e6fd8c45891d81df9c7da1e02d05",
150+
"size": "6533256"
184151
}
185152
]
186153
},
@@ -294,9 +261,7 @@
294261
}
295262
]
296263
}
297-
],
298-
"email": "[email protected]",
299-
"name": "esp8266"
264+
]
300265
}
301266
]
302267
}

platform.txt

+22-22
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ version=2.6.0-dev
1111
runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf
1212
runtime.tools.esptool.path={runtime.platform.path}/tools/esptool
1313
runtime.tools.signing={runtime.platform.path}/tools/signing.py
14+
runtime.tools.elf2bin={runtime.platform.path}/tools/elf2bin.py
15+
runtime.tools.makecorever={runtime.platform.path}/tools/makecorever.py
16+
runtime.tools.eboot={runtime.platform.path}/bootloaders/eboot/eboot.elf
17+
runtime.tools.python=python
18+
runtime.tools.python.windows={runtime.platform.path}/tools/python/python.exe
1419

1520
compiler.warning_flags=-w
1621
compiler.warning_flags.none=-w
@@ -76,14 +81,8 @@ compiler.elf2hex.extra_flags=
7681

7782
## generate file with git version number
7883
## needs bash, git, and echo
79-
recipe.hooks.core.prebuild.1.pattern=python "{runtime.tools.signing}" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
80-
recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h"
81-
recipe.hooks.core.prebuild.3.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd "{runtime.platform.path}"; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h"
82-
83-
## windows-compatible version without git
84-
recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c rem cannot sign on windows
85-
recipe.hooks.core.prebuild.2.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h
86-
recipe.hooks.core.prebuild.3.pattern.windows=cmd.exe /c if exist {build.source.path}\public.key echo #error Cannot automatically build signed binaries on Windows > {build.path}\core\Updater_Signing.h
84+
recipe.hooks.core.prebuild.1.pattern="{runtime.tools.python}" "{runtime.tools.signing}" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
85+
recipe.hooks.core.prebuild.2.pattern="{runtime.tools.python}" "{runtime.tools.makecorever}" --build_path "{build.path}' --platform_path "{runtime.platform.path}" --version "unix-{version}"
8786

8887
## Build the app.ld linker file
8988
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"
@@ -107,14 +106,8 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {build.exception_
107106
recipe.objcopy.eep.pattern=
108107

109108
## Create hex
110-
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
111-
112-
recipe.objcopy.hex.1.pattern="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
113-
recipe.objcopy.hex.2.pattern=python "{runtime.tools.signing}" --mode sign --privatekey "{build.source.path}/private.key" --bin "{build.path}/{build.project_name}.bin" --out "{build.path}/{build.project_name}.bin.signed"
114-
115-
# No signing on Windows
116-
recipe.objcopy.hex.1.pattern.windows="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
117-
recipe.objcopy.hex.2.pattern.windows=
109+
recipe.objcopy.hex.1.pattern="{runtime.tools.python}" "{runtime.tools.elf2bin}" --eboot "{runtime.tools.eboot}" --app "{build.path}/{build.project_name}.elf" --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size {build.flash_size} --path "{runtime.tools.xtensa-lx106-elf-gcc.path}/bin" --out "{build.path}/{build.project_name}.bin"
110+
recipe.objcopy.hex.2.pattern="{runtime.tools.python}" "{runtime.tools.signing}" --mode sign --privatekey "{build.source.path}/private.key" --bin "{build.path}/{build.project_name}.bin" --out "{build.path}/{build.project_name}.bin.signed"
118111

119112
## Save hex
120113
recipe.output.tmp_file={build.project_name}.bin
@@ -128,16 +121,23 @@ recipe.size.regex.data=^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*
128121

129122
# ------------------------------
130123

131-
tools.esptool.cmd=esptool
132-
tools.esptool.cmd.windows=esptool.exe
133-
tools.esptool.path={runtime.platform.path}/tools/esptool
124+
# Need to duplicate the python path because Arduino does not replace properly in this stage
125+
tools.esptool.cmd=python
126+
tools.esptool.cmd.windows={runtime.platform.path}/tools/python/python.exe
127+
tools.esptool.path=
134128
tools.esptool.network_cmd=python
135-
tools.esptool.network_cmd.windows=python.exe
129+
tools.esptool.network_cmd.windows={runtime.platform.path}/tools/python/python.exe
136130

137131
tools.esptool.upload.protocol=esp
138-
tools.esptool.upload.params.verbose=-vv
132+
tools.esptool.upload.params.verbose=--trace
139133
tools.esptool.upload.params.quiet=
140-
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" {upload.erase_cmd} -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"
134+
135+
# First, potentially perform an erase or nothing
136+
# Next, do the binary upload
137+
# Combined in one rule because Arduino doesn't suport upload.1.pattern/upload.3.pattern
138+
tools.esptool.upload.pattern="{cmd}" "{runtime.platform.path}/tools/upload.py" "{runtime.platform.path}/tools/pyserial" "{runtime.platform.path}/tools/esptool/esptool.py" --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" {upload.erase_cmd} --end --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" write_flash 0x0 "{build.path}/{build.project_name}.bin" --end
139+
140+
141141
tools.esptool.upload.network_pattern="{network_cmd}" "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
142142

143143
tools.mkspiffs.cmd=mkspiffs

0 commit comments

Comments
 (0)