Skip to content

Commit d4b1c56

Browse files
committed
Merge pull request #1481 from petermm/docs-perf-power
Docs: ESP32 Performance & Power Docs for changing performance/power menuconfig on Esp32. These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents a00098a + aa5179a commit d4b1c56

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

doc/src/build-instructions.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,63 @@ $ pytest --embedded-services=idf,qemu -s
315315

316316
ESP32 tests are erlang modules located in `src/platforms/esp32/test/main/test_erl_sources/` and executed from `src/platforms/esp32/test/main/test_main.c`.
317317

318+
### Performance and Power
319+
320+
AtomVM comes with conservative defaults for broad compatibility with different ESP32 boards, and a reasonable performance/power/longevity tradeoff.
321+
322+
You may want to change these settings to optimize for your specific application's performance and power needs.
323+
324+
Factors like heat dissipation should also be considered, and the effect on overall longevity of components.
325+
326+
#### CPU frequency
327+
328+
Use `idf.py menuconfig` in `src/platforms/esp32`
329+
`Component config ---> ESP System Settings ---> CPU frequency (160 MHz) --->`
330+
331+
You can increase or decrease the CPU frequency, this is a tradeoff against power usage.
332+
Eg. 160 MHz is the conservative default for the ESP32, but you can increase it to 240 MHz or decrease it to 80 MHz. The higher the frequency, the more power is consumed. The lower the frequency, the less power is consumed.
333+
334+
#### Flash mode and speed
335+
336+
Use `idf.py menuconfig` in `src/platforms/esp32`
337+
`Serial flasher config ---> Flash SPI mode (DIO) --->`
338+
You can change the mode of the SPI flash. QIO is the fastest mode, but not all flash chips support it.
339+
340+
`Serial flasher config ---> Flash SPI speed (40 MHz) --->`
341+
You can change the speed of the SPI flash. The higher the speed, the faster the flash will be, at the cost of higher power usage, but not all flash chips support higher speeds.
342+
343+
See external docs: [ESP-IDF flash modes](https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/spi-flash-modes.html)
344+
345+
#### PSRAM speed
346+
347+
Use `idf.py menuconfig` in `src/platforms/esp32`
348+
`Component config ---> ESP PSRAM ---> SPI RAM config --->`
349+
350+
If your board has PSRAM and it's enabled, you can configure the SPI RAM settings here.
351+
`Set RAM clock speed (40MHz clock speed) --->`
352+
You can increase or decrease the clock speed of the PSRAM.
353+
354+
```{warning}
355+
You may have to increase "Flash SPI speed" (see above) before you can increase PSRAM speed.
356+
```
357+
358+
The higher the speed, the faster the PSRAM will be, at the cost of higher power usage, but not all PSRAM chips support higher speeds.
359+
360+
#### Sleep mode - Deep sleep
361+
362+
For low power applications, you should use the [deep sleep functionality](./programmers-guide.md#restart-and-deep-sleep) of the ESP32.
363+
364+
This will put the ESP32 into a very low power state, and it will consume very little power.
365+
You can wake the ESP32 from deep sleep using a timer, or an interrupt etc.
366+
367+
Make sure your board is suitable for low power deep sleep, some boards have voltage regulators and/or LEDs constantly draining power, also make sure sensors are powered down or in low power mode when the ESP32 is in deep sleep.
368+
369+
For persisting small amounts of data during deep sleep, you can use the [RTC memory](./programmers-guide.md#rtc-memory) of the ESP32, which is preserved during deep sleep.
370+
371+
#### Sleep mode - Light sleep
372+
373+
Usage of light sleep is untested, and no support for controlling light sleep is currently implemented. Reach out if you do any experiments and measurements.
374+
318375
### Flash Layout
319376

320377
The AtomVM Flash memory is partitioned to include areas for the above binary artifacts created from the build, as well areas for runtime information used by the ESP32 and compiled Erlang/Elixir code.

0 commit comments

Comments
 (0)