Quickly set up a `probe-run` + `defmt` + `flip-link` embedded project

Overview

app-template

Quickly set up a probe-run + defmt + flip-link embedded project

Dependencies

1. flip-link:

$ cargo install flip-link

2. probe-run:

$ # make sure to install v0.2.0 or later
$ cargo install probe-run

3. cargo-generate:

$ cargo install cargo-generate

Note: You can also just clone this repository instead of using cargo-generate, but this involves additional manual adjustments.

Setup

1. Initialize the project template

$ cargo generate \
    --git https://github.com/knurling-rs/app-template \
    --branch main \
    --name my-app

If you look into your new my-app folder, you'll find that there are a few TODOs in the files marking the properties you need to set.

Let's walk through them together now.

2. Set probe-run chip

Pick a chip from probe-run --list-chips and enter it into .cargo/config.toml.

If, for example, you have a nRF52840 Development Kit from one of our workshops, replace {{chip}} with nRF52840_xxAA.

 # .cargo/config.toml
 [target.'cfg(all(target_arch = "arm", target_os = "none"))']
-runner = "probe-run --chip {{chip}}"
+runner = "probe-run --chip nRF52840_xxAA"

3. Adjust the compilation target

In .cargo/config.toml, pick the right compilation target for your board.

 # .cargo/config.toml
 [build]
-target = "thumbv6m-none-eabi"    # Cortex-M0 and Cortex-M0+
-# target = "thumbv7m-none-eabi"    # Cortex-M3
-# target = "thumbv7em-none-eabi"   # Cortex-M4 and Cortex-M7 (no FPU)
-# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
+target = "thumbv7em-none-eabihf" # Cortex-M4F (with FPU)

Add the target with rustup.

$ rustup target add thumbv7em-none-eabihf

4. Add a HAL as a dependency

In Cargo.toml, list the Hardware Abstraction Layer (HAL) for your board as a dependency.

For the nRF52840 you'll want to use the nrf52840-hal.

 # Cargo.toml
 [dependencies]
-# some-hal = "1.2.3"
+nrf52840-hal = "0.14.0"

5. Import your HAL

Now that you have selected a HAL, fix the HAL import in src/lib.rs

 // my-app/src/lib.rs
-// use some_hal as _; // memory layout
+use nrf52840_hal as _; // memory layout

(6. Get a linker script)

Some 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:

~/.cargo/registry/src/

Not all HALs provide a memory.x file, you may need to write it yourself. Check the documentation for the HAL you are using.

7. Run!

You are now all set to cargo-run your first defmt-powered application! There are some examples in the src/bin directory.

Start by cargo run-ning my-app/src/bin/hello.rs:

$ # `rb` is an alias for `run --bin`
$ cargo rb hello
    Finished dev [optimized + debuginfo] target(s) in 0.03s
flashing program ..
DONE
resetting device
0.000000 INFO Hello, world!
(..)

$ echo $?
0

If 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:

$ DEFMT_RTT_BUFFER_SIZE=64 cargo rb hello

(8. Set rust-analyzer.linkedProjects)

If 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.

{
    "rust-analyzer.linkedProjects": [
        "Cargo.toml",
        "firmware/Cargo.toml",
    ]
}

Running tests

The template comes configured for running unit tests and integration tests on the target.

Unit tests reside in the library crate and can test private API; the initial set of unit tests are in src/lib.rs. cargo test --lib will run those unit tests.

$ cargo test --lib
(1/1) running `it_works`...
└─ app::unit_tests::__defmt_test_entry @ src/lib.rs:33
all tests passed!
└─ app::unit_tests::__defmt_test_entry @ src/lib.rs:28

Integration tests reside in the tests directory; the initial set of integration tests are in tests/integration.rs. cargo test --test integration will run those integration tests. Note that the argument of the --test flag must match the name of the test file in the tests directory.

$ cargo test --test integration
(1/1) running `it_works`...
└─ integration::tests::__defmt_test_entry @ tests/integration.rs:13
all tests passed!
└─ integration::tests::__defmt_test_entry @ tests/integration.rs:8

