Generating Projects from Templates
We currently maintain two template repositories:
esp-template
-no_std
template.esp-idf-template
-std
template.
Both templates are 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
or esp-template
can be used to generate an application with all the required configurations and dependencies.
-
Install
cargo generate
:cargo install cargo-generate
-
Generate a project based on one of the templates:
esp-template
:
See Understandingcargo generate esp-rs/esp-template
esp-template
for more details on the template project.esp-idf-template
:
See Understandingcargo generate esp-rs/esp-idf-template cargo
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. -
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.
- Use
Using Dev Containers in the Templates
Both template repositories have a prompt for Dev Containers support, see details in Dev Containers section of the template README.
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
.