You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first number after ``Exception`` gives the cause of the reset. a
@@ -57,7 +57,10 @@ the hex after are the stack dump.
57
57
Decode
58
58
~~~~~~
59
59
60
-
It's possible to decode the Stack to readable information. For more info see the `Esp Exception Decoder <https://github.com/me-no-dev/EspExceptionDecoder>`__ tool.
60
+
It's possible to decode the Stack to readable information.
61
+
You can get a copy and read about the `Esp Exception Decoder <https://github.com/me-no-dev/EspExceptionDecoder>`__ tool.
62
+
63
+
For a troubleshooting example using the Exception Decoder Tool, read `FAQ: My ESP Crashes <../faq/a02-my-esp-crashes.rst#exception-decoder>`__.
By default, all functions are compiled into flash, which means that the
285
-
cache may kick in for that code. However, the cache currently can't be used
286
-
during hardware interrupts. That means that, if you use a hardware ISR, such as
287
-
attachInterrupt(gpio, myISR, CHANGE) for a GPIO change, the ISR must have the
288
-
IRAM_ATTR attribute declared. Not only that, but the entire function tree
347
+
By default, all functions are compiled into flash, which means that the
348
+
cache may kick in for that code. However, the cache currently can't be used
349
+
during hardware interrupts. That means that, if you use a hardware ISR, such as
350
+
attachInterrupt(gpio, myISR, CHANGE) for a GPIO change, the ISR must have the
351
+
IRAM_ATTR attribute declared. Not only that, but the entire function tree
289
352
called from the ISR must also have the IRAM_ATTR declared.
290
353
Be aware that every function that has this attribute reduces available memory.
291
354
292
-
In addition, it is not possible to execute delay() or yield() from an ISR,
355
+
In addition, it is not possible to execute delay() or yield() from an ISR,
293
356
or do blocking operations, or operations that disable the interrupts, e.g.: read
294
357
a DHT.
295
358
296
359
Finally, an ISR has very high restrictions on timing for the executed code, meaning
297
-
that executed code should not take longer than a very few microseconds. It is
360
+
that executed code should not take longer than a very few microseconds. It is
298
361
considered best practice to set a flag within the ISR, and then from within the loop()
299
362
check and clear that flag, and execute code.
300
363
@@ -303,16 +366,16 @@ Asynchronous Callbacks
303
366
than ISRs, but some restrictions still apply.
304
367
It is not possible to execute delay() or yield() from an asynchronous callback.
305
368
Timing is not as tight as an ISR, but it should remain below a few milliseconds. This
306
-
is a guideline. The hard timing requirements depend on the WiFi configuration and
369
+
is a guideline. The hard timing requirements depend on the WiFi configuration and
307
370
amount of traffic. In general, the CPU must not be hogged by the user code, as the
308
371
longer it is away from servicing the WiFi stack, the more likely that memory corruption
309
372
can happen.
310
373
311
374
Memory, memory, memory
312
375
Running out of heap is the **most common cause for crashes**. Because the build process for
313
376
the ESP leaves out exceptions (they use memory), memory allocations that fail will do
314
-
so silently. A typical example is when setting or concatenating a large String. If
315
-
allocation has failed internally, then the internal string copy can corrupt data, and
377
+
so silently. A typical example is when setting or concatenating a large String. If
378
+
allocation has failed internally, then the internal string copy can corrupt data, and
316
379
the ESP will crash.
317
380
318
381
In addition, doing many String concatenations in sequence, e.g.: using operator+()
@@ -348,9 +411,9 @@ Memory, memory, memory
348
411
* If you use std libs like std::vector, make sure to call its ::reserve() method before filling it. This allows allocating only once, which reduces mem fragmentation, and makes sure that there are no empty unused slots left over in the container at the end.
349
412
350
413
Stack
351
-
The amount of stack in the ESP is tiny at only 4KB. For normal development in large systems, it
414
+
The amount of stack in the ESP is tiny at only 4KB. For normal development in large systems, it
352
415
is good practice to use and abuse the stack, because it is faster for allocation/deallocation, the scope of the object is well defined, and deallocation automatically happens in reverse order as allocation, which means no mem fragmentation. However, with the tiny amount of stack available in the ESP, that practice is not really viable, at least not for big objects.
353
-
416
+
354
417
* Large objects that have internally managed memory, such as String, std::string, std::vector, etc, are ok on the stack, because they internally allocate their buffers on the heap.
355
418
* Large arrays on the stack, such as uint8_t buffer[2048] should be avoided on the stack and should be dynamically allocated instead (consider smart pointers).
356
419
* Objects that have large data members, such as large arrays, should also be avoided on the stack, and should be dynamically allocated (consider smart pointers).
@@ -392,7 +455,7 @@ or `esp8266 / Arduino <https://github.com/esp8266/Arduino>`__ core,
392
455
types and versions of O/S, you need to provide exact information on what
393
456
your application is about. Only then, people willing to look into your
394
457
issue may be able to compare it to a configuration they are familiar with.
395
-
If you are lucky, they may even attempt to reproduce your issue on their
458
+
If you are lucky, they may even attempt to reproduce your issue on their
396
459
own equipment!
397
460
This will be far more difficult if you provide only vague details,
398
461
so somebody would need to ask you to find out what is really happening.
0 commit comments