Note that to add a new test file to the tests directory you also need to add a new [[test]] section to Cargo.toml.

Trying out the git version of defmt

This template is configured to use the latest crates.io release (the "stable" release) of the defmt framework. To use the git version (the "development" version) of defmt follow these steps:

  1. Install the git version of probe-run
$ cargo install --git https://github.com/knurling-rs/probe-run --branch main
  1. Check which defmt version probe-run supports
$ probe-run --version
0.2.0 (aa585f2 2021-02-22)
supported defmt version: 60c6447f8ecbc4ff023378ba6905bcd0de1e679f

In the example output, the supported version is 60c6447f8ecbc4ff023378ba6905bcd0de1e679f

  1. Switch defmt dependencies to git: uncomment the last part of the root Cargo.toml and enter the hash reported by probe-run --version:
-# [patch.crates-io]
-# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
-# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
-# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
-# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
+[patch.crates-io]
+defmt = { git = "https://github.com/knurling-rs/defmt", rev = "60c6447f8ecbc4ff023378ba6905bcd0de1e679f" }
+defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "60c6447f8ecbc4ff023378ba6905bcd0de1e679f" }
+defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "60c6447f8ecbc4ff023378ba6905bcd0de1e679f" }
+panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "60c6447f8ecbc4ff023378ba6905bcd0de1e679f" }

You are now using the git version of defmt!

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.

Support

app-template is part of the Knurling project, Ferrous Systems' effort at improving tooling used to develop for embedded systems.

