ESP-IDF#
- Template: lf-esp-idf-uc-template
- ESP-IDF Documentation: docs.espressif.com
- Supported Boards: ESP32, ESP32-C3, ESP32-C6, ESP32-S2, ESP32-S3, ESP32-H2
Prerequisites#
In addition to the common prerequisites:
- Python 3.8+
- CMake 3.20+
- Ninja build system
Setup#
Clone and initialize submodules:
git clone https://github.com/lf-lang/lf-esp-idf-uc-template.git my-project
cd my-project
git submodule update --init --recursive
Option A: Using Nix (Recommended)#
Option B: Manual Setup#
Source export.sh in each new terminal:
Building#
Set the target board and configure:
export ESP_BOARD=esp32c6
cmake -Bbuild \
-DESP_IDF_BOARD=$ESP_BOARD \
-DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-$ESP_BOARD.cmake \
-GNinja
Build:
Flashing#
Or specify the port:
Flash and monitor:
Press Ctrl+] to exit the monitor.
Changing the Application#
cmake -Bbuild \
-DLF_MAIN=Timer \
-DLOG_LEVEL=LF_LOG_LEVEL_DEBUG \
-DESP_IDF_BOARD=$ESP_BOARD \
-DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-$ESP_BOARD.cmake \
-GNinja
Build Parameters#
| Parameter | Description |
|---|---|
LF_MAIN | LF file to compile (default: HelloEsp) |
LOG_LEVEL | LF_LOG_LEVEL_ERROR, WARN, INFO, DEBUG |
ESP_IDF_BOARD | esp32, esp32c3, esp32c6, esp32s2, esp32s3, esp32h2 |
Cleaning#
Example Applications#
- HelloEsp - Serial console output
- Timer - Periodic timer events
- Blink - LED toggle