Skip to content

Commit b3ed528

Browse files
Merge branch 'master' into signedupdates
2 parents 31b22fb + e7d3cf6 commit b3ed528

File tree

125 files changed

+5665
-1016
lines changed

Some content is hidden

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

125 files changed

+5665
-1016
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
sudo: false
21
language: bash
32
os: linux
43
dist: trusty

boards.txt

Lines changed: 348 additions & 116 deletions
Large diffs are not rendered by default.

bootloaders/eboot/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ AR := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-ar
1717
LD := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc
1818
OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump
1919

20-
20+
INC += -I../../tools/sdk/include
2121
CFLAGS += -std=gnu99
2222

2323
CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals
2424

25+
CFLAGS += $(INC)
26+
2527
LDFLAGS += -nostdlib -Wl,--no-check-sections -umain
2628

2729
LD_SCRIPT := -Teboot.ld

bootloaders/eboot/eboot.elf

24 Bytes
Binary file not shown.

bootloaders/eboot/flash.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
#ifndef FLASH_H
99
#define FLASH_H
1010

11+
12+
/* The geometry defines are placed in the sdk. The .h was factored out for reuse by eboot here.
13+
* Beware: this means that eboot has an external dependency.
14+
* The following .h is placed in tools/sdk/includes
15+
*/
16+
#include <spi_flash_geometry.h>
17+
1118
int SPIEraseBlock(uint32_t block);
1219
int SPIEraseSector(uint32_t sector);
1320
int SPIRead(uint32_t addr, void *dest, size_t size);
1421
int SPIWrite(uint32_t addr, void *src, size_t size);
1522
int SPIEraseAreaEx(const uint32_t start, const uint32_t size);
1623

17-
#define FLASH_SECTOR_SIZE 0x1000
18-
#define FLASH_BLOCK_SIZE 0x10000
19-
#define APP_START_OFFSET 0x1000
2024