If you think that our work is useful, consider sponsoring it via GitHub Sponsors.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Comments
  • defmt error trying to install as per instructions

    defmt error trying to install as per instructions

    I tried to do the following:

     cargo install \
        --git https://github.com/knurling-rs/probe-run \
        --branch main \
        --features defmt --force
    cargo install cargo-generate --force
    cargo install flip-link --force
    cargo generate \
        --git https://github.com/knurling-rs/app-template \
        --branch main \
        --name knurling-template
    

    I then performed the edits suggested from the README.md file: https://github.com/knurling-rs/app-template

    and when I do:

    cargo run --bin hello
    

    I get the following error:

         Running `probe-run --chip nRF52840_xxAA --defmt target/thumbv7em-none-eabihf/debug/hello`
    Error: defmt version mismatch (firmware is using 148009e3bb1d99b5a1938a1a816ad0b0b6423aeb, host is using 28c1afb4d3bad747ef47737a83f5c8b13928cb8a); are you using the same git version of defmt and related tools?
    Try `cargo install`-ing the latest git version of `probe-run` AND updating your project's `Cargo.lock` with `cargo update`
    

    I even did cargo uninstall probe-run and reran the install command above with no change.

    opened by dhylands 7
  • Cannot build with nrf51-hal

    Cannot build with nrf51-hal

    When I try to build for nrf51822 (cortex-m0) with nrf-51-hal crate the build never ends.

    Steps to reproduce:

    rustup target add thumbv6m-none-eabi cargo generate --git https://github.com/knurling-rs/app-template --branch main --name my-app Add nrf51-hal = "0.14" to Cargo.toml dependencies cargo build

    cargo build output: Compiling proc-macro2 v1.0.34 Compiling unicode-xid v0.2.2 Compiling syn v1.0.82 Compiling semver-parser v0.7.0 Compiling cortex-m v0.7.3 Compiling version_check v0.9.3 Compiling nb v1.0.0 Compiling vcell v0.1.3 Compiling void v1.0.2 Compiling cortex-m-rt v0.7.1 Compiling bitfield v0.13.2 Compiling defmt v0.3.0 Compiling az v1.2.0 Compiling typenum v1.14.0 Compiling defmt-macros v0.3.1 Compiling fixed v1.11.0 Compiling nrf51-pac v0.10.1 Compiling defmt-parser v0.3.0 Compiling half v1.8.2 Compiling stable_deref_trait v1.2.0 Compiling bitflags v1.3.2 Compiling nrf-hal-common v0.14.0 Compiling bytemuck v1.7.3 Compiling cast v0.3.0 Compiling rand_core v0.6.3 Compiling cfg-if v1.0.0 Compiling defmt-rtt v0.3.1 Compiling panic-probe v0.3.0 Compiling nrf51-hal v0.14.0 Compiling embedded-storage v0.2.0 Compiling volatile-register v0.2.1 Compiling nb v0.1.3 Compiling semver v0.9.0 Compiling embedded-dma v0.1.2 Compiling proc-macro-error-attr v1.0.4 Compiling proc-macro-error v1.0.4 Compiling embedded-hal v0.2.6 Compiling rustc_version v0.2.3 Compiling bare-metal v0.2.5 Compiling quote v1.0.10 Compiling cortex-m-rt-macros v0.7.0 Compiling my-app v0.1.0 (/home/honza/tmp/my-app) Building [=======================> ] 75/82: fixed

    type: bug status: blocked 
    opened by nedv-eu 5
  • vscode error `can't find crate for `test``

    vscode error `can't find crate for `test``

    Hi. After I used app-template to generate a project and opened it with vscode, the rust extension emitted an error can't find crate for test. Could you tell me how to avoid this.

    opened by YoshieraHuang 4
  • error[E0463]: can't find crate for `test`

    error[E0463]: can't find crate for `test`

    Have been trying to retrofit defmt::test to a library. Ran into issues, thought I'd better start with something working Ran through the readme instructions (cargo rb hello builds and runs) cargo test just complains about "can't find crate test` image Other than readme instructions for device specific bits, no modifications have been made

    installed cargo tools image

    type: documentation difficulty: easy status: needs PR 
    opened by Crzyrndm 3
  • Switch from cargo-generate to kickstart

    Switch from cargo-generate to kickstart

    kickstart is vastly simpler and easier to predict. It shouldn't run into the unreproducible CI errors in https://github.com/knurling-rs/app-template/pull/46.

    Drawbacks:

    • Author is no longer automatically filled in from git
    • We have to ask for both the package name and the crate name, because kickstart does not automatically give you both
    opened by jonas-schievink 3
  • Use defmt:timestamp! macro instead of attribute form

    Use defmt:timestamp! macro instead of attribute form

    This change fixes a compiler error in the CO2 sensor sessions:

    error: expected attribute, found macro `defmt::timestamp`
      --> src/lib.rs:18:3
       |
    18 | #[defmt::timestamp]
       |   ^^^^^^^^^^^^^^^^ not an attribute
    

    The #[defmt::timestamp] attribute has been changed to a regular macro that works just like the logging macros

    Cite: https://ferrous-systems.com/blog/knurling-changelog-13/

    opened by nicodemus26 3
  • Print-defmt feature results into linker error

    Print-defmt feature results into linker error

    The print-defmt feature, which is enabled by default here:

    https://github.com/knurling-rs/app-template/blob/b131e1125795b57e3f342fb2a58efcc60290edf0/testsuite/Cargo.toml#L25

    is not enabled in the root Cargo.toml

    https://github.com/knurling-rs/app-template/blob/b131e1125795b57e3f342fb2a58efcc60290edf0/Cargo.toml#L19-L21

    which results into this linker error on my machine, when envoking cargo test -p testsuite:

      Updating git repository `https://github.com/knurling-rs/defmt.git`
       Compiling testsuite v0.1.0 (/home/fabian/Projects/probe-rs-test/testsuite)
    error: linking with `rust-lld` failed: exit code: 1
      |
      = note: "rust-lld" "-flavor" "gnu" "--eh-frame-hdr" "-L" "/home/fabian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/test-daf5c426a107f9de.3f85ep5l4tmq4cjz.rcgu.o" "-o" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/test-daf5c426a107f9de" "--gc-sections" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps" "-L" "/home/fabian/Projects/probe-rs-test/target/debug/deps" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/build/cortex-m-9e8e16258a49aff5/out" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-de80db1368e4e709/out" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/build/defmt-63ffe4a8f615f792/out" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/build/defmt-9193441bd5229fe0/out" "-L" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/build/stm32f3-79ff9fbfd025df4d/out" "-L" "/home/fabian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib" "-Bstatic" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libprobe_rs_test-fc8a21b9535a2bb9.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libstm32f3xx_hal-969d10ed50bf8cb0.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libheapless-937b344ffad95b46.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libhash32-43140fd7893bf3c5.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libbyteorder-6fad586717fa02c4.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libembedded_hal_can-87549cd3a05caaee.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libstm32_usbd-86e8030cdc26258d.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libusb_device-b72e166c77966672.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libcfg_if-90796c704deea078.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/librtcc-9eb407e85b02babd.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libchrono-a670157da5d0ae28.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libnum_integer-c618218e6106f58c.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libnum_traits-13c286d7d20ca587.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libembedded_dma-dcfaf13f8f551ee0.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libcast-44574ff949e37aae.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libstm32f3-68ec9081389bd82f.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libembedded_hal-f7e699ffe96e3c2e.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libvoid-6f3bc16521189212.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libnb-47a67e8f2360fe58.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libnb-5a5434ccd7996659.rlib" "--start-group" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libpanic_probe-79dd64c85d461f83.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt-875d097bce3c0ced.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt_common-ff5cd0653fae5eee.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt_rtt-c5ca225d2c9d8903.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt-15d46e343b789076.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-0eb7bb1de769cc23.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libvolatile_register-b6339df8b54634ba.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libvcell-9695512adac47d45.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libbare_metal-b5b81c0dc4b2d60b.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libaligned-75df737b2ac89ff7.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libas_slice-5fd1956ac6d2cddc.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libstable_deref_trait-fcdcb203a2b90bb3.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libgeneric_array-fda4f9a3eb1be905.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libgeneric_array-25409c8c76176d2e.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libgeneric_array-02caaeed88b43efc.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libtypenum-94045a785496a94d.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libcortex_m_rt-148379300858178c.rlib" "/home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libr0-31ea11b2b4afebea.rlib" "/home/fabian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/librustc_std_workspace_core-cd2885036a83a85f.rlib" "/home/fabian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-638f4f8c5b5e5844.rlib" "--end-group" "/home/fabian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcompiler_builtins-93db0b79f9e8c6f2.rlib" "-Tlink.x" "-Tdefmt.x" "-Bdynamic"
      = note: rust-lld: error: duplicate symbol: __defmt_default_timestamp
              >>> defined at lib.rs:444 (/home/fabian/.cargo/git/checkouts/defmt-7f5b74b4e6ff55d4/be7f4a7/src/lib.rs:444)
              >>>            defmt-875d097bce3c0ced.defmt.m7gzhem3-cgu.0.rcgu.o:(__defmt_default_timestamp) in archive /home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt-875d097bce3c0ced.rlib
              >>> defined at lib.rs:442 (/home/fabian/.cargo/git/checkouts/defmt-7f5b74b4e6ff55d4/77bef85/src/lib.rs:442)
              >>>            defmt-15d46e343b789076.defmt.1dquk1wd-cgu.0.rcgu.o:(.text.__defmt_default_timestamp+0x1) in archive /home/fabian/Projects/probe-rs-test/target/thumbv7em-none-eabihf/debug/deps/libdefmt-15d46e343b789076.rlib
    

    Removing or disabling the print-defmt feature resolves the issue.

    opened by Sh3Rm4n 3
  • add debuginfo to `test --release`

    add debuginfo to `test --release`

    executable build with cargo test --release are built with the bench profile. By default, this profile is similar to the default release profile so it has debug = 0. The result is that cargo test --release results in (1) log messages having no location information and (2) knurling-rs/probe-run#9, which makes the process exit with nonzero exit code even when all test fails.

    this PR overrides the bench profile to match the release profile override. This fixes above issues.

    opened by japaric 2
  • Cannot find linker script memory.x

    Cannot find linker script memory.x

    Hi! I'm trying out this template on a Bluepill board with STM32F103C8 and stm32f1xx-hal. After following the setup steps (and working around #18) I get a linker error about missing memory.x when running cargo rb hello.

    Copying memory.x from the HAL's repository into the root of the project as suggested by their readme solves the problem. https://github.com/stm32-rs/stm32f1xx-hal/blob/master/memory.x

    Is this expected to be part of step 5 ("5. Import your HAL")? I could make a PR on the readme but I'm not sure if this works differently for other HAL's?

    opened by albertskog 2
  • Max number of RTT attach retries exceeded

    Max number of RTT attach retries exceeded

    I followed the defmt setup guide from this post and finished the todos. However I get the following when running the hello example. The repo is here: https://github.com/hamptokr/voltron-testing

      (HOST) INFO  flashing program
      (HOST) INFO  success!
    ────────────────────────────────────────────────────────────────────────────────
      (HOST) ERROR Max number of RTT attach retries exceeded.
    Error: RTT control block not found in target memory. Make sure RTT is initialized on the target.
    

    Here are some versions of things I am using

    • cargo 1.46.0 (149022b1d 2020-07-17)
    • rustc 1.46.0 (04488afe3 2020-08-24)
    • stm32f4xx-hal = { version = "0.8.3", features = ["rt", "stm32f429"] }
    • probe-run 0.1.3 (from master branch)
    type: bug 
    opened by hamptokr 2
  • Disable test harness for lib target

    Disable test harness for lib target

    Without this change, if testsuite/src/lib.rs will be crated and cargo test is invoked, cargo will try to link libtest with the crate.

    As this crate is no_std and will usually be run for targets, where no std library exists and therefor also no libtest, this will fail with an error similar to this:

    error[E0463]: can't find crate for `test`
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `testsuite`
    

    To circumvent this issue, disable the harness for lib as well.

    opened by Sh3Rm4n 1
  • We are on vacation ⛄

    We are on vacation ⛄

    Dear Knurling-rs community,

    Most of us maintainers of Knurling-rs will be on vacation from this week until the beginning of January. Therefore please do not expect too much activity in our repositories and issue tracker.

    We wish you a great holiday season (if you have it) or, otherwise, just a good time.

    Best, your Knurling-rs team ❄️

    opened by Urhengulas 0
  • Minor fix: Readme to config.toml references

    Minor fix: Readme to config.toml references

    Improved README to point correct references in the config.toml file. Minor issues on target selection has been fixed regarding to default config.

    @Urhengulas : Why are you closing a PR with a small issue that fast? You could ask for a fix and it could be done in a minute. That's what PR's discussions for.

    opened by MuratUrsavas 0
  • Replace cargo-generate with kickstart

    Replace cargo-generate with kickstart

    Closes #36.

    An example of prompts with defaults:

    ❯ kickstart https://github.com/knurling-rs/app-template
    Author's name? [default: You <[email protected]>]: 
    How to you name your project's crate? [default: my-embedded-app, validation: ^([a-zA-Z][a-zA-Z0-9_-]+)$]: 
    What's the name of the chip (see `probe-run --list-chips` output)? [default: nRF52840_xxAA]: 
    What's the target's name?: 
      1. thumbv6m-none-eabi (Cortex-M0 and Cortex-M0+)
      2. thumbv7m-none-eabi (Cortex-M3)
      3. thumbv7em-none-eabi (Cortex-M4 and Cortex-M7 | no FPU)
      4. thumbv7em-none-eabihf (Cortex-M4F and Cortex-M7F | with FPU)
      > Choose from 1..4 [default: 1]: 
    Do you want to use an embedded-hal?: 
      1. yes
      2. no
      > Choose from 1..2 [default: 1]: 
    embedded-hal crate name? [default: nrf52840-hal]: 
    embedded-hal crate version? [default: 0.11.0]: 
    
    Everything done, ready to go!
    

    Tested by compiling the generated project with defaults.

    opened by eupn 6
  • Replace cargo-generate with kickstart

    Replace cargo-generate with kickstart

    I think it could be better to replace cargo-generate with a similar but more powerful tool kickstart. This tool supports custom template variables. This should free the user of most of the manual actions of replacing {{variables}} that aren't supported by cargo-generate.

    If it makes sense to do so, I'll be happy to make a PR for this.

    type: enhancement difficulty: medium priority: low status: needs PR 
    opened by eupn 1
  • risc-v support

    risc-v support

    I'm getting linking errors during cargo build --bin hello

    error: linking with `rust-lld` failed: exit code: 1
      |
      = note: "rust-lld" "-flavor" "gnu" "-L" "/home/dkhayes117/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o" "-o" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350" "--gc-sections" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/debug/deps" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/defmt-786b78cb5fb56c90/out" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/hifive1-12e6de30a7c42179/out" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/e310x-c9d6b8bcdebcec36/out" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/riscv-b96e58c41469ec83/out" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/riscv-rt-7fa43864cbb5bfaa/out" "-L" "/home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/build/riscv-rt-7fa43864cbb5bfaa/out" "-L" "/home/dkhayes117/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "--start-group" "-Bstatic" "/tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib" "/tmp/rustcQiAIxg/libriscv-6fb334952367127a.rlib" "--end-group" "/home/dkhayes117/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/libcompiler_builtins-c1fdd1f60c58bc16.rlib" "-Bdynamic"
      = note: rust-lld: error: undefined symbol: _mp_hook
              >>> referenced by lib.rs:301 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:301)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: __pre_init
              >>> referenced by lib.rs:302 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:302)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: _sbss
              >>> referenced by lib.rs:302 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:302)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              >>> referenced by lib.rs:302 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:302)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: _ebss
              >>> referenced by lib.rs:302 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:302)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              >>> referenced by lib.rs:302 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:302)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: _sdata
              >>> referenced by lib.rs:0 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/r0-0.2.2/src/lib.rs:0)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              >>> referenced by lib.rs:0 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/r0-0.2.2/src/lib.rs:0)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: _sidata
              >>> referenced by lib.rs:0 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/r0-0.2.2/src/lib.rs:0)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              >>> referenced by lib.rs:0 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/r0-0.2.2/src/lib.rs:0)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_rust)
              
              rust-lld: error: undefined symbol: trap_handler
              >>> referenced by lib.rs:329 (/home/dkhayes117/.cargo/registry/src/github.com-1ecc6299db9ec823/riscv-rt-0.6.2/src/lib.rs:329)
              >>>               /home/dkhayes117/IdeaProjects/defmt_test/target/riscv32imac-unknown-none-elf/debug/deps/hello-a9b45fbc99b62350.hello.1n7pvg5w-cgu.0.rcgu.o:(_start_trap_rust)
              
              rust-lld: error: undefined symbol: _max_hart_id
              >>> referenced by riscv-rt.o:(.init+0x52) in archive /tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib
              >>> referenced by riscv-rt.o:(.init+0x56) in archive /tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib
              
              rust-lld: error: undefined symbol: _stack_start
              >>> referenced by riscv-rt.o:(.init+0x5E) in archive /tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib
              
              rust-lld: error: undefined symbol: _hart_stack_size
              >>> referenced by riscv-rt.o:(.init+0x66) in archive /tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib
              >>> referenced by riscv-rt.o:(.init+0x6A) in archive /tmp/rustcQiAIxg/libriscv_rt-c7d2a202c972997c.rlib
              
    
    error: aborting due to previous error
    
    error: could not compile `defmt_test`.
    
    To learn more, run the command again with --verbose.
    
    
    type: enhancement difficulty: hard priority: low status: blocked 
    opened by dkhayes117 1
