{"id":19923797,"url":"https://github.com/versbinarii/stm32-rtic-template","last_synced_at":"2026-06-09T08:31:18.739Z","repository":{"id":150486563,"uuid":"456170133","full_name":"VersBinarii/stm32-rtic-template","owner":"VersBinarii","description":"A template repository for quickly setting up RTIC based projects","archived":false,"fork":false,"pushed_at":"2022-02-06T14:14:26.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T10:21:58.024Z","etag":null,"topics":["arm","embedded","embedded-rust","rtic","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VersBinarii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-06T14:13:45.000Z","updated_at":"2023-10-04T02:22:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"abf86c72-fa28-4152-897e-0c5179b50172","html_url":"https://github.com/VersBinarii/stm32-rtic-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/VersBinarii/stm32-rtic-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VersBinarii%2Fstm32-rtic-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VersBinarii%2Fstm32-rtic-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VersBinarii%2Fstm32-rtic-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VersBinarii%2Fstm32-rtic-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VersBinarii","download_url":"https://codeload.github.com/VersBinarii/stm32-rtic-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VersBinarii%2Fstm32-rtic-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34098819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm","embedded","embedded-rust","rtic","rust"],"created_at":"2024-11-12T22:15:29.261Z","updated_at":"2026-06-09T08:31:18.734Z","avatar_url":"https://github.com/VersBinarii.png","language":"Rust","funding_links":["https://github.com/sponsors/knurling-rs"],"categories":[],"sub_categories":[],"readme":"# `app-template`\n\n\u003e Quickly set up a [`probe-run`] + [`defmt`] + [`flip-link`] embedded project\n\n[`probe-run`]: https://crates.io/crates/probe-run\n[`defmt`]: https://github.com/knurling-rs/defmt\n[`flip-link`]: https://github.com/knurling-rs/flip-link\n\n## Dependencies\n\n#### 1. `flip-link`:\n\n```console\n$ cargo install flip-link\n```\n\n#### 2. `probe-run`:\n\n``` console\n$ # make sure to install v0.2.0 or later\n$ cargo install probe-run\n```\n\n#### 3. [`cargo-generate`]:\n\n``` console\n$ cargo install cargo-generate\n```\n\n[`cargo-generate`]: https://crates.io/crates/cargo-generate\n\n\u003e *Note:* You can also just clone this repository instead of using `cargo-generate`, but this involves additional manual adjustments.\n\n## Setup\n\n#### 1. Initialize the project template\n\n``` console\n$ cargo generate \\\n    --git https://github.com/knurling-rs/app-template \\\n    --branch main \\\n    --name my-app\n```\n\nIf you look into your new `my-app` folder, you'll find that there are a few `TODO`s in the files marking the properties you need to set.\n\nLet's walk through them together now.\n\n#### 2. Set `probe-run` chip\n\nPick a chip from `probe-run --list-chips` and enter it into `.cargo/config.toml`.\n\nIf, for example, you have a nRF52840 Development Kit from one of [our workshops], replace `{{chip}}` with `nRF52840_xxAA`.\n\n[our workshops]: https://github.com/ferrous-systems/embedded-trainings-2020\n\n``` diff\n # .cargo/config.toml\n [target.'cfg(all(target_arch = \"arm\", target_os = \"none\"))']\n-runner = \"probe-run --chip {{chip}}\"\n+runner = \"probe-run --chip nRF52840_xxAA\"\n```\n\n#### 3. Adjust the compilation target\n\nIn `.cargo/config.toml`, pick the right compilation target for your board.\n\n``` diff\n # .cargo/config.toml\n [build]\n-target = \"thumbv6m-none-eabi\"    # Cortex-M0 and Cortex-M0+\n-# target = \"thumbv7m-none-eabi\"    # Cortex-M3\n-# target = \"thumbv7em-none-eabi\"   # Cortex-M4 and Cortex-M7 (no FPU)\n-# target = \"thumbv7em-none-eabihf\" # Cortex-M4F and Cortex-M7F (with FPU)\n+target = \"thumbv7em-none-eabihf\" # Cortex-M4F (with FPU)\n```\n\nAdd the target with `rustup`.\n\n``` console\n$ rustup target add thumbv7em-none-eabihf\n```\n\n#### 4. Add a HAL as a dependency\n\nIn `Cargo.toml`, list the Hardware Abstraction Layer (HAL) for your board as a dependency.\n\nFor the nRF52840 you'll want to use the [`nrf52840-hal`].\n\n[`nrf52840-hal`]: https://crates.io/crates/nrf52840-hal\n\n``` diff\n # Cargo.toml\n [dependencies]\n-# some-hal = \"1.2.3\"\n+nrf52840-hal = \"0.14.0\"\n```\n\n#### 5. Import your HAL\n\nNow that you have selected a HAL, fix the HAL import in `src/lib.rs`\n\n``` diff\n // my-app/src/lib.rs\n-// use some_hal as _; // memory layout\n+use nrf52840_hal as _; // memory layout\n```\n\n#### (6. Get a linker script)\n\nSome HAL crates require that you manually copy over a file called `memory.x` from the HAL to the root of your project. For nrf52840-hal, this is done automatically so no action is needed. For other HAL crates, you can get it from your local Cargo folder, the default location is under:\n\n```\n~/.cargo/registry/src/\n```\n\nNot all HALs provide a `memory.x` file, you may need to write it yourself. Check the documentation for the HAL you are using.\n\n\n#### 7. Run!\n\nYou are now all set to `cargo-run` your first `defmt`-powered application!\nThere are some examples in the `src/bin` directory.\n\nStart by `cargo run`-ning `my-app/src/bin/hello.rs`:\n\n``` console\n$ # `rb` is an alias for `run --bin`\n$ cargo rb hello\n    Finished dev [optimized + debuginfo] target(s) in 0.03s\nflashing program ..\nDONE\nresetting device\n0.000000 INFO Hello, world!\n(..)\n\n$ echo $?\n0\n```\n\nIf you're running out of memory (`flip-link` bails with an overflow error), you can decrease the size of the device memory buffer by setting the `DEFMT_RTT_BUFFER_SIZE` environment variable. The default value is 1024 bytes, and powers of two should be used for optimal performance:\n\n``` console\n$ DEFMT_RTT_BUFFER_SIZE=64 cargo rb hello\n```\n\n#### (8. Set `rust-analyzer.linkedProjects`)\n\nIf you are using [rust-analyzer] with VS Code for IDE-like features you can add following configuration to your `.vscode/settings.json` to make it work transparently across workspaces. Find the details of this option in the [RA docs].\n\n```json\n{\n    \"rust-analyzer.linkedProjects\": [\n        \"Cargo.toml\",\n        \"firmware/Cargo.toml\",\n    ]\n}\n```\n\n[RA docs]: https://rust-analyzer.github.io/manual.html#configuration\n[rust-analyzer]: https://rust-analyzer.github.io/\n\n## Running tests\n\nThe template comes configured for running unit tests and integration tests on the target.\n\nUnit tests reside in the library crate and can test private API; the initial set of unit tests are in `src/lib.rs`.\n`cargo test --lib` will run those unit tests.\n\n``` console\n$ cargo test --lib\n(1/1) running `it_works`...\n└─ app::unit_tests::__defmt_test_entry @ src/lib.rs:33\nall tests passed!\n└─ app::unit_tests::__defmt_test_entry @ src/lib.rs:28\n```\n\nIntegration tests reside in the `tests` directory; the initial set of integration tests are in `tests/integration.rs`.\n`cargo test --test integration` will run those integration tests.\nNote that the argument of the `--test` flag must match the name of the test file in the `tests` directory.\n\n``` console\n$ cargo test --test integration\n(1/1) running `it_works`...\n└─ integration::tests::__defmt_test_entry @ tests/integration.rs:13\nall tests passed!\n└─ integration::tests::__defmt_test_entry @ tests/integration.rs:8\n```\n\nNote that to add a new test file to the `tests` directory you also need to add a new `[[test]]` section to `Cargo.toml`.\n\n## Trying out the git version of defmt\n\nThis template is configured to use the latest crates.io release (the \"stable\" release) of the `defmt` framework.\nTo use the git version (the \"development\" version) of `defmt` follow these steps:\n\n1. Install the *git* version of `probe-run`\n\n``` console\n$ cargo install --git https://github.com/knurling-rs/probe-run --branch main\n```\n\n2. Check which defmt version `probe-run` supports\n\n``` console\n$ probe-run --version\n0.2.0 (aa585f2 2021-02-22)\nsupported defmt version: 60c6447f8ecbc4ff023378ba6905bcd0de1e679f\n```\n\nIn the example output, the supported version is `60c6447f8ecbc4ff023378ba6905bcd0de1e679f`\n\n3. Switch defmt dependencies to git: uncomment the last part of the root `Cargo.toml` and enter the hash reported by `probe-run --version`:\n\n``` diff\n-# [patch.crates-io]\n-# defmt = { git = \"https://github.com/knurling-rs/defmt\", rev = \"use defmt version reported by `probe-run --version`\" }\n-# defmt-rtt = { git = \"https://github.com/knurling-rs/defmt\", rev = \"use defmt version reported by `probe-run --version`\" }\n-# defmt-test = { git = \"https://github.com/knurling-rs/defmt\", rev = \"use defmt version reported by `probe-run --version`\" }\n-# panic-probe = { git = \"https://github.com/knurling-rs/defmt\", rev = \"use defmt version reported by `probe-run --version`\" }\n+[patch.crates-io]\n+defmt = { git = \"https://github.com/knurling-rs/defmt\", rev = \"60c6447f8ecbc4ff023378ba6905bcd0de1e679f\" }\n+defmt-rtt = { git = \"https://github.com/knurling-rs/defmt\", rev = \"60c6447f8ecbc4ff023378ba6905bcd0de1e679f\" }\n+defmt-test = { git = \"https://github.com/knurling-rs/defmt\", rev = \"60c6447f8ecbc4ff023378ba6905bcd0de1e679f\" }\n+panic-probe = { git = \"https://github.com/knurling-rs/defmt\", rev = \"60c6447f8ecbc4ff023378ba6905bcd0de1e679f\" }\n```\n\nYou are now using the git version of `defmt`!\n\n**NOTE** there may have been breaking changes between the crates.io version and the git version; you'll need to fix those in the source code.\n\n## Support\n\n`app-template` is part of the [Knurling] project, [Ferrous Systems]' effort at\nimproving tooling used to develop for embedded systems.\n\nIf you think that our work is useful, consider sponsoring it via [GitHub\nSponsors].\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\nlicensed as above, without any additional terms or conditions.\n\n[Knurling]: https://knurling.ferrous-systems.com\n[Ferrous Systems]: https://ferrous-systems.com/\n[GitHub Sponsors]: https://github.com/sponsors/knurling-rs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversbinarii%2Fstm32-rtic-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fversbinarii%2Fstm32-rtic-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversbinarii%2Fstm32-rtic-template/lists"}