2125
typedef struct {
2226
unsigned char magic;
@@ -25,7 +29,7 @@ typedef struct {
2529
/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
2630
unsigned char flash_mode;
2731

28-
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M,
32+
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M
2933
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
3034
unsigned char flash_size_freq;
3135

cores/esp8266/AddrList.h

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
AddrList.h - cycle through lwIP netif's ip addresses like a c++ list
3+
Copyright (c) 2018 david gauchard. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
/*
21+
This class allows to explore all configured IP addresses
22+
in lwIP netifs, with that kind of c++ loop:
23+
24+
for (auto a: ifList)
25+
out.printf("IF='%s' index=%d legacy=%d IPv4=%d local=%d hostname='%s' addr= %s\n",
26+
a->iface().c_str(),
27+
a->number(),
28+
a->addr().isLegacy(),
29+
a->addr().isV4(),
30+
a->addr().isLocal(),
31+
a->hostname().c_str(),
32+
a->addr().toString().c_str());
33+
34+
This loop:
35+
36+
while (WiFi.status() != WL_CONNECTED()) {
37+
Serial.print('.');
38+
delay(500);
39+
}
40+
41+
can be replaced by:
42+
43+
for (bool configured = false; !configured; ) {
44+
for (auto iface: ifList)
45+
if ((configured = !iface->addr().isLocal())
46+
break;
47+
Serial.print('.');
48+
delay(500);
49+
}
50+
51+
waiting for an IPv6 global address:
52+
53+
for (bool configured = false; !configured; ) {
54+
for (auto iface: ifList)
55+
if ((configured = ( !iface->addr()->isV4()
56+
&& !iface->addr().isLocal())))
57+
break;
58+
Serial.print('.');
59+
delay(500);
60+
}
61+
62+
waiting for an IPv6 global address, on a specific interface:
63+
64+
for (bool configured = false; !configured; ) {
65+
for (auto iface: ifList)
66+
if ((configured = ( !iface->addr()->isV4()
67+
&& !iface->addr().isLocal()
68+
&& iface->number() == STATION_IF)))
69+
break;
70+
Serial.print('.');
71+
delay(500);
72+
}
73+
*/
74+
75+
#ifndef __ADDRLIST_H
76+
#define __ADDRLIST_H
77+
78+
#include <IPAddress.h>
79+
#include <lwip/netif.h>
80+
81+
#if LWIP_IPV6
82+
#define IF_NUM_ADDRESSES (1 + LWIP_IPV6_NUM_ADDRESSES)
83+
#else
84+
#define IF_NUM_ADDRESSES (1)
85+
#endif
86+
87+
88+
class AddrListClass {
89+
90+
// no member in this class
91+
// lwIP's global 'struct netif* netif_list' is used
92+
// designed to be used with 'for (auto x: ifList)'
93+
94+
public:
95+
96+
class const_iterator {
97+
98+
public:
99+
100+
// iterator operations:
101+
102+
const_iterator (bool begin = true): _netif(begin? netif_list: nullptr), _num(-1) { ++*this; }
103+
const_iterator (const const_iterator& o): _netif(o._netif), _num(o._num) { }
104+
const_iterator& operator= (const const_iterator& o) { _netif = o._netif; _num = o._num; return *this; }
105+
106+
bool operator!= (const const_iterator& o) { return !equal(o); }
107+
bool operator== (const const_iterator& o) { return equal(o); }
108+
109+
const_iterator operator++(int) {
110+
const_iterator ret = *this;
111+
++(*this);
112+
return ret;
113+
}
114+
115+
const_iterator& operator++() {
116+
while (_netif) {
117+
if (++_num == IF_NUM_ADDRESSES) {
118+
_num = -1;
119+
_netif = _netif->next;
120+
continue;
121+
}
122+
if (!ip_addr_isany(_ip_from_netif_num()))
123+
break;
124+
}
125+
return *this;
126+
}
127+
128+
// (*iterator) emulation:
129+
130+
const const_iterator& operator* () const { return *this; }
131+
const const_iterator* operator-> () const { return this; }
132+
133+
bool isLegacy() const { return _num == 0; }
134+
bool isLocal() const { return addr().isLocal(); }
135+
IPAddress addr () const { return _ip_from_netif_num(); }
136+
IPAddress netmask () const { return _netif->netmask; }
137+
IPAddress gw () const { return _netif->gw; }
138+
String iface () const { return String(_netif->name[0]) + _netif->name[1]; }
139+
const char* hostname () const { return _netif->hostname?: emptyString.c_str(); }
140+
const char* mac () const { return (const char*)_netif->hwaddr; }
141+
int number () const { return _netif->num; }
142+
143+
protected:
144+
145+
bool equal (const const_iterator& o) {
146+
return _netif == o._netif
147+
&& (!_netif || _num == o._num);
148+
}
149+
150+
const ip_addr_t* _ip_from_netif_num () const {
151+
#if LWIP_IPV6
152+
return _num? &_netif->ip6_addr[_num - 1]: &_netif->ip_addr;
153+
#else
154+
return &_netif->ip_addr;
155+
#endif
156+
}
157+
158+
netif* _netif;
159+
int _num; // address index (0 is legacy, _num-1 is ip6_addr[]'s index)
160+
};
161+
162+
const const_iterator begin () const { return const_iterator(true); }
163+
const const_iterator end () const { return const_iterator(false); }
164+
};
165+
166+
extern AddrListClass addrList;
167+
168+
#endif // __ADDRLIST_H

cores/esp8266/Client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class Client: public Stream {
2727

2828
public:
29-
virtual int connect(IPAddress ip, uint16_t port) =0;
29+
virtual int connect(CONST IPAddress& ip, uint16_t port) =0;
3030
virtual int connect(const char *host, uint16_t port) =0;
3131
virtual size_t write(uint8_t) =0;
3232
virtual size_t write(const uint8_t *buf, size_t size) =0;
@@ -39,7 +39,7 @@ class Client: public Stream {
3939
virtual uint8_t connected() = 0;
4040
virtual operator bool() = 0;
4141
protected:
42-
uint8_t* rawIPAddress(IPAddress& addr) {
42+
CONST uint8_t* rawIPAddress(CONST IPAddress& addr) {
4343
return addr.raw_address();
4444
}
4545
;

cores/esp8266/Esp-version.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
#define STR(x) STRHELPER(x) // stringifier
3030

3131
static const char arduino_esp8266_git_ver [] PROGMEM = STR(ARDUINO_ESP8266_GIT_DESC);
32-
#if LWIP_VERSION_MAJOR != 1
33-
static const char lwip2_version [] PROGMEM = "/lwIP:" STR(LWIP_VERSION_MAJOR) "." STR(LWIP_VERSION_MINOR) "." STR(LWIP_VERSION_REVISION);
34-
#endif
3532
static const char bearssl_version [] PROGMEM = "/BearSSL:" STR(BEARSSL_GIT);
3633

3734
String EspClass::getFullVersion()
@@ -40,17 +37,18 @@ String EspClass::getFullVersion()
4037
+ F("/Core:") + FPSTR(arduino_esp8266_git_ver)
4138
#if LWIP_VERSION_MAJOR == 1
4239
+ F("/lwIP:") + String(LWIP_VERSION_MAJOR) + "." + String(LWIP_VERSION_MINOR) + "." + String(LWIP_VERSION_REVISION)
43-
#else
44-
+ FPSTR(lwip2_version)
45-
#endif
4640
#if LWIP_VERSION_IS_DEVELOPMENT
4741
+ F("-dev")
4842
#endif
4943
#if LWIP_VERSION_IS_RC
5044
+ F("rc") + String(LWIP_VERSION_RC)
5145
#endif
52-
#ifdef LWIP_HASH_STR
53-
+ "(" + F(LWIP_HASH_STR) + ")"
46+
#else // LWIP_VERSION_MAJOR != 1
47+
+ F("/lwIP:")
48+
#if LWIP_IPV6
49+
+ F("IPv6+")
50+
#endif
51+
+ F(LWIP_HASH_STR)
5452
#endif
5553
+ FPSTR(bearssl_version)
5654
;

cores/esp8266/Esp.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,43 @@ uint64_t EspClass::deepSleepMax()
132132

133133
}
134134

135+
/*
136+
Layout of RTC Memory is as follows:
137+
Ref: Espressif doc 2C-ESP8266_Non_OS_SDK_API_Reference, section 3.3.23 (system_rtc_mem_write)
138+
139+
|<------system data (256 bytes)------->|<-----------------user data (512 bytes)--------------->|
140+
141+
SDK function signature:
142+
bool system_rtc_mem_read (
143+
uint32 des_addr,
144+
void * src_addr,
145+
uint32 save_size
146+
)
147+
148+
The system data section can't be used by the user, so:
149+
des_addr must be >=64 (i.e.: 256/4) and <192 (i.e.: 768/4)
150+
src_addr is a pointer to data
151+
save_size is the number of bytes to write
152+
153+
For the method interface:
154+
offset is the user block number (block size is 4 bytes) must be >= 0 and <128
155+
data is a pointer to data, 4-byte aligned
156+
size is number of bytes in the block pointed to by data
157+
158+
Same for write
159+
160+
Note: If the Updater class is in play, e.g.: the application uses OTA, the eboot
161+
command will be stored into the first 128 bytes of user data, then it will be
162+
retrieved by eboot on boot. That means that user data present there will be lost.
163+
Ref:
164+
- discussion in PR #5330.
165+
- https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map#memmory-mapped-io-registers
166+
- Arduino/bootloaders/eboot/eboot_command.h RTC_MEM definition
167+
*/
168+
135169
bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
136170
{
137-
if (size + offset > 512) {
171+
if (offset * 4 + size > 512 || size == 0) {
138172
return false;
139173
} else {
140174
return system_rtc_mem_read(64 + offset, data, size);
@@ -143,13 +177,15 @@ bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
143177

144178
bool EspClass::rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size)
145179
{
146-
if (size + offset > 512) {
180+
if (offset * 4 + size > 512 || size == 0) {
147181
return false;
148182
} else {
149183
return system_rtc_mem_write(64 + offset, data, size);
150184
}
151185
}
152186

187+
188+
153189
extern "C" void __real_system_restart_local();
154190
void EspClass::reset(void)
155191
{
@@ -165,6 +201,7 @@ void EspClass::restart(void)
165201
uint16_t EspClass::getVcc(void)
166202
{
167203
InterruptLock lock;
204+
(void)lock;
168205
return system_get_vdd33();
169206
}
170207

cores/esp8266/FSImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class DirImpl {
6262

6363
class FSImpl {
6464
public:
65+
virtual ~FSImpl () { }
6566
virtual bool begin() = 0;
6667
virtual void end() = 0;
6768
virtual bool format() = 0;

0 commit comments

Comments
 (0)