This guide will teach you how to use Docker containers to develop, compile, upload, and debug ESP-IDF projects. Docker containers are isolated environments that run different software and tools without affecting your host system. They are helpful for cross-platform development and testing.
Software ComponentsHardware ComponentsDev container is a feature of Visual Studio Code that allows developers to create and run a development environment inside a Docker container. This can be useful for developing applications for ESP32 and other Espressif chips, as you can easily switch between different versions of ESP-IDF and its tools without affecting your host system.
By the end of this tutorial, you will be able to use dev container in ESP-IDF projects with ease and efficiency.
Let’s get started!
Local Project Creation (Optional)In this section, we will go through the steps of creating an example project using the ESP-IDF extension for Visual Studio Code.
- Install ESP-IDF VS Code Extension
https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md
In this step, please select ESP-IDF version 5.1> to support the ESP32-C6 target.
- Press F1 and type ESP-IDF: Show Examples Projects
- Select the place where you have installed ESP-IDF SDK.
- Let's select the Blink example project
Now your basic blink project was created and it's ready to be configured!
- Configure the LED GPIO using idf.py menuconfig command.
- Open the "Example Configuration" and configure the GPIO for Blink as GPIO8.
- Build your project!
- Flash to your board.
Select the COM port attached to your board and confirm it.
Press F1 and select the ESP-IDF: Flash you project option
Let's compile this project in a Docker container that has all the necessary tools to build our project.
- Add Docker Container Configuration to the project
- Reopen the folder in Container
- Fix your compiler path
Probably, the compiler path will be completed by the compiler path of your local machine, please change it to the right place at the container.
- Fix the "PROJECT_VER" issue on top level CmakeList
- Clean the project
- Compile
- Flash
There are ways to bind the board connected to your host machine to the container. Here you will check how to use the TELNET protocol to access the device communication port to flash and monitor.
Download the latest version of esp-tools on your host:
https://github.com/espressif/esptool/releases/download/v4.6.2/esptool-v4.6.2-win64.zip
Extract it, go the the extracted folder, and type:
esp_rfc2217_server -v -p 4000 COM3
"COM3" is an example, please insert the correct COM of the board connected to your machine.
Open the "setting.json" file on the container in Visual Studio Code and edit the "idf.port" configuration attribute.
Click on the flash button or select the "ESP-IDF: Flash your project" option.
- Monitor
Once the "idf.port" option was configured, all you need to do in this step is to click on "ESP-DF Monitor device button" or select the "ESP-IDF: Monitor your Device" option.
All done!
Now you can build your projects on Docker container, flash, and monitor the board connected to your host machine!
Comments
Please log in or sign up to comment.