Code Monkey home page Code Monkey logo

app-template's Introduction

app-template

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

Dependencies

1. flip-link:

$ cargo install flip-link

2. probe-rs:

$ # make sure to install v0.2.0 or later
$ cargo install probe-rs --features cli
$ 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-rs chip

Pick a chip from probe-rs chip list 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-rs run --chip {{chip}}"
+runner = "probe-rs run --chip nRF52840_xxAA"

2.1 Pass custom log format

You need to use an array of strings instead of a single string for the runner if you use a custom log format.

runner = ["probe-rs", "run", "--chip", "$CHIP", "--log-format", "{L} {s}"]

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"

⚠️ Note for RP2040 users ⚠️

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

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.

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.

app-template's People

Contributors

albertskog avatar andresv avatar atomycx avatar briocheberlin avatar japaric avatar jonas-schievink avatar jonathanpallant avatar sh3rm4n avatar spookyvision avatar urhengulas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

app-template's Issues

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.

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)

failed to load bc of ...

Hi. Does anyone know what could cause this? Have been using probe-run for a while; got this error on modifying project to be like the template, using defmt and flip-link. Thank you.

warning: Linking globals named '_SEGGER_RTT': symbol multiply defined!

error: failed to load bc of "defmt_rtt-744a0a5cfb69d4e1.defmt_rtt.awuu50kv-cgu.0.rcgu.o":

error: aborting due to previous error; 34 warnings emitted

I'm using Windows.

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.

Error in README.md

In Step 2 of the Setup has an incorrect command.
probe-rs list chips is not a valid command.
It should be probe-rs chip list instead.

Hard fault crash after 1-2 minutes of running

I've written a simple button application based on the app-template. However, after some time of firmware being run on the STM32F027B-DISCO board, it stopped. I started to dig in and found HardFault occurred. The breakpoint in the HardFault handler in lib.rs never hit even if I press Run after the automatic stop caused by the debugger.
The repo: https://github.com/itxs/embedded_rust_learning
The screenshot of an issue:
image

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

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 ❄️

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.

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?

Print-defmt feature results into linker error

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

features = ["print-defmt"]

is not enabled in the root Cargo.toml

app-template/Cargo.toml

Lines 19 to 21 in b131e11

[dependencies.panic-probe]
git = "https://github.com/knurling-rs/probe-run"
branch = "main"

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.

semihosting on the "blue pill" board

Hello knurling-rs,

I can't seem to get semihosting to work with the app-template and my STM32F103C8T6 "blue pill" board. I'm using VSCode and the "Debugger for probe-rs" behind an STLink V2:

$ probe-rs list
The following debug probes were found:
[0]: STLink V2 (VID: 0483, PID: 3748, Serial: [...], StLink)
$ probe-rs info
Probing target via JTAG

ARM Chip:
Debug Port: Version 1, DP Designer: ARM Ltd
└── 0 MemoryAP
    └── ROM Table (Class 1)
        ├── Cortex-M3 SCS   (Generic IP component)
        │   └── CPUID
        │       ├── IMPLEMENTER: ARM Ltd
        │       ├── VARIANT: 1
        │       ├── PARTNO: 3107
        │       └── REVISION: 1
        ├── Cortex-M3 DWT   (Generic IP component)
        ├── Cortex-M3 FBP   (Generic IP component)
        ├── Cortex-M3 ITM   (Generic IP component)
        └── Cortex-M3 TPIU  (Coresight Component)

[...]

Now, whenever I start debugging anything, I end up in line 212 of cortex-m-semihosting/src/lib.rs, indicative of a failed semihosting attempt.

In a more "bare" setup (without knurling-rs, using the "Cortex-Debug" VSC extension and a manually setup "cargo build" prelaunch task) I was able to resolve the same issue leveraging "preLaunchCommands" for the gdb process, i.e. "monitor arm semihosting enable". I can't seem to find a similar setting with the arguably better approach using probe-rs and knurling.

I've selfhosted both experimental projects in my gitea instance and added a containers.dev config for convenience.

Any ideas forward?

Crossposted at probe-rs/vscode/issues/89

Update to `defmt 0.3`

We should update the template to defmt 0.3 and release the new template at the same time as defmt.

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

Use opt-level=z again

This was removed in #2 to work around a rustc bug. It should be restored once that bug is fixed and in stable.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.