8000 Merge branch 'master' into pr-dns-forwarder · esp8266/Arduino@ff5d79a · GitHub
[go: up one dir, main page]

Skip to content

Commit ff5d79a

Browse files
authored
Merge branch 'master' into pr-dns-forwarder
2 parents 22769c5 + 8b7126d commit ff5d79a

File tree

85 files changed

+2734
-877
lines changed

Some content is hidden

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

85 files changed

+2734
-877
lines changed

.github/workflows/pull-request.yml

Lines changed: 7 additions & 0 deletions
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

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

cores/esp8266/Arduino.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ extern "C" {
4343
#define HIGH 0x1
4444
#define LOW 0x0
4545

46-
#define PWMRANGE 1023
47-
4846
//GPIO FUNCTIONS
4947
#define INPUT 0x00
5048
#define INPUT_PULLUP 0x02
@@ -176,13 +174,9 @@ int analogRead(uint8_t pin);
176174
void analogReference(uint8_t mode);
177175
void analogWrite(uint8_t pin, int val);
178176
void analogWriteFreq(uint32_t freq);
177+
void analogWriteResolution(int res);
179178
void analogWriteRange(uint32_t range);
180179

181-
unsigned long millis(void);
182-
unsigned long micros(void);
183-
uint64_t micros64(void);
184-
void delay(unsigned long);
185-
void delayMicroseconds(unsigned int us);
186180
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
187181
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
188182

cores/esp8266/Crypto.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void *createBearsslHmac(const br_hash_class *hashType, const void *data, const s
100100

101101
String createBearsslHmac(const br_hash_class *hashType, const uint8_t hashTypeNaturalLength, const String &message, const void *hashKey, const size_t hashKeyLength, const size_t hmacLength)
102102
{
103+
(void) hashTypeNaturalLength;
103104
assert(1 <= hmacLength && hmacLength <= hashTypeNaturalLength);
104105

105106
uint8_t hmac[hmacLength];
@@ -152,6 +153,7 @@ void *createBearsslHmacCT(const br_hash_class *hashType, const void *data, const
152153

153154
String createBearsslHmacCT(const br_hash_class *hashType, const uint8_t hashTypeNaturalLength, const String &message, const void *hashKey, const size_t hashKeyLength, const size_t hmacLength)
154155
{
156+
(void) hashTypeNaturalLength;
155157
assert(1 <= hmacLength && hmacLength <= hashTypeNaturalLength);
156158

157159
uint8_t hmac[hmacLength];

cores/esp8266/Esp.cpp

Lines changed: 7 additions & 13 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;
@@ -697,15 +690,16 @@ static SpiFlashOpResult spi_flash_write_puya(uint32_t offset, uint32_t *data, si
697690
} else {
698691
bytesLeft = 0;
699692
}
700-
rc = spi_flash_read(pos, flash_write_puya_buf, bytesNow);
693+
size_t bytesAligned = (bytesNow + 3) & ~3;
694+
rc = spi_flash_read(pos, flash_write_puya_buf, bytesAligned);
701695
if (rc != SPI_FLASH_RESULT_OK) {
702696
return rc;
703697
}
704-
for (size_t i = 0; i < bytesNow / 4; ++i) {
698+
for (size_t i = 0; i < bytesAligned / 4; ++i) {
705699
flash_write_puya_buf[i] &= *ptr;
706700
++ptr;
707701
}
708-
rc = spi_flash_write(pos, flash_write_puya_buf, bytesNow);
702+
rc = spi_flash_write(pos, flash_write_puya_buf, bytesAligned);
709703
pos += bytesNow;
710704
}
711705
return rc;
@@ -739,17 +733,17 @@ String EspClass::getSketchMD5()
739733
}
740734
uint32_t lengthLeft = getSketchSize();
741735
const size_t bufSize = 512;
742-
std::unique_ptr<uint8_t[]> buf(new uint8_t[bufSize]);
736+
std::unique_ptr<uint8_t[]> buf(new (std::nothrow) uint8_t[bufSize]);
743737
uint32_t offset = 0;
744738
if(!buf.get()) {
745-
return String();
739+
return emptyString;
746740
}
747741
MD5Builder md5;
748742
md5.begin();
749743
while( lengthLeft > 0) {
750744
size_t readBytes = (lengthLeft < bufSize) ? lengthLeft : bufSize;
751745
if (!flashRead(offset, reinterpret_cast<uint32_t*>(buf.get()), (readBytes + 3) & ~3)) {
752-
return String();
746+
return emptyString;
753747
}
754748
md5.add(buf.get(), readBytes);
755749
lengthLeft -= readBytes;

cores/esp8266/Esp.h

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

124124
#if defined(F_CPU) || defined(CORE_MOCK)
125-
constexpr uint8_t getCpuFreqMHz() const
125+
constexpr
126+
#endif
127+
inline uint8_t getCpuFreqMHz() const __attribute__((always_inline))
126128
{
127-
return clockCyclesPerMicrosecond();
129+
return esp_get_cpu_freq_mhz();
128130
}
129-
#else
130-
uint8_t getCpuFreqMHz();
131-
#endif
132131

133132
uint32_t getFlashChipId();
134133
uint8_t getFlashChipVendorId();
@@ -167,21 +166,15 @@ class EspClass {
167166
uint8_t *random(uint8_t *resultArray, const size_t outputSizeBytes) const;
168167
uint32_t random() const;
169168

170-
#ifndef CORE_MOCK
171-
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+
}
172174
#else
173175
uint32_t getCycleCount();
174-
#endif
175-
};
176-
177-
#ifndef CORE_MOCK
178-
179-
uint32_t EspClass::getCycleCount()
180-
{
181-
return esp_get_cycle_count();
182-
}
183-
184176
#endif // !defined(CORE_MOCK)
177+
};
185178

186179
extern EspClass ESP;
187180

cores/esp8266/HardwareSerial.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
#include "HardwareSerial.h"
3333
#include "Esp.h"
3434

35+
36+
// SerialEvent functions are weak, so when the user doesn't define them,
37+
// the linker just sets their address to 0 (which is checked below).
38+
// T 10000 he Serialx_available is just a wrapper around Serialx.available(),
39+
// but we can refer to it weakly so we don't pull in the entire
40+
// HardwareSerial instance if the user doesn't also refer to it.
41+
void serialEvent() __attribute__((weak));
42+
3543
HardwareSerial::HardwareSerial(int uart_nr)
3644
: _uart_nr(uart_nr), _rx_size(256)
3745
{}
@@ -162,6 +170,14 @@ size_t HardwareSerial::readBytes(char* buffer, size_t size)
162170

163171
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
164172
HardwareSerial Serial(UART0);
173+
174+
// Executed at end of loop() processing when > 0 bytes available in the Serial port
175+
void serialEventRun(void)
176+
{
177+
if (serialEvent && Serial.available()) {
178+
serialEvent();
179+
}
180+
}
165181
#endif
166182
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1)
167183
HardwareSerial Serial1(UART1);

cores/esp8266/HardwareSerial.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,6 @@ class HardwareSerial: public Stream
207207
extern HardwareSerial Serial;
208208
extern HardwareSerial Serial1;
209209

210+
extern void serialEventRun(void) __attribute__((weak));
211+
210212
#endif

cores/esp8266/PolledTimeout.h

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/*
66
PolledTimeout.h - Encapsulation of a polled Timeout
7-
7+
88
Copyright (c) 2018 Daniel Salazar. All rights reserved.
99
This file is part of the esp8266 core for Arduino environment.
1010
@@ -23,9 +23,10 @@
2323
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
*/
2525

26-
#include <limits>
27-
28-
#include <Arduino.h>
26+
#include <c_types.h> // IRAM_ATTR
27+
#include <limits> // std::numeric_limits
28+
#include <type_traits> // std::is_unsigned
29+
#include <core_esp8266_features.h>
2930

3031
namespace esp8266
3132
{
@@ -70,13 +71,13 @@ struct TimeSourceMillis
7071

7172
struct TimeSourceCycles
7273
{
73-
// time policy based on ESP.getCycleCount()
74+
// time policy based on esp_get_cycle_count()
7475
// this particular time measurement is intended to be called very often
7576
// (every loop, every yield)
7677

77-
using timeType = decltype(ESP.getCycleCount());
78-
static timeType time() {return ESP.getCycleCount();}
79-
static constexpr timeType ticksPerSecond = ESP.getCpuFreqMHz() * 1000000UL; // 80'000'000 or 160'000'000 Hz
78+
using timeType = decltype(esp_get_cycle_count());
79+
static timeType time() {return esp_get_cycle_count();}
80+
static constexpr timeType ticksPerSecond = esp_get_cpu_freq_mhz() * 1000000UL; // 80'000'000 or 160'000'000 Hz
8081
static constexpr timeType ticksPerSecondMax = 160000000; // 160MHz
8182
};
8283

@@ -161,13 +162,13 @@ class timeoutTemplate
161162
return expiredRetrigger();
162163
return expiredOneShot();
163164
}
164-
165+
165166
IRAM_ATTR // fast
166167
operator bool()
167168
{
168-
return expired();
169+
return expired();
169170
}
170-
171+
171172
bool canExpire () const
172173
{
173174
return !_neverExpires;
@@ -178,6 +179,7 @@ class timeoutTemplate
178179
return _timeout != alwaysExpired;
179180
}
180181

182+
// Resets, will trigger after this new timeout.
181183
IRAM_ATTR // called from ISR
182184
void reset(const timeType newUserTimeout)
183185
{
@@ -186,12 +188,30 @@ class timeoutTemplate
186188
_neverExpires = (newUserTimeout < 0) || (newUserTimeout > timeMax());
187189
}
188190

191+
// Resets, will trigger after the timeout previously set.
189192
IRAM_ATTR // called from ISR
190193
void reset()
191194
{
192195
_start = TimePolicyT::time();
193196
}
194197

198+
// Resets to just expired so that on next poll the check will immediately trigger for the user,
199+
// also change timeout (after next immediate trigger).
200+
IRAM_ATTR // called from ISR
201+
void resetAndSetExpired (const timeType newUserTimeout)
202+
{
203+
reset(newUserTimeout);
204+
_start -= _timeout;
205+
}
206+
207+
// Resets to just expired so that on next poll the check will immediately trigger for the user.
208+
IRAM_ATTR // called from ISR
209+
void resetAndSetExpired ()
210+
{
211+
reset();
212+
_start -= _timeout;
213+
}
214+
195215
void resetToNeverExpires ()
196216
{
197217
_timeout = alwaysExpired + 1; // because canWait() has precedence
@@ -202,7 +222,7 @@ class timeoutTemplate
202222
{
203223
return TimePolicyT::toUserUnit(_timeout);
204224
}
205-
225+
206226
static constexpr timeType timeMax()
207227
{
208228
return TimePolicyT::timeMax;
@@ -235,14 +255,14 @@ class timeoutTemplate
235255
}
236256
return false;
237257
}
238-
258+
239259
IRAM_ATTR // fast
240260
bool expiredOneShot() const
241261
{
242262
// returns "always expired" or "has expired"
243263
return !canWait() || checkExpired(TimePolicyT::time());
244264
}
245-
265+
246266
timeType _timeout;
247267
timeType _start;
248268
bool _neverExpires;
@@ -259,14 +279,14 @@ using periodic = polledTimeout::timeoutTemplate<true> /*__attribute__((deprecate
259279
using oneShotMs = polledTimeout::timeoutTemplate<false>;
260280
using periodicMs = polledTimeout::timeoutTemplate<true>;
261281

262-
// Time policy based on ESP.getCycleCount(), and intended to be called very often:
282+
// Time policy based on esp_get_cycle_count(), and intended to be called very often:
263283
// "Fast" versions sacrifices time range for improved precision and reduced execution time (by 86%)
264-
// (cpu cycles for ::expired(): 372 (millis()) vs 52 (ESP.getCycleCount()))
284+
// (cpu cycles for ::expired(): 372 (millis()) vs 52 (esp_get_cycle_count()))
265285
// timeMax() values:
266286
// Ms: max is 26843 ms (26.8 s)
267287
// Us: max is 26843545 us (26.8 s)
268288
// Ns: max is 1073741823 ns ( 1.07 s)
269-
// (time policy based on ESP.getCycleCount() is intended to be called very often)
289+
// (time policy based on esp_get_cycle_count() is intended to be called very often)
270290

271291
using oneShotFastMs = polledTimeout::timeoutTemplate<false, YieldPolicy::DoNothing, TimePolicy::TimeFastMillis>;
272292
using periodicFastMs = polledTimeout::timeoutTemplate<true, YieldPolicy::DoNothing, TimePolicy::TimeFastMillis>;

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ UpdaterClass::UpdaterClass()
3535
, _startAddress(0)
3636
, _currentAddress(0)
3737
, _command(U_FLASH)
38+
, _ledPin(-1)
3839
, _hash(nullptr)
3940
, _verify(nullptr)
4041
, _progress_callback(nullptr)
@@ -112,6 +113,8 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
112113

113114
_reset();
114115
clearError(); // _error = 0
116+
_target_md5 = emptyString;
117+
_md5 = MD5Builder();
115118

116119
#ifndef HOST_MOCK
117120
wifi_set_sleep_type(NONE_SLEEP_T);

0 commit comments

Comments
 (0)
0