Skip to content

Commit 3284c73

Browse files
authored
Merge branch 'master' into master
2 parents fa2cb5e + bc3daef commit 3284c73

File tree

362 files changed

+15989
-29762
lines changed

Some content is hidden

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

362 files changed

+15989
-29762
lines changed

.github/workflows/pull-request.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/cache@v2
3131
with:
3232
path: ./tools/dist
33-
key: key-linux-toolchain
33+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
3434
- name: Build Sketches
3535
env:
3636
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -62,7 +62,7 @@ jobs:
6262
uses: actions/cache@v2
6363
with:
6464
path: ./tools/dist
65-
key: key-linux-toolchain
65+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
6666
- name: Build Sketches
6767
env:
6868
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -90,7 +90,7 @@ jobs:
9090
uses: actions/cache@v2
9191
with:
9292
path: ./tools/dist
93-
key: key-windows-toolchain
93+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
9494
- name: Build Sketch
9595
env:
9696
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -102,7 +102,7 @@ jobs:
102102
run: |
103103
# Windows has python3 already installed, but it's called "python".
104104
# Copy python.exe to the proper name so scripts "just work".
105-
copy (get-command python).source (get-command python).source.Replace("python.exe", "python3.exe")
105+
try { Get-Command python3 } catch { copy (get-command python).source (get-command python).source.Replace("python.exe", "python3.exe") }
106106
bash ./tests/build.sh
107107
108108
@@ -122,7 +122,7 @@ jobs:
122122
uses: actions/cache@v2
123123
with:
124124
path: ./tools/dist
125-
key: key-mac-toolchain
125+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
126126
- name: Build Sketch
127127
env:
128128
TRAVIS_BUILD_DIR: ${{ github.workspace }}
@@ -260,11 +260,12 @@ jobs:
260260
uses: actions/cache@v2
261261
with:
262262
path: ./tools/dist
263-
key: key-linux-toolchain
263+
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh') }}
264264
- name: Boards.txt diff
265265
env:
266266
TRAVIS_BUILD_DIR: ${{ github.workspace }}
267267
TRAVIS_TAG: ${{ github.ref }}
268268
run: |
269269
bash ./tests/ci/build_boards.sh
270270
bash ./tests/ci/eboot_test.sh
271+
bash ./tests/ci/pkgrefs_test.sh

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
url = https://github.com/arduino-libraries/Ethernet.git
2525
[submodule "tools/sdk/uzlib"]
2626
path = tools/sdk/uzlib
27-
url = https://github.com/earlephilhower/uzlib.git
27+
url = https://github.com/pfalcon/uzlib.git

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
3030

