Generating Projects from Templates

We currently maintain two template repositories:

esp-generate

esp-generate is project generation tool that can be used to generate an application with all the required configurations and dependencies

  1. Install esp-generate:

    cargo install esp-generate
    
  2. Generate a project based on the template, selecting the chip and the name of the project:

    esp-generate --chip=esp32c6 your-project
    

    See Understanding esp-generate for more details on the template project.

    When the esp-generate subcommand is invoked, you will be prompted with a TUI where you can select the configuration of your application. Upon completion of this process, you will have a buildable project with all the correct configurations.

  3. Build/Run the generated project:

    • Use cargo build to compile the project using the appropriate toolchain and target.
    • Use cargo run to compile the project, flash it, and open a serial monitor with our target device.

esp-idf-template

esp-idf-template is based on cargo-generate, a tool that allows you to create a new project based on some existing template. In our case, esp-idf-template can be used to generate an application with all the required configurations and dependencies.

  1. Install cargo generate:

    cargo install cargo-generate
    
  2. Generate a project based on the template:

    cargo generate esp-rs/esp-idf-template cargo
    

    See Understanding esp-idf-template for more details on the template project.

    When the cargo generate subcommand is invoked, you will be prompted to answer several questions regarding the target of your application. Upon completion of this process, you will have a buildable project with all the correct configurations.

  3. Build/Run the generated project:

    • Use cargo build to compile the project using the appropriate toolchain and target.
    • Use cargo run to compile the project, flash it, and open a serial monitor with our target device.

Using Dev Containers in the Templates

Both template repositories have a prompt for Dev Containers support.

Dev Containers use the idf-rust container image, which was explained in the Using Container section of the Setting up a Development Environment chapter. This image provides an environment ready to develop Rust applications for Espressif chips with no installation required. Dev Containers also have integration with Wokwi simulator, to simulate the project, and allow flashing from the container using web-flash.