Skip to content

Commit 4ab2003

Browse files
Merge branch 'master' into master
2 parents 63bbd02 + 8c3f1be commit 4ab2003

File tree

134 files changed

+3385
-1467
lines changed

Some content is hidden

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

134 files changed

+3385
-1467
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ tools/xtensa-lx106-elf/
44
tools/mkspiffs/
55
tools/mklittlefs/
66
tools/python/
7+
tools/python3/
78
package/versions/
89
exclude.txt
910
tools/sdk/lib/liblwip_src.a

.travis.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ git:
66
depth: 1
77
submodules: false
88

9-
addons:
10-
apt:
11-
sources:
12-
- ubuntu-toolchain-r-test
13-
packages:
14-
- g++-7
15-
- gcc-7
16-
179
before_install:
1810
- git submodule update --init # no recursive update
1911

@@ -87,7 +79,11 @@ jobs:
8779
- name: "Host tests"
8880
stage: build
8981
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh
90-
install: sudo apt-get install valgrind lcov
82+
install:
83+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
84+
- sudo apt-get update -q
85+
- sudo apt-get install -y --allow-unauthenticated g++-7 gcc-7
86+
- sudo apt-get install valgrind lcov
9187
env: CC=gcc-7 CXX=g++-7
9288

9389
- name: "Docs"
@@ -105,8 +101,24 @@ jobs:
105101
- name: "Mock trivial test"
106102
stage: build
107103
script: $TRAVIS_BUILD_DIR/tests/buildm.sh
104+
install:
105+
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
106+
- sudo apt-get update -q
107+
- sudo apt-get install -y --allow-unauthenticated g++-7 gcc-7
108108
env: CC=gcc-7 CXX=g++-7
109109

110+
- name: "Mac OSX can build sketches"
111+
os: osx
112+
stage: build
113+
script: $TRAVIS_BUILD_DIR/tests/build.sh
114+
env: MACOSX=1 BUILD_PARITY=custom mod=500 rem=1
115+
116+
- name: "Windows can build sketches"
117+
os: windows
118+
stage: build
119+
script: $TRAVIS_BUILD_DIR/tests/build.sh
120+
env: WINDOWS=1 BUILD_PARITY=custom mod=500 rem=1
121+
110122
- name: "Boards"
111123
stage: build
112124
script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh

boards.txt

Lines changed: 342 additions & 180 deletions
Large diffs are not rendered by default.

cores/esp8266/AddrList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct netifWrapper
128128
const char* ifmac () const { return (const char*)_netif->hwaddr; }
129129
int ifnumber () const { return _netif->num; }
130130
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
131+
CONST netif* interface () const { return _netif; }
131132

