summaryrefslogtreecommitdiff
path: root/docs/library/esp32.rst
diff options
context:
space:
mode:
authorThorsten von Eicken <tve@voneicken.com>2020-03-28 23:00:06 -0700
committerDamien George <damien.p.george@gmail.com>2020-04-23 00:02:11 +1000
commita177831c46a7e217fed6562510e12183377053f7 (patch)
tree5948016216c968238cf89059dae144bd325a06b3 /docs/library/esp32.rst
parent6a1c7ea81598489373ed9e2b84cb300584050ae8 (diff)
esp32/modesp32: Add idf_heap_info(capabilities) to esp32 module.
This commit adds an idf_heap_info(capabilities) method to the esp32 module which returns info about the ESP-IDF heaps. It's useful to get a bit of a picture of what's going on when code fails because ESP-IDF can't allocate memory anymore. Includes documentation and a test.
Diffstat (limited to 'docs/library/esp32.rst')
-rw-r--r--docs/library/esp32.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/library/esp32.rst b/docs/library/esp32.rst
index 5df1f3c93..bfef5a32d 100644
--- a/docs/library/esp32.rst
+++ b/docs/library/esp32.rst
@@ -38,6 +38,30 @@ Functions
Read the raw value of the internal Hall sensor, returning an integer.
+.. function:: idf_heap_info(capabilities)
+
+ Returns information about the ESP-IDF heap memory regions. One of them contains
+ the MicroPython heap and the others are used by ESP-IDF, e.g., for network
+ buffers and other data. This data is useful to get a sense of how much memory
+ is available to ESP-IDF and the networking stack in particular. It may shed
+ some light on situations where ESP-IDF operations fail due to allocation failures.
+ The information returned is *not* useful to troubleshoot Python allocation failures,
+ use `micropython.mem_info()` instead.
+
+ The capabilities parameter corresponds to ESP-IDF's ``MALLOC_CAP_XXX`` values but the
+ two most useful ones are predefined as `esp32.HEAP_DATA` for data heap regions and
+ `esp32.HEAP_EXEC` for executable regions as used by the native code emitter.
+
+ The return value is a list of 4-tuples, where each 4-tuple corresponds to one heap
+ and contains: the total bytes, the free bytes, the largest free block, and
+ the minimum free seen over time.
+
+ Example after booting::
+
+ >>> import esp32; esp32.idf_heap_info(esp32.HEAP_DATA)
+ [(240, 0, 0, 0), (7288, 0, 0, 0), (16648, 4, 4, 4), (79912, 35712, 35512, 35108),
+ (15072, 15036, 15036, 15036), (113840, 0, 0, 0)]
+
Flash partitions
----------------
@@ -88,6 +112,10 @@ Constants
Used in `Partition.find` to specify the partition type.
+.. data:: HEAP_DATA
+ HEAP_EXEC
+
+ Used in `idf_heap_info`.
.. _esp32.RMT: