Skip to content

Commit

Permalink
Docs: Esp32 Performance & Power
Browse files Browse the repository at this point in the history
Initial docs for changing performance/power params on Esp32.

Signed-off-by: Peter M <[email protected]>
  • Loading branch information
petermm committed Jan 21, 2025
1 parent a00098a commit f122f46
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions doc/src/build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,60 @@ $ pytest --embedded-services=idf,qemu -s

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`.

### Performance and Power

AtomVM comes with conservative defaults for broad compatibility with different ESP32 boards.
You may want to change these settings to optimize for your specific applications performance and power needs.

#### CPU frequency

Use `idf.py menuconfig` in `src/platforms/esp32`
```Component config ---> ESP System Settings ---> CPU frequency (160 MHz) --->```

You can increase or decrease the CPU frequency, this is a tradeoff against power usage.
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.

#### Flash mode and speed

Use `idf.py menuconfig` in `src/platforms/esp32`
```Serial flasher config ---> Flash SPI mode (DIO) --->```
You can change the mode of the SPI flash. QIO is the fastest mode, but not all flash chips support it.

```Serial flasher config ---> Flash SPI speed (40 MHz) --->```
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.

See external docs: [ESP-IDF flash modes](https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/spi-flash-modes.html)

#### PSRAM speed

Use `idf.py menuconfig` in `src/platforms/esp32`
```Component config ---> ESP PSRAM ---> SPI RAM config --->```

If your board has PSRAM and it's enabled, you can configure the SPI RAM settings here.
```Set RAM clock speed (40MHz clock speed) --->```
You can increase or decrease the clock speed of the PSRAM.

```{warning}
You may have to increase "Flash SPI speed" (see above) before you can increase PSRAM speed.
```

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.

#### Sleep mode - Deep sleep

For low power applications, you should use the [deep sleep functionality](./programmers-guide.md#restart-and-deep-sleep) of the ESP32.

This will put the ESP32 into a very low power state, and it will consume very little power.
You can wake the ESP32 from deep sleep using a timer, or an interrupt etc.

Make sure your board is suitable for 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.

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.

#### Sleep mode - Light sleep

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.

### Flash Layout

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.
Expand Down

0 comments on commit f122f46

Please sign in to comment.