Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defmt with rtic #450

Closed
davidlattimore opened this issue Apr 16, 2021 · 5 comments
Closed

defmt with rtic #450

davidlattimore opened this issue Apr 16, 2021 · 5 comments
Labels
difficulty: medium Somewhat difficult to solve type: question A question that isn't answered by the docs

Comments

@davidlattimore
Copy link

I'm not sure whether to file this under rtic or defmt, but I'm having trouble using these together.

When I do, I get this:

    Finished dev [optimized + debuginfo] target(s) in 1.06s
     Running `probe-run --probe '0483:374b' --chip stm32g071 target/thumbv6m-none-eabi/debug/application`
  (HOST) INFO  flashing program (4.99 KiB)
  (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.
- Depending on the target, sleep modes can interfere with RTT.

That's when I do cargo run with an stm32g071 dev board attached. Relatively minimal source directory attached:

defmt_and_rtic.tar.gz

If I comment out the rtic code and uncomment the regular #[entry], then it works as expected.

Is it expected that these can't work together, or is there something I can do to make it work?

Thanks for defmt by the way, it's been awesome.

@mattico
Copy link
Contributor

mattico commented Apr 16, 2021

If I remember correctly, I had this issue when I used wfi in my idle function rather than just looping.

@Dirbaio
Copy link
Contributor

Dirbaio commented Apr 16, 2021

Apply this workaround in init: probe-rs/probe-rs#350 (comment)

You'll probably have to adjust it for the g0.

@davidlattimore
Copy link
Author

Thank you. Both solutions worked!

I had no idle function, which presumably meant that rtic was putting the CPU to sleep. Adding an idle function with a loop made it work:

#[idle]
    fn idle(_ctx: idle::Context) -> ! {
        loop {}
    }

Alternatively, based of @Dirbaio's suggestion, adding the following to my init function fixed it.

ctx.device.RCC.ahbenr.modify(|_, w| w.dmaen().set_bit());

I now realise that probe-run mentioned in the error that "Depending on the target, sleep modes can interfere with RTT". I was thinking of sending a PR to add some documentation about how to make this work. Do you have any thoughts about where such documentation should belong? Alternatively, more detail could be added to the error - or perhaps a link to suggestions for how to resolve the problem.

@Urhengulas
Copy link
Member

Hi @davidlattimore, good to see that you were able to figure it out with the help of the community!

Such documentation would fit well into our "Troubleshooting" section in the REAMDE: https://github.com/knurling-rs/probe-run#troubleshooting
I am awaiting your PR! 😄

@Urhengulas Urhengulas added difficulty: medium Somewhat difficult to solve type: question A question that isn't answered by the docs labels Apr 20, 2021
@Urhengulas Urhengulas added this to Incoming in Issue Triage via automation Apr 20, 2021
davidlattimore added a commit to davidlattimore/probe-run that referenced this issue Apr 20, 2021
davidlattimore added a commit to davidlattimore/probe-run that referenced this issue Apr 22, 2021
bors bot added a commit to knurling-rs/probe-run that referenced this issue Apr 25, 2021
183: README.md: Add troubleshooting for use with RTIC r=Urhengulas a=davidlattimore

Additional context:
knurling-rs/defmt#450

Co-authored-by: David Lattimore <dml@google.com>
@Urhengulas
Copy link
Member

Solved by knurling-rs/probe-run#183

Issue Triage automation moved this from Incoming to Closed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium Somewhat difficult to solve type: question A question that isn't answered by the docs
Projects
No open projects
Development

No branches or pull requests

4 participants