Skip to content

Commit 7994b18

Browse files
committed
Merge remote-tracking branch 'origin/master' into buildopts/refactoring
2 parents 69982cc + 8126849 commit 7994b18

18 files changed

+566
-393
lines changed

.github/workflows/build-platformio.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
ESP8266_ARDUINO_BUILDER: "platformio"
3737
run: |
3838
pip install -U platformio
39-
env ESP8266_ARDUINO_SKETCHES="$(find libraries/ -name '*.ino' | shuf -n 10 -)" bash ./tests/build.sh
39+
env ESP8266_ARDUINO_SKETCHES="$(find libraries/ -name '*.ino' | grep -e libraries/esp8266/examples -e SoftwareSerial)" bash ./tests/build.sh

.gitignore

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
.DS_Store
2-
tools/dist/
3-
tools/xtensa-lx106-elf/
4-
tools/mkspiffs/
5-
tools/mklittlefs/
6-
tools/python3/
7-
package/versions/
8-
exclude.txt
92

10-
tests/hosts/lcov/
3+
*.orig
114

12-
*.pyc
135
*.gch
6+
*.pyc
147

15-
boards.local.txt
16-
17-
*.gcov
18-
*.gcno
198
*.gcda
20-
*.o
9+
*.gcno
10+
*.gcov
2111
*.a
12+
*.o
13+
14+
#created by user/scripts
15+
cores/esp8266/CommonHFile.h
16+
tests/host/lcov/
17+
tools/sdk/ld/backup/
18+
*.local.txt
19+
.cache
20+
compile_commands.json
21+
22+
#dist
23+
tools/dist/
24+
tools/mklittlefs/
25+
tools/mkspiffs/
26+
tools/python3/
27+
tools/xtensa-lx106-elf/
28+
package/versions/
29+
exclude.txt
2230

2331
#Ignore files built by Visual Studio/Visual Micro
2432
[Dd]ebug*/

boards.txt

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

cores/esp8266/StackThunk.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void stack_thunk_add_ref()
7373
}
7474
stack_thunk_top = stack_thunk_ptr + _stackSize - 1;
7575
stack_thunk_save = NULL;
76+
stack_thunk_yield_save = NULL;
7677
stack_thunk_repaint();
7778
}
7879
}
@@ -90,6 +91,7 @@ void stack_thunk_del_ref()
9091
stack_thunk_ptr = NULL;
9192
stack_thunk_top = NULL;
9293
stack_thunk_save = NULL;
94+
stack_thunk_yield_save = NULL;
9395
}
9496
}
9597

