Skip to content

Commit e6bbf7f

Browse files
Merge branch 'master' into thunks
2 parents 3e4de76 + cb05b86 commit e6bbf7f

File tree

181 files changed

+6135
-9606
lines changed

Some content is hidden

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

181 files changed

+6135
-9606
lines changed

boards.txt

Lines changed: 448 additions & 224 deletions
Large diffs are not rendered by default.

cores/esp8266/Esp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ uint32_t EspClass::getFreeContStack()
183183
return cont_get_free_stack(g_pcont);
184184
}
185185

186+
void EspClass::resetFreeContStack()
187+
{
188+
cont_repaint_stack(g_pcont);
189+
}
190+
186191
uint32_t EspClass::getChipId(void)
187192
{
188193
return system_get_chip_id();

cores/esp8266/Esp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class EspClass {
111111
void getHeapStats(uint32_t* free = nullptr, uint16_t* max = nullptr, uint8_t* frag = nullptr);
112112

113113
uint32_t getFreeContStack();
114+
void resetFreeContStack();
114115

115116
const char * getSdkVersion();
116117
String getCoreVersion();

cores/esp8266/Updater.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void UpdaterClass::_reset() {
3737
_command = U_FLASH;
3838

3939
if(_ledPin != -1) {
40-
digitalWrite(_ledPin, _ledStateRestore);
40+
digitalWrite(_ledPin, !_ledOn); // off
4141
}
4242
}
4343

@@ -50,10 +50,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
5050
}
5151

5252
_ledPin = ledPin;
53-
_ledOn = ledOn;
54-
if(_ledPin != -1) {
55-
_ledStateRestore = digitalRead(_ledPin);
56-
}
53+
_ledOn = !!ledOn; // 0(LOW) or 1(HIGH)
5754

5855
/* Check boot mode; if boot mode is 1 (UART download mode),
5956
we will not be able to reset into normal mode once update is done.
@@ -178,7 +175,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
178175

179176
_md5.calculate();
180177
if(_target_md5.length()) {
181-
if(_target_md5 != _md5.toString()){
178+
if(strcasecmp(_target_md5.c_str(), _md5.toString().c_str()) != 0){
182179
_setError(UPDATE_ERROR_MD5);
183180
_reset();
184181
return false;
@@ -376,7 +373,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
376373

377374
while(remaining()) {
378375
if(_ledPin != -1) {
379-
digitalWrite(LED_BUILTIN, _ledOn); // Switch LED on
376+
digitalWrite(_ledPin, _ledOn); // Switch LED on
380377
}
381378
size_t bytesToRead = _bufferSize - _bufferLen;
382379
if(bytesToRead > remaining()) {
@@ -394,7 +391,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
394391
}
395392
}
396393
if(_ledPin != -1) {
397-
digitalWrite(LED_BUILTIN, _ledOn == HIGH ? LOW : HIGH); // Switch LED off
394+
digitalWrite(_ledPin, !_ledOn); // Switch LED off
398395
}
399396
_bufferLen += toRead;
400397
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())

cores/esp8266/Updater.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ class UpdaterClass {
165165

166166
int _ledPin;
167167
uint8_t _ledOn;
168-
int _ledStateRestore;
169168
};
170169

171170
extern UpdaterClass Update;

cores/esp8266/WString.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,7 @@ float String::toFloat(void) const {
796796
return atof(buffer);
797797
return 0;
798798
}
799+
800+
// global empty string to allow returning const String& with nothing
801+
802+
const String emptyString;

cores/esp8266/WString.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,7 @@ class StringSumHelper: public String {
294294
}
295295
};
296296

297+
extern const String emptyString;
298+
297299
#endif // __cplusplus
298300
#endif // String_class_h

cores/esp8266/cont.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ int cont_get_free_stack(cont_t* cont);
7474
// continuation stack
7575
bool cont_can_yield(cont_t* cont);
7676

77+
// Repaint the stack from the current SP to the end, to allow individual
78+
// routines' stack usages to be calculated by re-painting, checking current
79+
// free, running the routine, then checking the max free
80+
void cont_repaint_stack(cont_t *cont);
81+
82+
7783
#ifdef __cplusplus
7884
}
7985
#endif

cores/esp8266/cont_util.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,18 @@ bool ICACHE_RAM_ATTR cont_can_yield(cont_t* cont) {
6464
return !ETS_INTR_WITHINISR() &&
6565
cont->pc_ret != 0 && cont->pc_yield == 0;
6666
}
67+
68+
// No need for this to be in IRAM, not expected to be IRQ called
69+
void cont_repaint_stack(cont_t *cont)
70+
{
71+
register uint32_t *sp asm("a1");
72+
// Ensure 64 bytes adjacent to the current SP don't get touched to endure
73+
// we don't accidentally trounce over locals or IRQ temps.
74+
uint32_t sp_safe = CONT_STACKSIZE/4 - ((sp - &cont->stack[0] - 64)/4);
75+
76+
// Fill stack with magic values
77+
for(uint32_t pos = 0; pos < sp_safe; pos++)
78+
{
79+
cont->stack[pos] = CONT_STACKGUARD;
80+
}
81+
}

0 commit comments

Comments
 (0)