knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
645 stars 75 forks source link

ITM support #270

Closed sourcebox closed 2 years ago

sourcebox commented 2 years ago

I'm currently using ITM for log messages via the itm_logger crate. This works with openocd, but I see no option to use this here. It seems that probe-rs has some support for it already.

Urhengulas commented 2 years ago

Hello @sourcebox 👋🏾

You can use https://crates.io/crates/defmt-itm to log your defmt-messages over itm. If you used the app-template to get started, just replace defmt_rtt with defmt_itm (link):

use defmt_rtt as _; // global logger

Does this help you?

sourcebox commented 2 years ago

I think, I don't want to use defmt in my project. It's a great thing, but it doesn't give me any advantage because I have to use core::fmt::Write in my code anyway. So it would just add complexity without reducing code size.

Urhengulas commented 2 years ago

I see. What is your usecase for probe-run then? Acutally it does make sense. Sorry for the confusion.

sourcebox commented 2 years ago

As far as I understand probe-run it can be used as simpler alternative to openocd.

Urhengulas commented 2 years ago

As far as I understand probe-run it can be used as simpler alternative to openocd.

Yes. But it currently only supports rtt. Do you use itm via your probe?

sourcebox commented 2 years ago

Yes, I'm using an ST-Link via OpenOCD/GDB, then VS Code to dump the ITM messages.

Urhengulas commented 2 years ago

In this setup itm, would be an option, but rtt is also. Why do you choose itm over rtt?

sourcebox commented 2 years ago

Isn't a J-Link required for RTT?

Urhengulas commented 2 years ago

TIL. That's the problem if you only work with j-links 😅

sourcebox commented 2 years ago

I have access to a J-Link, but as my projects are usually passed to colleagues and customers, this requirement is often not fulfilled.

Urhengulas commented 2 years ago

I see. I will investigate internally and come back to you 😁

Urhengulas commented 2 years ago

@sourcebox Although rtt was developed by segger, it should still work with other probes, including the st-links.

Can you please try if rtt + st-link works, and report if there is an error? For a minimal example refer to github.com/knurling-rs/app-template.

sourcebox commented 2 years ago

This works! Very nice. So RTT can be used with ST-Link also.

Urhengulas commented 2 years ago

Seems like it. Have fun with it!