Owner
Knurling
Get a handle on bare metal Rust
Knurling
An open source WCH-Link library/command line tool written in Rust.

wlink - WCH-Link command line tool NOTE: This tool is still in development and not ready for production use. Known Issue: Only support binary firmware

WCH MCU for Rust 22 Mar 7, 2023
Tests a wide variety of N64 features, from common to hardware quirks. Written in Rust. Executes quickly.

n64-systemtest Tests a wide variety of N64 features, from common to hardware quirks. Written in Rust. Executes quickly. n64-systemtest is a test rom t

null 37 Jan 7, 2023
This is the Rust course used by the Android team at Google. It provides you the material to quickly teach Rust to everyone.

Comprehensive Rust ?? This repository has the source code for Comprehensive Rust ?? , a four day Rust course developed by the Android team. The course

Google 5.2k Jan 3, 2023
A typemap for a set of known types optionally without heap allocation, and supporting iterating by traits

fixed_typemap docs.rs GitHub Sponsors Implements typemaps that support a lot of extra funcctionality using procedural macros. docs.rs has a lot more t

Austin Hicks 2 Dec 27, 2021
Rust crates with map and set with interval keys (ranges x..y).

This crates implements map and set with interval keys (ranges x..y). IntervalMap is implemented using red-black binary tree, where each node contains