3131
- Install the current upstream Arduino IDE at the 1.8.9 level or later. The current version is on the [Arduino website](https://www.arduino.cc/en/main/software).
3232
- Start Arduino and open the Preferences window.
33-
- Enter ```https://arduino.esp8266.com/stable/package_esp8266com_index.json``` into the *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
33+
- Enter ```https://arduino.esp8266.com/stable/package_esp8266com_index.json``` into the *File>Preferences>Additional Boards Manager URLs* field of the Arduino IDE. You can add multiple URLs, separating them with commas.
3434
- Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
3535

3636
#### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)

boards.txt

Lines changed: 417 additions & 7 deletions
Large diffs are not rendered by default.

bootloaders/eboot/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump
2121

2222
INC += -I../../tools/sdk/include -I../../tools/sdk/uzlib/src
2323

24-
CFLAGS += -std=gnu99
24+
CFLAGS += -std=gnu17
2525

26-
CFLAGS += -Os -fcommon -g -Wall -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals -ffunction-sections -fdata-sections
26+
CFLAGS += -Os -fcommon -g -Wall -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals -ffunction-sections -fdata-sections -free -fipa-pta
2727

2828
CFLAGS += $(INC)
2929

@@ -40,17 +40,17 @@ APP_FW := eboot.bin
4040

4141
all: $(APP_OUT)
4242

43-
tinflate.o: $(UZLIB_PATH)/tinflate.c $(UZLIB_PATH)/uzlib.h $(UZLIB_PATH)/uzlib_conf.h
43+
tinflate.o: $(UZLIB_PATH)/tinflate.c $(UZLIB_PATH)/uzlib.h $(UZLIB_PATH)/uzlib_conf.h Makefile
4444
$(CC) $(CFLAGS) -c -o tinflate.o $(UZLIB_PATH)/tinflate.c
4545

46-
tinfgzip.o: $(UZLIB_PATH)/tinfgzip.c $(UZLIB_PATH)/uzlib.h $(UZLIB_PATH)/uzlib_conf.h
46+
tinfgzip.o: $(UZLIB_PATH)/tinfgzip.c $(UZLIB_PATH)/uzlib.h $(UZLIB_PATH)/uzlib_conf.h Makefile
4747
$(CC) $(CFLAGS) -c -o tinfgzip.o $(UZLIB_PATH)/tinfgzip.c
4848

49-
$(APP_AR): $(TARGET_OBJ_PATHS) tinflate.o tinfgzip.o
49+
$(APP_AR): $(TARGET_OBJ_PATHS) tinflate.o tinfgzip.o Makefile
5050
$(AR) cru $@ $^
5151

5252
$(APP_OUT): $(APP_AR) eboot.ld | Makefile
53-
$(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--whole-archive $(APP_AR) -Wl,--end-group -o $@
53+
$(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--sort-common $(APP_AR) -Wl,--end-group -o $@
5454

5555
clean:
5656
rm -f *.o

bootloaders/eboot/eboot.c

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,19 @@
1414
#include "eboot_command.h"
1515
#include <uzlib.h>
1616

17-
extern unsigned char _gzip_dict;
1817

1918
#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);
2019

2120
extern void ets_wdt_enable(void);
2221
extern void ets_wdt_disable(void);
2322

24-
// Converts bit of a string into a uint32
25-
#define S(a,b,c,d) ( (((uint32_t)a) & 0xff) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | (((uint32_t)d)<<24) )
26-
2723
int print_version(const uint32_t flash_addr)
2824
{
2925
uint32_t ver;
3026
if (SPIRead(flash_addr + APP_START_OFFSET + sizeof(image_header_t) + sizeof(section_header_t), &ver, sizeof(ver))) {
3127
return 1;
3228
}
33-
// We don't have BSS and can't print from flash, so build up string
34-
// 4 chars at a time. Smaller code than byte-wise assignment.
35-
uint32_t fmt[2];
36-
fmt[0] = S('v', '%', '0', '8');
37-
fmt[1] = S('x', '\n', 0, 0);
38-
ets_printf((const char*) fmt, ver);
29+
ets_printf("v%08x\n", ver);
3930
return 0;
4031
}
4132

@@ -68,7 +59,9 @@ int load_app_from_flash_raw(const uint32_t flash_addr)
6859
load = true;
6960
}
7061

71-
if (address >= 0x40100000 && address < 0x40108000) {
62+
// The final IRAM size, once boot has completed, can be either 32K or 48K.
63+
// Allow for the higher in range testing.
64+
if (address >= 0x40100000 && address < 0x4010C000) {
7265
load = true;
7366
}
7467

@@ -220,6 +213,16 @@ int main()
220213
bool clear_cmd = false;
221214
struct eboot_command cmd;
222215

216+
// BSS init commented out for now to save space. If any static variables set
217+
// to 0 are used, need to uncomment it or else the BSS will not be cleared and
218+
// the static vars will power on with random values.
219+
#if 0
220+
// Clear BSS ourselves, we don't have handy C runtime
221+
extern char _bss_start;
222+
extern char _bss_end;
223+
ets_bzero(&_bss_start, &_bss_end - &_bss_start);
224+
#endif
225+
223226
print_version(0);
224227

225228
if (eboot_command_read(&cmd) == 0) {
@@ -234,32 +237,26 @@ int main()
234237
}
235238

236239
if (cmd.action == ACTION_COPY_RAW) {
237-
uint32_t cp = S('c', 'p', ':', 0);
238-
ets_printf((const char *)&cp);
240+
ets_printf("cp:");
239241

240242
ets_wdt_disable();
241243
res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2], false);
242244
ets_wdt_enable();
243245

244-
cp = S('0' + res, '\n', 0, 0 );
245-
ets_printf((const char *)&cp);
246+
ets_printf("%d\n", res);
246247
#if 0
247248
//devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
248249
//beginning of the image in the empty area, see #7458. Disabling for now.
249250
//TODO: replace the below verify with hash type, crc, or similar.
250251
// Verify the copy
251-
uint32_t v[2];
252-
v[0] = S('c', 'm', 'p', ':');
253-
v[1] = 0;
254-
ets_printf(const char *)v);
252+
ets_printf("cmp:");
255253
if (res == 0) {
256254
ets_wdt_disable();
257255
res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2], true);
258256
ets_wdt_enable();
259257
}
260258

