2025-12-14 17:13:13 +00:00
|
|
|
---
|
|
|
|
|
tags:
|
|
|
|
|
- micro-controllers
|
|
|
|
|
- C
|
|
|
|
|
- ESP32
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
> The ESP-IDF is the SDK, provided by Expressif, for programming the ESP32 with
|
|
|
|
|
> C and C++.
|
|
|
|
|
|
|
|
|
|
> Ensure you are a member of the `uucp` group so that you have serial access,
|
|
|
|
|
> using `usermod -a -G uucp $USER`
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
yay -Sy esp-idf
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Pre-requisites:
|
|
|
|
|
|
2025-12-14 17:14:21 +00:00
|
|
|
```txt
|
2025-12-14 17:13:13 +00:00
|
|
|
To use ESP-IDF:
|
|
|
|
|
|
|
|
|
|
1. Run /opt/esp-idf/install.sh to install ESP-IDF to ~/.espressif.
|
|
|
|
|
You only have to do this once after installing or upgrading
|
|
|
|
|
the esp-idf package.
|
|
|
|
|
|
|
|
|
|
2. Run `source /opt/esp-idf/export.sh` to add idf.py and idf_tools.py
|
|
|
|
|
to your current PATH. You will have to do this in every terminal
|
|
|
|
|
where you want to use ESP-IDF. Alternatively, you can add
|
|
|
|
|
"source /opt/esp-idf/export.sh" to ~/.bashrc or the equivalent for
|
|
|
|
|
your shell to load ESP-IDF automatically in all terminals.
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Must run
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
. /opt/esp-idf/export.sh
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
In any terminal where you want to compile to the device.
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2025-12-15 19:32:39 +00:00
|
|
|
## Compilation/flashing process
|
2025-12-14 17:13:13 +00:00
|
|
|
|
|
|
|
|
To demonstrate compilation, I have copied one of the demo projects provided:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cp -r /opt/esp-idf/examples/get-started/hello_world .
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-15 19:34:26 +00:00
|
|
|
### Initialise the project
|
|
|
|
|
|
2025-12-14 17:13:13 +00:00
|
|
|
To initialise the project, run:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
idf.py set-target esp32
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> Python is used as the client for automated processes/bootstrapping etc, even
|
|
|
|
|
> though the code that runs on the device is written in C.
|
2025-12-15 19:34:26 +00:00
|
|
|
|
|
|
|
|
### Check ESP32 is registered as connected to computer you are programming on
|
|
|
|
|
|
|
|
|
|
Check that ESP32 is registered as connected (after plugging in);
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
lsusb
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Current device listed as `ID 10c4:ea60 Silicon Labs CP210x UART Bridge`
|
|
|
|
|
|
|
|
|
|
> `Silicon Labs CP210x` is the USB-to-serial chip on the ESP32 board
|
|
|
|
|
|
|
|
|
|
Then run:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
ls /dev/ttyUSB*
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
It should return something like:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
crw-rw---- 1 root uucp 188, 0 Dec 15 17:57 /dev/ttyUSB0
|
|
|
|
|
```
|