当前位置: 首页 > article >正文

ESP IDF docker 使用方法

docker镜像:

https://hub.docker.com/r/espressif/idf

使用方法:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html

IDF Docker Image

IDF Docker image () is intended for building applications and libraries with specific versions of ESP-IDF, when doing automated builds.espressif/idf

The image contains:

  • Common utilities such as git, wget, curl, zip.

  • Python 3.7 or newer.

  • A copy of a specific version of ESP-IDF (see below for information about versions). environment variable is set, and points to ESP-IDF location in the container.IDF_PATH

  • All the build tools required for the specific version of ESP-IDF: CMake, ninja, cross-compiler toolchains, etc.

  • All Python packages required by ESP-IDF are installed in a virtual environment.

The image entrypoint sets up environment variable to point to the correct version of tools, and activates the Python virtual environment. As a result, the environment is ready to use the ESP-IDF build system.PATH

The image can also be used as a base for custom images, if additional utilities are required.

Tags

Multiple tags of this image are maintained:

  • latest: tracks branch of ESP-IDFmaster

  • vX.Y: corresponds to ESP-IDF release vX.Y

  • release-vX.Y: tracks branch of ESP-IDFrelease/vX.Y

Note

Versions of ESP-IDF released before this feature was introduced do not have corresponding Docker image versions. You can check the up-to-date list of available tags at Docker.

Usage

Setting up Docker

Before using the Docker image locally, make sure you have Docker installed. Follow the instructions at Get Docker, if it is not installed yet.espressif/idf

If using the image in CI environment, consult the documentation of your CI service on how to specify the image used for the build process.

Building a project with CMake

In the project directory, run:

docker run --rm -v $PWD:/project -w /project espressif/idf idf.py build 

The above command explained:

  • docker run: runs a Docker image. It is a shorter form of the command .docker container run

  • --rm: removes the container when the build is finished

  • -v $PWD:/project: mounts the current directory on the host () as directory in the container$PWD/project

  • espressif/idf: uses Docker image with tag (implicitly added by Docker when no tag is specified)espressif/idflatest

  • idf.py build: runs this command inside the container

To build with a specific Docker image tag, specify it as , for example:espressif/idf:TAG

docker run --rm -v $PWD:/project -w /project espressif/idf:release-v4.4 idf.py build 

You can check the up-to-date list of available tags at Docker.

Using the image interactively

It is also possible to do builds interactively, to debug build issues or test the automated build scripts. Start the container with -i -t flags:

docker run --rm -v $PWD:/project -w /project -it espressif/idf 

Then inside the container, use as usual:idf.py

idf.py menuconfig idf.py build 

Note

