liveBook · Manning

Cargo-generate

As explained in Embedded Software with Rust

cargo-generate is a Cargo subcommand that creates projects from templates.

cargo-generate creates a Cargo project from a compatible template repository, avoiding manual setup of embedded project files before application development begins. section 2.4

cargo generate --git <template-repo-url> --name <project-name>

Install the subcommand with Cargo, then generate a project from a remote template repository and give it a project name. section 2.4.1

A template can supply embedded-specific project structure and configuration, including:

  • A standard Cargo layout and target configuration in .cargo/config.toml. section 2.4.2
  • A memory.x linker script tuned for the selected microcontroller and integration with cortex-m-rt. section 2.4.2

The STM32 template’s setup wizard asks for a project name and microcontroller model, along with options such as HAL version, RTIC, and defmt. Template quality matters: templates can become outdated, so manual project configuration eventually becomes useful. section 2.4.2 section 3.0

How Embedded Software with Rust covers it

How deep it goes
Shows installation, template invocation, wizard choices, and generated files, then defers detailed manual project configuration.
Examples
Uses the stm32-template repository to generate an STM32F103C8T6 project with a named project and configurable setup options.
What it assumes
Starts with Cargo-based installation and teaches the generation command, without requiring prior knowledge of manual embedded project configuration.
What you can do after
Apply cargo-generate to create a Cargo project from a remote template and configure its initial embedded setup.
How it connects
Connects project generation with Cargo, project templates, target configuration, linker scripts, and cortex-m-rt.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.