Timofey Prodanov 8 Aug 23, 2022
A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments.

Zerokit A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments. Initial scope Focus on RLN

vac 44 Dec 27, 2022
Trying embedded Rust on the Pinecil GD32VF103 RISC-V device.

Pinecil GD32VF103 RISC-V Rust Demos My personal collection of Rust demos running on the PINE64 Pinecil portable soldering iron, featuring a GD32VF103T

alvinhochun 39 Nov 28, 2022
An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree.

Nouzdb An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree. Plan Implement a memtable. Implement the

Nouzan 1 Dec 5, 2021
A library for extracting #[no_mangle] pub extern "C" functions (https://docs.rust-embedded.org/book/interoperability/rust-with-c.html#no_mangle)

A library for extracting #[no_mangle] pub extern "C" functions In order to expose a function with C binary interface for interoperability with other p

Dmitrii - Demenev 0 Feb 17, 2022
Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree.

ekv Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree. Features None yet TODO Everything Minimum supported Rust version (MSRV

Dario Nieuwenhuis 16 Nov 22, 2022
ArbOS operating system, to run at Layer 2 on Arbitrum chains. Also a compiler for Mini, the language in which ArbOS is written.

ArbOS and Mini compiler ArbOS is the "operating system" that runs at Layer 2 on an Arbitrum chain, to manage the chain's operation, maintain security,

Offchain Labs 88 Nov 6, 2022
TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Kirill Vasiltsov 28 Dec 12, 2022
Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer.

Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer ?? Download | Give it a Star ⭐ | Share it on Twitte

Julio Andres 73 Jun 15, 2023
A learning project/fun experiment in internet protocol

Piper a learning project/fun experiment in internet protocol Version 0.4.0 (SEMVER) Goals Piper is Simple. A page is a page. There are no secondary re

null 13 Oct 27, 2022
Gecko is a high-level, general-purpose programming language built on top of the LLVM project.

Gecko is a high-level, general-purpose programming language built on top of the LLVM project. Gecko Technology & principles Gecko is a general-purpose

Gecko 19 Oct 3, 2022
Elemental System Designs is an open source project to document system architecture design of popular apps and open source projects that we want to study

Elemental System Designs is an open source project to document system architecture design of popular apps and open source projects that we want to study

Jason Shin 9 Apr 10, 2022
This project contains small exercises to get you used to reading and writing Rust code

rustlings ?? ❤️ Greetings and welcome to rustlings. This project contains small exercises to get you used to reading and writing Rust code. This inclu

Cynthia Tran 1 May 24, 2022
This repository serves as the backend for the Torrust Index project.

Torrust Index Backend ?? Important Updates ?? None at the moment ACCESS ALL UPDATES Index PROJECT DESCRIPTION PROJECT ROADMAP DOCUMENTATION INSTALLATI

Torrust 6 Dec 15, 2022
A project for developing Rust applications

rust_dev This is a project for developing Rust applications. The goal of this project is to provide a solid foundation for building robust and scalabl

Harsh agarwal 4 Feb 7, 2023