Skip to content

Commit d84e323

Browse files
authored
Merge branch 'master' into LEAmDNS2x
2 parents 15861ca + 32470fb commit d84e323

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2246
-689
lines changed

.github/workflows/pull-request.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ jobs:
154154
mod: 42 # Picked at random to give 4-5 builds and exit.
155155
rem: 13
156156
run: |
157-
sudo apt-get install python3-pip python3-setuptools
157+
sudo apt update
158+
sudo apt install python3-pip python3-setuptools
158159
PATH=/home/runner/.local/bin:$PATH bash ./tests/platformio.sh
159160
160161
@@ -174,7 +175,8 @@ jobs:
174175
TRAVIS_BUILD_DIR: ${{ github.workspace }}
175176
TRAVIS_TAG: ${{ github.ref }}
176177
run: |
177-
sudo apt-get install valgrind lcov
178+
sudo apt update
179+
sudo apt install valgrind lcov
178180
bash ./tests/ci/host_test.sh
179181
180182
@@ -194,7 +196,8 @@ jobs:
194196
TRAVIS_BUILD_DIR: ${{ github.workspace }}
195197
TRAVIS_TAG: ${{ github.ref }}
196198
run: |
197-
sudo apt-get install python3-pip python3-setuptools
199+
sudo apt update
200+
sudo apt install python3-pip python3-setuptools
198201
# GitHub CI installs pip3 and setuptools outside the path.
199202
# Update the path to include them and run.
200203
PATH=/home/runner/.local/bin:$PATH pip3 install --user -r doc/requirements.txt
@@ -217,7 +220,8 @@ jobs:
217220
TRAVIS_BUILD_DIR: ${{ github.workspace }}
218221
TRAVIS_TAG: ${{ github.ref }}
219222
run: |
220-
sudo apt-get install astyle
223+
sudo apt update
224+
sudo apt install astyle
221225
bash ./tests/ci/style_check.sh
222226
223227
@@ -251,9 +255,16 @@ jobs:
251255
- uses: actions/setup-python@v2
252256
with:
253257
python-version: '3.x'
258+
- name: Cache Linux toolchain
259+
id: cache-linux
260+
uses: actions/cache@v2
261+
with:
262+
path: ./tools/dist
263+
key: key-linux-toolchain
254264
- name: Boards.txt diff
255265
env:
256266
TRAVIS_BUILD_DIR: ${{ github.workspace }}
257267
TRAVIS_TAG: ${{ github.ref }}
258268
run: |
259269
bash ./tests/ci/build_boards.sh
270+
bash ./tests/ci/eboot_test.sh

boards.txt

Lines changed: 80 additions & 170 deletions
Large diffs are not rendered by default.

