{"id":13423247,"url":"https://github.com/knurling-rs/app-template","last_synced_at":"2026-02-17T21:48:20.005Z","repository":{"id":40599368,"uuid":"289238316","full_name":"knurling-rs/app-template","owner":"knurling-rs","description":"Quickly set up a `probe-rs` + `defmt` + `flip-link` embedded project","archived":false,"fork":false,"pushed_at":"2025-07-28T14:02:11.000Z","size":94,"stargazers_count":358,"open_issues_count":6,"forks_count":36,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-07-28T15:24:12.488Z","etag":null,"topics":["embedded-rust","ferrous-systems"],"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/knurling-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["knurling-rs"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-08-21T10:06:10.000Z","updated_at":"2025-07-28T14:01:55.000Z","dependencies_parsed_at":"2023-10-11T13:43:49.451Z","dependency_job_id":"ce91f36f-dd14-4a0e-bd29-d437c5cb4b2e","html_url":"https://github.com/knurling-rs/app-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/knurling-rs/app-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knurling-rs%2Fapp-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knurling-rs%2Fapp-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knurling-rs%2Fapp-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knurling-rs%2Fapp-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knurling-rs","download_url":"https://codeload.github.com/knurling-rs/app-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knurling-rs%2Fapp-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29559610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:44:20.755Z","status":"ssl_error","status_checked_at":"2026-02-17T21:44:18.221Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["embedded-rust","ferrous-systems"],"created_at":"2024-07-31T00:00:26.020Z","updated_at":"2026-02-17T21:48:14.991Z","avatar_url":"https://github.com/knurling-rs.png","language":"Rust","funding_links":["https://github.com/sponsors/knurling-rs"],"categories":["Tools"],"sub_categories":["Paid and commercially available materials","Community Chat Rooms"],"readme":"# `app-template`\n\n\u003e Quickly set up a [`probe-rs`] + [`defmt`] + [`flip-link`] embedded project\n\n[`probe-rs`]: https://crates.io/crates/probe-rs\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```bash\ncargo install flip-link\n```\n\n### 2. `probe-rs`:\n\nInstall probe-rs by following the instructions at \u003chttps://probe.rs/docs/getting-started/installation/\u003e.\n\n### 3. [`cargo-generate`]:\n\n```bash\ncargo 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```bash\ncargo 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-rs` chip\n\nPick a chip from ` probe-rs chip list` 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-rs run --chip {{chip}}\"\n+runner = \"probe-rs run --chip nRF52840_xxAA\"\n```\n\n### 2.1 Pass custom log format\n\nYou need to use an array of strings instead of a single string for the `runner` if you use a custom log format.\n\n```toml\nrunner = [\"probe-rs\", \"run\", \"--chip\", \"$CHIP\", \"--log-format\", \"{L} {s}\"]\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```bash\nrustup 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⚠️ Note for RP2040 users ⚠️\n\nYou will need to not just specify the `rp-hal` HAL, but a BSP (board support crate) which includes a second stage bootloader. Please find a list of available BSPs [here](https://github.com/rp-rs/rp-hal-boards#packages).\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```text\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### 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## 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%2Fknurling-rs%2Fapp-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknurling-rs%2Fapp-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknurling-rs%2Fapp-template/lists"}