@@ -175,15 +177,18 @@ asm(
175177
"movi a2, stack_thunk_yield_save\n\t"
176178
"s32i.n a1, a2, 0\n\t"
177179
"movi a2, stack_thunk_save\n\t"
180+
/* But, only when inside of bssl stack (saved a1 != 0) */
181+
"l32i.n a3, a2, 0\n\t"
182+
"beqz a3, stack_thunk_yield_do_yield\n\t"
178183
"l32i.n a1, a2, 0\n\t"
179184
/* optimistic_yield(10000) without extra l32r */
185+
"stack_thunk_yield_do_yield:\n\t"
180186
"movi a2, 0x10\n\t"
181187
"addmi a2, a2, 0x2700\n\t"
182188
"call0 optimistic_yield\n\t"
183189
/* Swap bearssl <-> cont stacks, again */
184190
"movi a2, stack_thunk_yield_save\n\t"
185191
"l32i.n a1, a2, 0\n\t"
186-
"\n"
187192
/* Restore caller */
188193
"l32i.n a0, a1, 12\n\t"
189194
"addi a1, a1, 16\n\t"

cores/esp8266/StackThunk.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#ifndef _STACKTHUNK_H
2828
#define _STACKTHUNK_H
2929

30+
#include <stdint.h>
31+
3032
#ifdef __cplusplus
3133
extern "C" {
3234
#endif
@@ -80,9 +82,11 @@ thunk_"#fcnToThunk":\n\
8082
call0 stack_thunk_fatal_smashing\n\
8183
.L1"#fcnToThunk":\n\
8284
movi a15, stack_thunk_save /* Restore A1(SP) */\n\
83-
l32i.n a1, a15, 0\n\
84-
l32i.n a15, a1, 8 /* Restore the saved registers */\n\
85-
l32i.n a0, a1, 12\n\
85+
l32i.n a1, a15, 0/* Restore A1(SP) */\n\
86+
movi a0, 0 /* Purge temporary storage */\n\
87+
s32i.n a0, a15, 0\n\
88+
l32i.n a15, a1, 8/* Restore A15 */\n\
89+
l32i.n a0, a1, 12/* Restore A0 */\n\
8690
addi a1, a1, 16 /* Free up stack and return to caller */\n\
8791
ret\n\
8892
.size thunk_"#fcnToThunk", . - thunk_"#fcnToThunk"\n");

doc/boards.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ ESPresso Lite 2.0
271271

272272
ESPresso Lite 2.0 is an Arduino-compatible Wi-Fi development board based on an earlier V1 (beta version). Re-designed together with Cytron Technologies, the newly-revised ESPresso Lite V2.0 features the auto-load/auto-program function, eliminating the previous need to reset the board manually before flashing a new program. It also feature two user programmable side buttons and a reset button. The special distinctive features of on-board pads for I2C sensor and actuator is retained.
273273

274-
Mercury 1.0
275-
-----------
276-
277-
Based on ESP8266, Mercury is board developed by Ralio Technologies. Board supports on motor drivers and direct-connect feature for various endpoints.
274+
Mercury
275+
-------
278276

277+
ESP8266 based development board supercharged with onboard motor driver, RGB LED, support for servo motors and etc.
278+
Git: https://github.com/raliotech/products/tree/master
279279
Product page: https://www.raliotech.com
280280

281281
Phoenix 1.0

doc/faq/readme.rst renamed to doc/faq.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Please feel free to contribute if you believe that some frequent issues
1313
are not covered below.
1414

1515

16-
I am getting "espcomm\_sync failed" error when trying to upload my ESP. How to resolve this issue?
17-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
I am getting "espcomm\_sync failed", "esptool.FatalError", etc. How to resolve this issue?
17+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1818

1919
This message indicates issue with uploading ESP module over a serial
2020
connection. There are couple of possible causes, that depend on the type
2121
of your module, if you use separate USB to serial converter.
2222

23-
`Read more <a01-espcomm_sync-failed.rst>`__.
23+
`Read more <faq/a01-upload-failed.rst>`__.
2424

2525
Why esptool is not listed in "Programmer" menu? How do I upload ESP without it?
2626
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -38,7 +38,7 @@ My ESP crashes running some code. How to troubleshoot it?
3838
The code may crash because of s/w bug or issue with your h/w. Before
3939
entering an issue report, please perform initial troubleshooting.
4040

41-
`Read more <a02-my-esp-crashes.rst>`__.
41+
`Read more <faq/a02-my-esp-crashes.rst>`__.
4242

4343
How can I get some extra KBs in flash ?
4444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -50,7 +50,7 @@ How can I get some extra KBs in flash ?
5050

5151
* Use the debug level option ``NoAssert-NDEBUG`` (in the Tools menu)
5252

53-
`Read more <a05-board-generator.rst>`__.
53+
`Read more <faq/a05-board-generator.rst>`__.
5454

5555
About WPS
5656
~~~~~~~~~
@@ -63,7 +63,7 @@ required to enable it:
6363

6464
``./tools/boards.txt.py --allowWPS --boardsgen``
6565

66-
`Read more <a05-board-generator.rst>`__.
66+
`Read more <faq/a05-board-generator.rst>`__.
6767

6868
For platformIO (and maybe other build environments), you will also need to add the build flag: -D NO_EXTRA_4K_HEAP
6969

@@ -77,7 +77,7 @@ This Arduino library doesn't work on ESP. How do I make it work?
7777
You would like to use this Arduino library with ESP8266 and it does not
7878
perform. It is not listed among libraries verified to work with ESP8266.
7979

80-
`Read more <a03-library-does-not-work.rst>`__.
80+
`Read more <faq/a03-library-does-not-work.rst>`__.
8181

8282
In the IDE, for ESP-12E that has 4M flash, I can choose 4M (1M FS) or 4M (3M FS). No matter what I select, the IDE tells me the maximum code space is about 1M. Where does my flash go?
8383
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -118,7 +118,7 @@ This error may pop up after switching between
118118
`staging <https://github.com/esp8266/Arduino#staging-version->`__ and
119119
`stable <https://github.com/esp8266/Arduino#stable-version->`__ esp8266
120120
/ Arduino package installations, or after upgrading the package version
121-
`Read more <a04-board-generic-is-unknown.rst>`__.
121+
`Read more <faq/a04-board-generic-is-unknown.rst>`__.
122122

123123

124124
How to clear TCP PCBs in time-wait state ?
@@ -199,4 +199,4 @@ By using a uniquely named `.h` file, macro definitions can be created and
199199
globally used. Additionally, compiler command-line options can be embedded in
200200
this file as a unique block comment.
201201

202-
`Read more <../global_build_options>`__.
202+
`Read more <../global_build_options.rst>`__.

doc/faq/a01-espcomm_sync-failed.rst renamed to doc/faq/a01-upload-failed.rst

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
:orphan:
2-
3-
I am getting "espcomm\_sync failed" error when trying to upload my ESP. How to resolve this issue?
4-
--------------------------------------------------------------------------------------------------
1+
Why I am getting errors when trying to upload to my ESP?
2+
--------------------------------------------------------
53

64
- `Introduction <#introduction>`__
75
- `Initial Checks <#initial-checks>`__
@@ -15,14 +13,24 @@ I am getting "espcomm\_sync failed" error when trying to upload my ESP. How to r
1513
Introduction
1614
~~~~~~~~~~~~
1715

18-
This message indicates issue with uploading ESP module over a serial
16+
Messages like
17+
18+
* ``espcomm_sync failed``
19+
20+
* ``esptool.FatalError: Failed to connect to ESP8266: Invalid head of packet (0xF0)``
21+
22+
* ``esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header``
23+
24+
indicate issue with with uploading ESP module over a serial
1925
connection. There are couple of possible causes, that depend on the type
2026
of module, if you use separate USB to serial converter, what parameters
2127
are selected for upload, etc. As result there is no single answer on the
2228
root cause. To find it out you may need to complete couple of
2329
troubleshooting steps.
2430

25-
Note: If you are just starting with ESP, to reduce potential issues
31+
.. note::
32+
33+
If you are just starting with ESP, to reduce potential issues
2634
with uploading, select ESP board with integrated USB to serial
2735
converter. This will considerably reduce number of user depended
2836
factors or configuration settings that influence upload process.
@@ -167,7 +175,93 @@ loading <../boards.rst#minimal-hardware-setup-for-bootloading-only>`__
167175
during: upload* and try uploading again. For successful upload this
168176
log should look similar to example shown below:
169177

170-
``C:\Users\Krzysztof\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.8/esptool.exe -vv -cd ck -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\KRZYSZ~1\AppData\Local\Temp\build7e44b372385012e74d64fb272d24b802.tmp/Blink.ino.bin esptool v0.4.8 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de> setting board to ck setting baudrate from 115200 to 115200 setting port from COM1 to COM3 setting address from 0x00000000 to 0x00000000 espcomm_upload_file espcomm_upload_mem setting serial port timeouts to 1000 ms opening bootloader resetting board trying to connect flush start setting serial port timeouts to 1 ms setting serial port timeouts to 1000 ms flush complete espcomm_send_command: sending command header espcomm_send_command: sending command payload read 0, requested 1 trying to connect flush start setting serial port timeouts to 1 ms setting serial port timeouts to 1000 ms flush complete espcomm_send_command: sending command header espcomm_send_command: sending command payload espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data espcomm_send_command: receiving 2 bytes of data Uploading 226368 bytes from to flash at 0x00000000 erasing flash size: 037440 address: 000000 first_sector_index: 0 total_sector_count: 56 head_sector_count: 16 adjusted_sector_count: 40 erase_size: 028000 espcomm_send_command: sending command header espcomm_send_command: sending command payload setting serial port timeouts to 15000 ms setting serial port timeouts to 1000 ms espcomm_send_command: receiving 2 bytes of data writing flash .............................................................................................................................................................................................................................. starting app without reboot espcomm_send_command: sending command header espcomm_send_command: sending command payload espcomm_send_command: receiving 2 bytes of data closing bootloader flush start setting serial port timeouts to 1 ms setting serial port timeouts to 1000 ms flush complete``
178+
For example, uploading using esptool.py and esptool
179+
180+
.. code-block:: console
181+
182+
$ esptool.py --after no_reset --chip esp8266 --baud 460800 write_flash 0x0 d1-mini-firmware.bin
183+
esptool.py v4.5.1
184+
Found 1 serial ports
185+
Serial port /dev/ttyUSB0
186+
Connecting....
187+
Chip is ESP8266EX
188+
Features: WiFi
189+
Crystal is 26MHz
190+
MAC: 11:22:33:44:55:66
191+
Uploading stub...
192+
Running stub...
193+
Stub running...
194+
Changing baud rate to 460800
195+
Changed.
196+
Configuring flash size...
197+
Flash will be erased from 0x00000000 to 0x0004efff...
198+
Compressed 321440 bytes to 221714...
199+
Wrote 321440 bytes (221714 compressed) at 0x00000000 in 5.0 seconds (effective 511.4 kbit/s)...
200+
Hash of data verified.
201+
202+
Leaving...
203+
Staying in bootloader.
204+
205+
206+
.. code-block:: console
207+
208+
> C:\Users\Krzysztof\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.8/esptool.exe -vv -cd ck -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\KRZYSZ~1\AppData\Local\Temp\build7e44b372385012e74d64fb272d24b802.tmp/Blink.ino.bin
209+
esptool v0.4.8 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
210+
setting board to ck
211+
setting baudrate from 115200 to 115200
212+
setting port from COM1 to COM3
213+
setting address from 0x00000000 to 0x00000000
214+
espcomm_upload_file
215+
espcomm_upload_mem
216+
setting serial port timeouts to 1000 ms
217+
opening bootloader
218+
resetting board
219+
trying to connect
220+
flush start
221+
setting serial port timeouts to 1 ms
222+
setting serial port timeouts to 1000 ms
223+
flush complete
224+
espcomm_send_command: sending command header
225+
espcomm_send_command: sending command payload
226+
read 0, requested 1
227+
trying to connect
228+
flush start
229+
setting serial port timeouts to 1 ms
230+
setting serial port timeouts to 1000 ms
231+
flush complete
232+
espcomm_send_command: sending command header
233+
espcomm_send_command: sending command payload
234+
espcomm_send_command: receiving 2 bytes of data
235+
espcomm_send_command: receiving 2 bytes of data
236+
espcomm_send_command: receiving 2 bytes of data
237+
espcomm_send_command: receiving 2 bytes of data
238+
espcomm_send_command: receiving 2 bytes of data
239+
espcomm_send_command: receiving 2 bytes of data
240+
espcomm_send_command: receiving 2 bytes of data
241+
espcomm_send_command: receiving 2 bytes of data
242+
Uploading 226368 bytes from to flash at 0x00000000
243+
erasing flash
244+
size: 037440 address: 000000
245+
first_sector_index: 0
246+
total_sector_count: 56
247+
head_sector_count: 16
248+
adjusted_sector_count: 40
249+
erase_size: 028000
250+
espcomm_send_command: sending command header
251+
espcomm_send_command: sending command payload
252+
setting serial port timeouts to 15000 ms
253+
setting serial port timeouts to 1000 ms
254+
espcomm_send_command: receiving 2 bytes of data
255+
writing flash ..............................................................................................................................................................................................................................
256+
starting app without reboot
257+
espcomm_send_command: sending command header
258+
espcomm_send_command: sending command payload
259+
espcomm_send_command: receiving 2 bytes of data
260+
closing bootloader
261+
flush start
262+
setting serial port timeouts to 1 ms
263+
setting serial port timeouts to 1000 ms
264+
flush complete
171265
172266
Upload log may be longer depending on number of connection attempts made
173267
by esptool. Analyze it for any anomalies to configuration you have
@@ -177,7 +271,7 @@ rate, etc. Resolve all noted differences.
177271
Reset Methods
178272
~~~~~~~~~~~~~
179273

180-
If you got to this point and still see ``espcomm_sync failed``, then now
274+
If you got to this point and still see uploading error, then now
181275
you need to bring in the heavy guns.
182276

183277
Connect scope or logic analyzer to GPIO0, RST and RXD pins of the ESP to
@@ -238,13 +332,13 @@ Each retry is reported in upload log as follows:
238332

239333
resetting board
240334
trying to connect
241-
flush start
242-
setting serial port timeouts to 1 ms
243-
setting serial port timeouts to 1000 ms
244-
flush complete
245-
espcomm_send_command: sending command header
246-
espcomm_send_command: sending command payload
247-
read 0, requested 1
335+
flush start
336+
setting serial port timeouts to 1 ms
337+
setting serial port timeouts to 1000 ms
338+
flush complete
339+
espcomm_send_command: sending command header
340+
espcomm_send_command: sending command payload
341+
read 0, requested 1
248342

249343
Presented circuit has one important limitation when it comes to work
250344
with Arduino IDE. After opening Serial Monitor (Ctrl-Shift-M), both RTS

doc/faq/a02-my-esp-crashes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:orphan:
2-
31
My ESP crashes running some code. How to troubleshoot it?
42
---------------------------------------------------------
53

doc/faq/a03-library-does-not-work.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:orphan:
2-
31
This Arduino library doesn't work on ESP. How do I make it working?
42
-------------------------------------------------------------------
53

doc/faq/a04-board-generic-is-unknown.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:orphan:
2-
31
How to resolve "Board generic (platform esp8266, package esp8266) is unknown" error?
42
------------------------------------------------------------------------------------
53

doc/faq/a05-board-generator.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:orphan:
2-
31
Board generator
42
---------------
53

0 commit comments

Comments
 (0)