261-
cp = S('0' + res, '\n', 0, 0 );
262-
ets_printf((const char *)&cp);
259+
ets_printf("%d\n", res);
263260
#endif
264261
if (res == 0) {
265262
cmd.action = ACTION_LOAD_APP;
@@ -272,13 +269,10 @@ int main()
272269
}
273270

274271
if (cmd.action == ACTION_LOAD_APP) {
275-
ets_putc('l'); ets_putc('d'); ets_putc('\n');
272+
ets_printf("ld\n");
276273
res = load_app_from_flash_raw(cmd.args[0]);
277274
// We will get to this only on load fail
278-
uint32_t e[2];
279-
e[0] = S('e', ':', '0' + res, '\n' );
280-
e[1] = 0;
281-
ets_printf((const char*)e);
275+
ets_printf("e:%d\n", res);
282276
}
283277

284278
if (res) {

bootloaders/eboot/eboot.elf

43.1 KB
Binary file not shown.

bootloaders/eboot/eboot.ld

Lines changed: 24 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -42,53 +42,13 @@ PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
4242
SECTIONS
4343
{
4444

45-
.dport0.rodata : ALIGN(4)
46-
{
47-
_dport0_rodata_start = ABSOLUTE(.);
48-
*(.dport0.rodata)
49-
*(.dport.rodata)
50-
_dport0_rodata_end = ABSOLUTE(.);
51-
} >dport0_0_seg :dport0_0_phdr
52-
53-
.dport0.literal : ALIGN(4)
54-
{
55-
_dport0_literal_start = ABSOLUTE(.);
56-
*(.dport0.literal)
57-
*(.dport.literal)
58-
_dport0_literal_end = ABSOLUTE(.);
59-
} >dport0_0_seg :dport0_0_phdr
60-
61-
.dport0.data : ALIGN(4)
62-
{
63-
_dport0_data_start = ABSOLUTE(.);
64-
*(.dport0.data)
65-
*(.dport.data)
66-
_dport0_data_end = ABSOLUTE(.);
67-
} >dport0_0_seg :dport0_0_phdr
68-
69-
.data : ALIGN(4)
45+
.globals : ALIGN(4)
7046
{
7147
*(COMMON) /* Global vars */
72-
. = ALIGN(4);
73-
_heap_start = ABSOLUTE(.);
74-
/* _stack_sentry = ALIGN(0x8); */
7548
} >dram0_0_seg :dram0_0_bss_phdr
76-
/* __stack = 0x3ffc8000; */
7749

78-
.text : ALIGN(4)
50+
.data : ALIGN(4)
7951
{
80-
_stext = .;
81-
_text_start = ABSOLUTE(.);
82-
*(.entry.text)
83-
*(.init.literal)
84-
*(.init)
85-
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
86-
*(.fini.literal)
87-
*(.fini)
88-
*(.gnu.version)
89-
_text_end = ABSOLUTE(.);
90-
_etext = .;
91-
. = ALIGN (8);
9252
_data_start = ABSOLUTE(.);
9353
*(.data)
9454
*(.data.*)
@@ -102,7 +62,10 @@ SECTIONS
10262
*(.gnu.linkonce.s2.*)
10363
*(.jcr)
10464
_data_end = ABSOLUTE(.);
105-
. = ALIGN (8);
65+
} >dram0_0_seg :dram0_0_bss_phdr
66+
67+
.rodata : ALIGN(4)
68+
{
10669
_rodata_start = ABSOLUTE(.);
10770
*(.rodata)
10871
*(.rodata.*)
@@ -131,14 +94,11 @@ SECTIONS
13194
*(.xt_except_desc_end)
13295
*(.dynamic)
13396
*(.gnu.version_d)
134-
. = ALIGN(4); /* this table MUST be 4-byte aligned */
135-
_bss_table_start = ABSOLUTE(.);
136-
LONG(_bss_start)
137-
LONG(_bss_end)
138-
_bss_table_end = ABSOLUTE(.);
13997
_rodata_end = ABSOLUTE(.);
98+
} >dram0_0_seg :dram0_0_bss_phdr
14099

141-
. = ALIGN (8);
100+
.bss : ALIGN(4)
101+
{
142102
_bss_start = ABSOLUTE(.);
143103
*(.dynsbss)
144104
*(.sbss)
@@ -152,26 +112,24 @@ SECTIONS
152112
*(.bss)
153113
*(.bss.*)
154114
*(.gnu.linkonce.b.*)
155-
. = ALIGN (8);
156115
_bss_end = ABSOLUTE(.);
157-
_free_space = 4096 - 17 - (. - _stext);
158-
/*
159-
The boot loader checksum must be before the CRC, which is written by elf2bin.py.
160-
This leaves 16 bytes after the checksum for the CRC placed at the end of the
161-
4096-byte sector. */
162-
_cs_here = (ALIGN((. + 1), 16) == ALIGN(16)) ? (ALIGN(16) - 1) : (. + 0x0F);
116+
} >dram0_0_seg :dram0_0_bss_phdr
163117

164-
/*
165-
The filling (padding) and values for _crc_size and _crc_val are handled by
166-
elf2bin.py. With this, we give values to the symbols without explicitly
167-
assigning space. This avoids the linkers back *fill* operation that causes
168-
trouble.
169118

170-
The CRC info is stored in last 8 bytes. */
171-
_crc_size = _stext + 4096 - 8;
172-
_crc_val = _stext + 4096 - 4;
173-
ASSERT((4096 > (17 + (. - _stext))), "Error: No space for CS and CRC in bootloader sector.");
174-
ASSERT((_crc_size > _cs_here), "Error: CRC must be located after CS.");
119+
.text : ALIGN(4)
120+
{
121+
_stext = .;
122+
_text_start = ABSOLUTE(.);
123+
*(.entry.text)
124+
*(.init.literal)
125+
*(.init)
126+
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
127+
*(.fini.literal)
128+
*(.fini)
129+
*(.gnu.version)
130+
_text_end = ABSOLUTE(.);
131+
_etext = .;
132+
. = ALIGN (4); /* Ensure 32b alignment since this is written to IRAM */
175133
} >iram1_0_seg :iram1_0_phdr
176134

177135
.lit4 : ALIGN(4)

cores/esp8266/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ int digitalRead(uint8_t pin);
171171
int analogRead(uint8_t pin);
172172
void analogReference(uint8_t mode);
173173
void analogWrite(uint8_t pin, int val);
174+
void analogWriteMode(uint8_t pin, int val, bool openDrain);
174175
void analogWriteFreq(uint32_t freq);
175176
void analogWriteResolution(int res);
176177
void analogWriteRange(uint32_t range);
@@ -225,6 +226,10 @@ void optimistic_yield(uint32_t interval_us);
225226
#include <cstdlib>
226227
#include <cmath>
227228

229+
230+
#include "mmu_iram.h"
231+
232+
228233
using std::min;
229234
using std::max;
230235
using std::round;

cores/esp8266/Esp-frag.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag)
3030
// 100 * (1 - sqrt(sum(hole-size²)) / sum(hole-size))
3131

3232
umm_info(NULL, false);
33-
uint8_t block_size = umm_block_size();
33+
34+
uint32_t free_size = umm_free_heap_size_core(umm_get_current_heap());
3435
if (hfree)
35-
*hfree = ummHeapInfo.freeBlocks * block_size;
36+
*hfree = free_size;
3637
if (hmax)
37-
*hmax = (uint16_t)ummHeapInfo.maxFreeContiguousBlocks * block_size;
38+
*hmax = (uint16_t)umm_max_block_size_core(umm_get_current_heap());
3839
if (hfrag) {
39-
if (ummHeapInfo.freeBlocks) {
40-
*hfrag = 100 - (sqrt32(ummHeapInfo.freeBlocksSquared) * 100) / ummHeapInfo.freeBlocks;
40+
if (free_size) {
41+
*hfrag = umm_fragmentation_metric_core(umm_get_current_heap());
4142
} else {
4243
*hfrag = 0;
4344
}
@@ -46,11 +47,5 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag)
4647

4748
uint8_t EspClass::getHeapFragmentation()
4849
{
49-
#ifdef UMM_INLINE_METRICS
50-
return (uint8_t)umm_fragmentation_metric();
51-
#else
52-
uint8_t hfrag;
53-
getHeapStats(nullptr, nullptr, &hfrag);
54-
return hfrag;
55-
#endif
50+
return (uint8_t)umm_fragmentation_metric();
5651
}

0 commit comments

Comments
 (0)