132133
const ip_addr_t* ipFromNetifNum () const
133134
{

cores/esp8266/Arduino.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,15 @@ long secureRandom(long);
275275
long secureRandom(long, long);
276276
long map(long, long, long, long, long);
277277

278-
extern "C" void configTime(long timezone, int daylightOffset_sec,
279-
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
278+
void configTime(int timezone, int daylightOffset_sec, const char* server1,
279+
const char* server2 = nullptr, const char* server3 = nullptr);
280280

281-
#endif
281+
void configTime(const char* tz, const char* server1,
282+
const char* server2 = nullptr, const char* server3 = nullptr);
282283

283-
#include "pins_arduino.h"
284+
#endif // __cplusplus
284285

285-
#ifndef PUYA_SUPPORT
286-
#define PUYA_SUPPORT 1
287-
#endif
286+
#include "pins_arduino.h"
288287

289288
#endif
290289

cores/esp8266/Esp.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21-
#include "Arduino.h"
21+
#include "Esp.h"
2222
#include "flash_utils.h"
2323
#include "eboot_command.h"
2424
#include <memory>
@@ -36,6 +36,14 @@ extern struct rst_info resetInfo;
3636

3737
//#define DEBUG_SERIAL Serial
3838

39+
#ifndef PUYA_SUPPORT
40+
#define PUYA_SUPPORT 1
41+
#endif
42+
#ifndef PUYA_BUFFER_SIZE
43+
// Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k)
44+
// Always use a multiple of flash page size (256 bytes)
45+
#define PUYA_BUFFER_SIZE 256
46+
#endif
3947

4048
/**
4149
* User-defined Literals
@@ -494,7 +502,7 @@ uint32_t EspClass::getSketchSize() {
494502

495503
image_header_t image_header;
496504
uint32_t pos = APP_START_OFFSET;
497-
if (spi_flash_read(pos, (uint32_t*) &image_header, sizeof(image_header))) {
505+
if (spi_flash_read(pos, (uint32_t*) &image_header, sizeof(image_header)) != SPI_FLASH_RESULT_OK) {
498506
return 0;
499507
}
500508
pos += sizeof(image_header);
@@ -506,7 +514,7 @@ uint32_t EspClass::getSketchSize() {
506514
++section_index)
507515
{
508516
section_header_t section_header = {0, 0};
509-
if (spi_flash_read(pos, (uint32_t*) &section_header, sizeof(section_header))) {
517+
if (spi_flash_read(pos, (uint32_t*) &section_header, sizeof(section_header)) != SPI_FLASH_RESULT_OK) {
510518
return 0;
511519
}
512520
pos += sizeof(section_header);
@@ -577,26 +585,27 @@ bool EspClass::flashEraseSector(uint32_t sector) {
577585
}
578586

579587
#if PUYA_SUPPORT
580-
static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
588+
static SpiFlashOpResult spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
581589
if (data == nullptr) {
582-
return 1; // SPI_FLASH_RESULT_ERR
590+
return SPI_FLASH_RESULT_ERR;
583591
}
584592
// PUYA flash chips need to read existing data, update in memory and write modified data again.
585593
static uint32_t *flash_write_puya_buf = nullptr;
586-
int rc = 0;
587-
uint32_t* ptr = data;
588594

589595
if (flash_write_puya_buf == nullptr) {
590596
flash_write_puya_buf = (uint32_t*) malloc(PUYA_BUFFER_SIZE);
591597
// No need to ever free this, since the flash chip will never change at runtime.
592598
if (flash_write_puya_buf == nullptr) {
593599
// Memory could not be allocated.
594-
return 1; // SPI_FLASH_RESULT_ERR
600+
return SPI_FLASH_RESULT_ERR;
595601
}
596602
}
603+
604+
SpiFlashOpResult rc = SPI_FLASH_RESULT_OK;
605+
uint32_t* ptr = data;
597606
size_t bytesLeft = size;
598607
uint32_t pos = offset;
599-
while (bytesLeft > 0 && rc == 0) {
608+
while (bytesLeft > 0 && rc == SPI_FLASH_RESULT_OK) {
600609
size_t bytesNow = bytesLeft;
601610
if (bytesNow > PUYA_BUFFER_SIZE) {
602611
bytesNow = PUYA_BUFFER_SIZE;
@@ -605,7 +614,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
605614
bytesLeft = 0;
606615
}
607616
rc = spi_flash_read(pos, flash_write_puya_buf, bytesNow);
608-
if (rc != 0) {
617+
if (rc != SPI_FLASH_RESULT_OK) {
609618
return rc;
610619
}
611620
for (size_t i = 0; i < bytesNow / 4; ++i) {
@@ -620,7 +629,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) {
620629
#endif
621630

622631
bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size) {
623-
int rc = 0;
632+
SpiFlashOpResult rc = SPI_FLASH_RESULT_OK;
624633
#if PUYA_SUPPORT
625634
if (getFlashChipVendorId() == SPI_FLASH_VENDOR_PUYA) {
626635
rc = spi_flash_write_puya(offset, data, size);
@@ -630,12 +639,12 @@ bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size) {
630639
{
631640
rc = spi_flash_write(offset, data, size);
632641
}
633-
return rc == 0;
642+
return rc == SPI_FLASH_RESULT_OK;
634643
}
635644

636645
bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size) {
637-
int rc = spi_flash_read(offset, (uint32_t*) data, size);
638-
return rc == 0;
646+
auto rc = spi_flash_read(offset, (uint32_t*) data, size);
647+
return rc == SPI_FLASH_RESULT_OK;
639648
}
640649

641650
String EspClass::getSketchMD5()

cores/esp8266/Esp.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323

2424
#include <Arduino.h>
2525

26-
#ifndef PUYA_SUPPORT
27-
#define PUYA_SUPPORT 0
28-
#endif
29-
#ifndef PUYA_BUFFER_SIZE
30-
// Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k)
31-
// Always use a multiple of flash page size (256 bytes)
32-
#define PUYA_BUFFER_SIZE 256
33-
#endif
34-
3526
// Vendor IDs taken from Flashrom project
3627
// https://review.coreboot.org/cgit/flashrom.git/tree/flashchips.h?h=1.0.x
3728
typedef enum {
@@ -201,9 +192,10 @@ class EspClass {
201192
bool eraseConfig();
202193

203194
#ifndef CORE_MOCK
204-
inline
205-
#endif
195+
inline uint32_t getCycleCount() __attribute__((always_inline));
196+
#else
206197
uint32_t getCycleCount();
198+
#endif
207199
};
208200

209201
#ifndef CORE_MOCK

cores/esp8266/HardwareSerial.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ void HardwareSerial::end()
6060
_uart = NULL;
6161
}
6262

63+
void HardwareSerial::updateBaudRate(unsigned long baud)
64+
{
65+
if(!_uart) {
66+
return;
67+
}
68+
69+
uart_set_baudrate(_uart, baud);
70+
}
71+
6372
size_t HardwareSerial::setRxBufferSize(size_t size){
6473
if(_uart) {
6574
_rx_size = uart_resize_rx_buffer(_uart, size);
@@ -99,14 +108,16 @@ int HardwareSerial::available(void)
99108

100109
void HardwareSerial::flush()
101110
{
111+
uint8_t bit_length = 0;
102112
if(!_uart || !uart_tx_enabled(_uart)) {
103113
return;
104114
}
105115

116+
bit_length = uart_get_bit_length(_uart_nr); // data width, parity and stop
106117
uart_wait_tx_empty(_uart);
107118
//Workaround for a bug in serial not actually being finished yet
108119
//Wait for 8 data bits, 1 parity and 2 stop bits, just in case
109-
delayMicroseconds(11000000 / uart_get_baudrate(_uart) + 1);
120+
delayMicroseconds(bit_length * 1000000 / uart_get_baudrate(_uart) + 1);
110121
}
111122

112123
void HardwareSerial::startDetectBaudrate()
@@ -121,9 +132,9 @@ unsigned long HardwareSerial::testBaudrate()
121132

122133
unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
123134
{
124-
time_t startMillis = millis();
135+
esp8266::polledTimeout::oneShotFastMs timeOut(timeoutMillis);
125136
unsigned long detectedBaudrate;
126-
while ((time_t) millis() - startMillis < timeoutMillis) {
137+
while (!timeOut) {
127138
if ((detectedBaudrate = testBaudrate())) {
128139
break;
129140
}
@@ -133,8 +144,8 @@ unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
133144
return detectedBaudrate;
134145
}
135146

136-
size_t HardwareSerial::readBytes(char* buffer, size_t size)
137-
{
147+
size_t HardwareSerial::readBytes(char* buffer, size_t size)
148+
{
138149
size_t got = 0;
139150

140151
while (got < size)
@@ -147,7 +158,7 @@ size_t HardwareSerial::readBytes(char* buffer, size_t size)
147158
got += read(buffer + got, std::min(size - got, avail));
148159
}
149160
return got;
150-
}
161+
}
151162

152163
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
153164
HardwareSerial Serial(UART0);

cores/esp8266/HardwareSerial.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class HardwareSerial: public Stream
8888

8989
void end();
9090

91+
void updateBaudRate(unsigned long baud);
92+
9193
size_t setRxBufferSize(size_t size);
9294
size_t getRxBufferSize()
9395
{

cores/esp8266/StreamString.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ size_t StreamString::write(const uint8_t *data, size_t size) {
3232
*(wbuffer() + newlen) = 0x00; // add null for string end
3333
return size;
3434
}
35+
DEBUGV(":stream2string: OOM (%d->%d)\n", length(), newlen+1);
3536
}
3637
return 0;
3738
}

0 commit comments

Comments
 (0)