Commands which communicate with the development board, such as and will not work in the container unless the serial port is passed through into the container. This can be done with Docker for Linux with the device option. However currently this is not possible with Docker for Windows (Serial port unavailable under Windows even with --privileged flag · Issue #1018 · docker/for-win · GitHub) and Docker for Mac (Exposing a tty serial device requires privileged and doesn't work · Issue #900 · docker/for-mac · GitHub). This limitation may be overcome by using remote serial ports. An example how to do this can be found in the following using remote serial port section.idf.py flashidf.py monitor

Using remote serial port

The RFC2217 (Telnet) protocol can be used to remotely connect to a serial port. For more information please see the remote serial ports documentation in the esptool project. This method can also be used to access the serial port inside a Docker container if it cannot be accessed directly. Following is an example how to use the flash command from within a Docker container.

On host install and start :esp_rfc2217_server

  • On Windows, package is available as a one-file bundled executable created by pyinstaller and it can be downloaded from the esptool releases page in a zip archive along with other esptool utilities:

    esp_rfc2217_server -v -p 4000 COM3 
  • On Linux/MacOS, package is available as part of esptool which can be found in ESP-IDF environment or by installing using pip:

    pip install esptool 

    And then starting the server by executing:

    esp_rfc2217_server.py -v -p 4000 /dev/ttyUSB0 

Now the device attached to the host can be flashed from inside a Docker container by using:

docker run --rm -v <host_path>:/<container_path> -w /<container_path> espressif/idf idf.py --port rfc2217://host.docker.internal:4000?ign_set_control flash 

Please make sure that is properly set to your project path on the host and is set as a working directory inside the container with the option. The is a special Docker DNS name to access the host. This can be replaced with host IP if necessary.<host_path><container_path>-whost.docker.internal

Building custom images

The Dockerfile in ESP-IDF repository provides several build arguments which can be used to customize the Docker image:

  • IDF_CLONE_URL: URL of the repository to clone ESP-IDF from. Can be set to a custom URL when working with a fork of ESP-IDF. Default is .https://github.com/espressif/esp-idf.git

  • IDF_CLONE_BRANCH_OR_TAG: Name of a git branch or tag use when cloning ESP-IDF. This value is passed to command using the argument. Default is .git clone--branchmaster

  • IDF_CHECKOUT_REF: If this argument is set to a non-empty value, command will be performed after cloning. This argument can be set to the SHA of the specific commit to check out, for example if some specific commit on a release branch is desired.git checkout $IDF_CHECKOUT_REF

  • IDF_CLONE_SHALLOW: If this argument is set to a non-empty value, arguments will be used when performing . This significantly reduces the amount of data downloaded and the size of the resulting Docker image. However, if switching to a different branch in such a “shallow” repository is necessary, an additional command must be executed first.--depth=1 --shallow-submodulesgit clonegit fetch origin <branch>

  • IDF_INSTALL_TARGETS: Comma-separated list of IDF targets to install toolchains for, or to install toolchains for all targets. Selecting specific targets reduces the amount of data downloaded and the size of the resulting Docker image. Default is .allall

To use these arguments, pass them via the command line option. For example, the following command will build a Docker image with a shallow clone of ESP-IDF v4.4.1 and tools for ESP32-C3, only:--build-arg

docker build -t idf-custom:v4.4.1-esp32c3 \ --build-arg IDF_CLONE_BRANCH_OR_TAG=v4.4.1 \ --build-arg IDF_CLONE_SHALLOW=1 \ --build-arg IDF_INSTALL_TARGETS=esp32c3 \ tools/docker 

http://www.kler.cn/news/4419.html

相关文章:

  • C语言基础——运算符(定义变量、转义字符、输入输出语句、运算符、32个关键字)
  • 【华为OD机试 2023最新 】 识图谱新词挖掘(C++)
  • 用户态--fork函数创建进程
  • vue 监听器及计算属性高阶用法
  • vue Teleport和ref结合复用弹框组件
  • 统计字符串中每个字符出现的次数
  • C语言基础——流程控制语句
  • 深度学习的面试小记
  • VUE3 学习笔记(五)UI框架Element Plus
  • C/C++开发,编译环境搭建
  • HDFS概述
  • 查看mysql InnoDB引擎 线程模型信息
  • Modelsim仿真使用教程
  • Leetcode.1191 K 次串联后最大子数组之和
  • 数据结构之小端和大端之谜
  • Vue 点击图片放大显示功能
  • 11_nginx_document_uri
  • 信息打点-主机架构蜜罐识别WAF识别端口扫描协议识别服务安全
  • 测试开发进阶系列课程
  • 问卷中多选题该怎么分析?
  • 《毫无意义的工作》笔记——一个人的工作越明显对他人有益,他得到的酬劳就越低?
  • STM32之TIM编码器接口
  • uni-app使用uview组件中的封装
  • 【笔记】C# 泛型约束
  • 【华为OD机试 2023最新 】 回文字符串(C++)
  • 基于springboot实现校园在线拍卖电商系统【源码】
  • 小波阈值去躁
  • 除了四大“门派”菌,一文了解肠道菌群的其它17个小众“门派”细菌
  • Java 线程调度
  • C语言的灵魂---指针(进阶)