bootloaders/eboot/eboot.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ int copy_raw(const uint32_t src_addr,
159159
gzip = true;
160160
}
161161
while (left > 0) {
162-
if (!verify) {
163-
if (SPIEraseSector(daddr/buffer_size)) {
164-
return 2;
165-
}
166-
}
167162
if (!gzip) {
168163
if (SPIRead(saddr, buffer, buffer_size)) {
169164
return 3;
@@ -190,8 +185,25 @@ int copy_raw(const uint32_t src_addr,
190185
return 9;
191186
}
192187
} else {
193-
if (SPIWrite(daddr, buffer, buffer_size)) {
194-
return 4;
188+
// Special treatment for address 0 (bootloader). Only erase and
189+
// rewrite if the data is different (i.e. very rarely).
190+
bool skip = false;
191+
if (daddr == 0) {
192+
if (SPIRead(daddr, buffer2, buffer_size)) {
193+
return 4;
194+
}
195+
if (!memcmp(buffer2, buffer, buffer_size)) {
196+
ets_putc('B'); // Note we skipped the bootloader in output
197+
skip = true; // And skip erase/write
198+
}
199+
}
200+
if (!skip) {
201+
if (SPIEraseSector(daddr/buffer_size)) {
202+
return 2;
203+
}
204+
if (SPIWrite(daddr, buffer, buffer_size)) {
205+
return 4;
206+
}
195207
}
196208
}
197209
saddr += buffer_size;

bootloaders/eboot/eboot.elf

432 Bytes
Binary file not shown.

cores/esp8266/Esp.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,6 @@ uint8_t EspClass::getBootMode(void)
264264
return system_get_boot_mode();
265265
}
266266

267-
#ifndef F_CPU
268-
uint8_t EspClass::getCpuFreqMHz(void)
269-
{
270-
return system_get_cpu_freq();
271-
}
272-
#endif
273-
274267
uint32_t EspClass::getFlashChipId(void)
275268
{
276269
static uint32_t flash_chip_id = 0;
@@ -740,17 +733,17 @@ String EspClass::getSketchMD5()
740733
}
741734
uint32_t lengthLeft = getSketchSize();
742735
const size_t bufSize = 512;
743-
std::unique_ptr<uint8_t[]> buf(new uint8_t[bufSize]);
736+
std::unique_ptr<uint8_t[]> buf(new (std::nothrow) uint8_t[bufSize]);
744737
uint32_t offset = 0;
745738
if(!buf.get()) {
746-
return String();
739+
return emptyString;
747740
}
748741
MD5Builder md5;
749742
md5.begin();
750743
while( lengthLeft > 0) {
751744
size_t readBytes = (lengthLeft < bufSize) ? lengthLeft : bufSize;
752745
if (!flashRead(offset, reinterpret_cast<uint32_t*>(buf.get()), (readBytes + 3) & ~3)) {
753-
return String();
746+
return emptyString;
754747
}
755748
md5.add(buf.get(), readBytes);
756749
lengthLeft -= readBytes;

cores/esp8266/Esp.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,12 @@ class EspClass {
122122
uint8_t getBootMode();
123123

124124
#if defined(F_CPU) || defined(CORE_MOCK)
125-
constexpr uint8_t getCpuFreqMHz() const
126-
{
127-
return esp_get_cpu_freq_mhz();
128-
}
129-
#else
130-
uint8_t getCpuFreqMHz() const
125+
constexpr
126+
#endif
127+
inline uint8_t getCpuFreqMHz() const __attribute__((always_inline))
131128
{
132129
return esp_get_cpu_freq_mhz();
133130
}
134-
#endif
135131

136132
uint32_t getFlashChipId();
137133
uint8_t getFlashChipVendorId();
@@ -170,21 +166,15 @@ class EspClass {
170166
uint8_t *random(uint8_t *resultArray, const size_t outputSizeBytes) const;
171167
uint32_t random() const;
172168

173-
#ifndef CORE_MOCK
174-
inline uint32_t getCycleCount() __attribute__((always_inline));
169+
#if !defined(CORE_MOCK)
170+
inline uint32_t getCycleCount() __attribute__((always_inline))
171+
{
172+
return esp_get_cycle_count();
173+
}
175174
#else
176175
uint32_t getCycleCount();
177-
#endif
178-
};
179-
180-
#ifndef CORE_MOCK
181-
182-
uint32_t EspClass::getCycleCount()
183-
{
184-
return esp_get_cycle_count();
185-
}
186-
187176
#endif // !defined(CORE_MOCK)
177+
};
188178

189179
extern EspClass ESP;
190180

cores/esp8266/IPAddress.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ IPAddress::IPAddress() {
3232
}
3333

3434
bool IPAddress::isSet () const {
35-
return !ip_addr_isany(&_ip);
35+
return !ip_addr_isany(&_ip) && ((*this) != IPADDR_NONE);
3636
}
3737

3838
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) {
@@ -183,6 +183,10 @@ bool IPAddress::isValid(const char* arg) {
183183
const IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
184184
const IPAddress INADDR_NONE(255,255,255,255);
185185

186+
void IPAddress::clear() {
187+
(*this) = INADDR_ANY;
188+
}
189+
186190
/**************************************/
187191

188192
#if LWIP_IPV6

cores/esp8266/IPAddress.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class IPAddress: public Printable {
132132
virtual size_t printTo(Print& p) const;
133133
String toString() const;
134134

135+
void clear();
136+
135137
/*
136138
check if input string(arg) is a valid IPV4 address or not.
137139
return true on valid.

cores/esp8266/Print.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ size_t Print::printf(const char *format, ...) {
6363
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
6464
va_end(arg);
6565
if (len > sizeof(temp) - 1) {
66-
buffer = new char[len + 1];
66+
buffer = new (std::nothrow) char[len + 1];
6767
if (!buffer) {
6868
return 0;
6969
}
@@ -86,7 +86,7 @@ size_t Print::printf_P(PGM_P format, ...) {
8686
size_t len = vsnprintf_P(temp, sizeof(temp), format, arg);
8787
va_end(arg);
8888
if (len > sizeof(temp) - 1) {
89-
buffer = new char[len + 1];
89+
buffer = new (std::nothrow) char[len + 1];
9090
if (!buffer) {
9191
return 0;
9292
}

cores/esp8266/Stream.cpp

Lines changed: 2 additions & 2 deletions
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();

cores/esp8266/Updater.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ bool UpdaterClass::end(bool evenIfRemaining){
282282
return false;
283283
}
284284
free(sig);
285+
_size = binSize; // Adjust size to remove signature, not part of bin payload
286+
285287
#ifdef DEBUG_UPDATER
286288
DEBUG_UPDATER.printf_P(PSTR("[Updater] Signature matches\n"));
287289
#endif

cores/esp8266/WString.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ String::~String() {
124124
invalidate();
125125
}
126126

127-
// /*********************************************/
128-
// /* Memory Management */
129-
// /*********************************************/
127+
/*********************************************/
128+
/* Memory Management */
129+
/*********************************************/
130130

131131
inline void String::init(void) {
132132
setSSO(true);
@@ -199,9 +199,9 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) {
199199
return 0;
200200
}
201201

202-
// /*********************************************/
203-
// /* Copy and Move */
204-
// /*********************************************/
202+
/*********************************************/
203+
/* Copy and Move */
204+
/*********************************************/
205205

206206
String & String::copy(const char *cstr, unsigned int length) {
207207
if (!reserve(length)) {
@@ -297,9 +297,9 @@ String & String::operator = (const __FlashStringHelper *pstr)
297297
return *this;
298298
}
299299

300-
// /*********************************************/
301-
// /* concat */
302-
// /*********************************************/
300+
/*********************************************/
301+
/* concat */
302+
/*********************************************/
303303

304304
unsigned char String::concat(const String &s) {
305305
// Special case if we're concatting ourself (s += s;) since we may end up
@@ -483,9 +483,9 @@ StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHel
483483
return a;
484484
}
485485

486-
// /*********************************************/
487-
// /* Comparison */
488-
// /*********************************************/
486+
/*********************************************/
487+
/* Comparison */
488+
/*********************************************/
489489

490490
int String::compareTo(const String &s) const {
491491
if(!buffer() || !s.buffer()) {
@@ -587,9 +587,9 @@ unsigned char String::endsWith(const String &s2) const {
587587
return strcmp(&buffer()[len() - s2.len()], s2.buffer()) == 0;
588588
}
589589

590-
// /*********************************************/
591-
// /* Character Access */
592-
// /*********************************************/
590+
/*********************************************/
591+
/* Character Access */
592+
/*********************************************/
593593

594594
char String::charAt(unsigned int loc) const {
595595
return operator[](loc);
@@ -629,9 +629,9 @@ void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int ind
629629
buf[n] = 0;
630630
}
631631

632-
// /*********************************************/
633-
// /* Search */
634-
// /*********************************************/
632+
/*********************************************/
633+
/* Search */
634+
/*********************************************/
635635

636636
int String::indexOf(char c) const {
637637
return indexOf(c, 0);
@@ -713,9 +713,9 @@ String String::substring(unsigned int left, unsigned int right) const {
713713
return out;
714714
}
715715

716-
// /*********************************************/
717-
// /* Modification */
718-
// /*********************************************/
716+
/*********************************************/
717+
/* Modification */
718+
/*********************************************/
719719

720720
void String::replace(char find, char replace) {
721721
if (!buffer())
@@ -828,9 +828,9 @@ void String::trim(void) {
828828
wbuffer()[newlen] = 0;
829829
}
830830

831-
// /*********************************************/
832-
// /* Parsing / Conversion */
833-
// /*********************************************/
831+
/*********************************************/
832+
/* Parsing / Conversion */
833+
/*********************************************/
834834

835835
long String::toInt(void) const {
836836
if (buffer())

0 commit comments

Comments
 (0)