Skip to content

Commit 3ab38d6

Browse files
d-a-vdevyte
authored andcommitted
board generator documentation (#4989)
* update "more flash" doc * doc: try to emphasize OOM knowledge * fighting with markdown? * it seems I can't emphasize text in link * board generator doc: need reviewers * markdown formatting, typos * typos * add links * + last memory failure allocation + emphasis exception decoder * more emphasis on exception decoder * repeat the board generator introduction * fixes
1 parent 7d5997d commit 3ab38d6

File tree

3 files changed

+125
-15
lines changed

3 files changed

+125
-15
lines changed

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

+21-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ My ESP crashes running some code. How to troubleshoot it?
99
- `What is the Cause of Restart? <#what-is-the-cause-of-restart>`__
1010
- `Exception <#exception>`__
1111
- `Watchdog <#watchdog>`__
12-
- `Check Where the Code Crashes <#check-where-the-code-crashes>`__
13-
- `Other Causes for Crashes <#other-causes-for-crashes>`__
12+
- `Exception Decoder <#exception-decoder>`__
13+
- `Other Common Causes for Crashes <#other-causes-for-crashes>`__
1414
- `If at the Wall, Enter an Issue
1515
Report <#if-at-the-wall-enter-an-issue-report>`__
1616
- `Conclusion <#conclusion>`__
@@ -161,8 +161,8 @@ out before restart, you should be able to narrow down part of code
161161
firing the h/w wdt reset. If diagnosed application or library has debug
162162
option then switch it on to aid this troubleshooting.
163163

164-
Check Where the Code Crashes
165-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164+
Exception Decoder
165+
~~~~~~~~~~~~~~~~~
166166

167167
Decoding of ESP stack trace is now easy and available to everybody
168168
thanks to great `Arduino ESP8266/ESP32 Exception Stack Trace
@@ -183,21 +183,25 @@ If you don't have any code for troubleshooting, use the example below:
183183
Serial.println();
184184
Serial.println("Let's provoke the s/w wdt firing...");
185185
//
186-
// wait for s/w wdt in infinite loop below
186+
// provoke an OOM, will be recorded as the last occured one
187+
char* out_of_memory_failure = (char*)malloc(1000000);
187188
//
189+
// wait for s/w wdt in infinite loop below
188190
while(true);
189191
//
190192
Serial.println("This line will not ever print out");
191193
}
192194

193195
void loop(){}
194196

195-
Upload this code to your ESP (Ctrl+U) and start Serial Monitor
196-
(Ctrl+Shift+M). You should shortly see ESP restarting every couple of
197-
seconds and ``Soft WDT reset`` message together with stack trace showing
198-
up on each restart. Click the Autoscroll check-box on Serial Monitor to
199-
stop the messages scrolling up. Select and copy the stack trace, go to
200-
the *Tools* and open the *ESP Exception Decoder*.
197+
Enable the Out-Of-Memory (*OOM*) debug option (in the *Tools > Debug Level*
198+
menu), compile/flash/upload this code to your ESP (Ctrl+U) and start Serial
199+
Monitor (Ctrl+Shift+M). You should shortly see ESP restarting every couple
200+
of seconds and ``Soft WDT reset`` message together with stack trace showing
201+
up on each restart. Click the Autoscroll check-box on Serial Monitor to
202+
stop the messages scrolling up. Select and copy the stack trace, including
203+
the ``last failed alloc call: ...`` line, go to the *Tools* and open the
204+
*ESP Exception Decoder*.
201205

202206
.. figure:: pictures/a02-decode-stack-tace-1-2.png
203207
:alt: Decode the stack trace, steps 1 and 2
@@ -263,7 +267,7 @@ Asynchronous Callbacks
263267
can happen.
264268

265269
Memory, memory, memory
266-
Running out of heap is the most common cause for crashes. Because the build process for
270+
Running out of heap is the **most common cause for crashes**. Because the build process for
267271
the ESP leaves out exceptions (they use memory), memory allocations that fail will do
268272
so silently. A typical example is when setting or concatenating a large String. If
269273
allocation has failed internally, then the internal string copy can corrupt data, and
@@ -287,6 +291,11 @@ Memory, memory, memory
287291
rely on exceptions for error handling, which is not available for the ESP, and in any
288292
case there is no access to the underlying code.
289293

294+
Instrumenting the code with the OOM debug option and calls to ``ESP.getFreeHeap()`` will
295+
help the process of finding leaks. Now is time to re-read about the
296+
`exception decoder <#exception-decoder>`__.
297+
298+
290299
*Some techniques for reducing memory usage*
291300

292301
* Don't use const char * with literals. Instead, use const char[] PROGMEM. This is particularly true if you intend to, e.g.: embed html strings.

doc/faq/a05-board-generator.rst

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
:orphan:
2+
3+
Board generator
4+
---------------
5+
6+
The board generator is a python script originally intended to ease the
7+
Arduino IDE's `boards.txt` configuration file about the multitude of
8+
available boards, especially when common parameters have to be updated for
9+
all of them.
10+
11+
This script is also used to manage uncommon options that are currently not
12+
available in the IDE menu.
13+
14+
- `How can I run the script ? <#how-can-i-run-the-script>`__
15+
- `What can I do with it ? <#what-can-i-do-with-it>`__
16+
- `When do I need to update it ? <#when-do-i-need-to-mess-with-it>`__
17+
- `Why is my pull-request failing continuous-integration ? <#why-is-my-pull-request-failing-continuous-integration>`__
18+
19+
How can I run the script ?
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
22+
Python 2 needs to be installed on your system.
23+
24+
The script is located in the ``tools`` subdirectory of the core's root installation.
25+
It needs to be run from the root directory,
26+
27+
::
28+
29+
$ tools/boards.txt.py
30+
31+
::
32+
33+
C:\...> tools\boards.txt.py
34+
C:\...> python tools\boards.txt.py
35+
36+
Running without parameters will show the command line help. They are
37+
generally self-explanatory.
38+
39+
40+
What can I do with it ?
41+
~~~~~~~~~~~~~~~~~~~~~~~
42+
43+
As of today you can:
44+
45+
* in the IDE: change the default serial programming speed of any board
46+
47+
* in the IDE: add new serial programming speed
48+
49+
* increase available flash space by disabling floats in ``*printf`` functions
50+
51+
* enable WPS which is now disabled by default (at the cost of a smaller heap by ~4KB)
52+
53+
* change led pin ``LED_BUILTIN`` for the two generic boards
54+
55+
* change the default lwIP version (1.4 or 2)
56+
57+
58+
When do I need to mess with it ?
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
The board generator is used to automate generation of configuration files
62+
when possible. It needs to be edited for:
63+
64+
* All information for specific boards. This is the only place where a new
65+
board (definition, description) can be updated or added to the existing
66+
list.
67+
68+
* Memory mapping for ldscripts (flash and spiffs size combinations)
69+
70+
71+
Why is my pull-request failing continuous-integration ?
72+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73+
74+
The generator is able to update a number of files (see list in help), and
75+
global coherency can be checked by the continuous integration facilities.
76+
77+
After a modification in the generator, it is **mandatory** to regenerate all
78+
files (option ``--allgen``) and add them in the pull-request.
79+
80+
81+
`FAQ list :back: <readme.rst>`__

doc/faq/readme.rst

+23-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ entering an issue report, please perform initial troubleshooting.
4343
How can I get some extra KBs in flash ?
4444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4545

46-
Using ``*printf()`` with floats is enabled by default. Some KBs of flash can
47-
be saved by using the option ``--nofloat`` with the boards generator:
46+
* Using ``*printf()`` with floats is enabled by default. Some KBs of flash can
47+
be saved by using the option ``--nofloat`` with the boards generator:
4848

49-
``./tools/boards.txt.py --nofloat --allgen``
49+
``./tools/boards.txt.py --nofloat --allgen``
50+
51+
* Use the debug level option ``NoAssert-NDEBUG`` (in the Tools menu)
52+
53+
`Read more <a05-board-generator.rst>`__.
5054

5155
Why can't I use WPS ?
5256
~~~~~~~~~~~~~~~~~~~~~
@@ -56,6 +60,8 @@ WPS (and lose 4KB of useable ram), use this boards generator option:
5660

5761
``./tools/boards.txt.py --allowWPS --allgen``
5862

63+
`Read more <a05-board-generator.rst>`__.
64+
5965
This Arduino library doesn't work on ESP. How do I make it work?
6066
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6167

@@ -139,3 +145,17 @@ The following lines are compatible with both lwIP versions:
139145
}
140146
141147
Ref. `#1923 <https://github.com/esp8266/Arduino/issues/1923>`__
148+
149+
150+
Why is there a board generator and what about it ?
151+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
153+
The board generator is a python script originally intended to ease the
154+
Arduino IDE's `boards.txt` configuration file about the multitude of
155+
available boards, especially when common parameters have to be updated for
156+
all of them.
157+
158+
This script is also used to manage uncommon options that are currently not
159+
available in the IDE menu.
160+
161+
`Read more <a05-board-generator.rst>`__.

0 commit comments

Comments
 (0)