probe-rs icon indicating copy to clipboard operation
probe-rs copied to clipboard

STLink bridge interface

Open oll3 opened this issue 2 years ago • 4 comments

First of all; Thank you for developing and providing on this project, it's been of great help building custom MCU programming tools! :)

This PR is a interest check/proposal to implement the STLink (V3) bridge interface. An interface which can be used to reach the STLink GPIO/SPI/I2C/CAN interfaces when available. This PR only implements the GPIO part though. And it's missing some tests and docs.

I'm wondering if this is of interest to this project at all, and if so how it should fit with the rest of the project? In this proposal I've tried to make it generic so that other debuggers/probes could possibly implement them if they have similar functionality.

oll3 avatar Oct 09 '23 14:10 oll3

Hi, and thanks for the nice words.

I'm not sure how well this would fit into probe-rs, since it's quite different from the other functionality, and I don't know of any other probes which have similar functionality, except for maybe controlling some GPIOs.

But I wonder if it would helpful to move the st-link specific code into a separate crate? So a probe-stlink (or something else) crate, which could be used in a dedicated tool?

Tiwalun avatar Oct 09 '23 17:10 Tiwalun

Hi, and thanks for the nice words.

I'm not sure how well this would fit into probe-rs, since it's quite different from the other functionality, and I don't know of any other probes which have similar functionality, except for maybe controlling some GPIOs.

That was a bit of what I suspected too, that this might be a bit outside probe-r's main focus.

But I wonder if it would helpful to move the st-link specific code into a separate crate? So a probe-stlink (or something else) crate, which could be used in a dedicated tool?

Just to be clear... You mean move the current stlink code from probe-rs to a separerate crate which would then be a dependency of probe-rs? But have the new probe-stlink crate live under the probe-rs project? On my behalf that seems like good path forward. And I could probably put a PR like that together, if that's wanted.

oll3 avatar Oct 09 '23 18:10 oll3

Just to be clear... You mean move the current stlink code from probe-rs to a separerate crate which would then be a dependency of probe-rs? But have the new probe-stlink crate live under the probe-rs project?

Yes, I would still keep it as part of this repo, but just as a separate crate, so that it can be used by itself.

A PR would be great, happy to help here or on Matrix if you have any questions.

Tiwalun avatar Oct 15 '23 18:10 Tiwalun

Just to be clear... You mean move the current stlink code from probe-rs to a separerate crate which would then be a dependency of probe-rs? But have the new probe-stlink crate live under the probe-rs project?

Yes, I would still keep it as part of this repo, but just as a separate crate, so that it can be used by itself.

A PR would be great, happy to help here or on Matrix if you have any questions.

I did a simple try basically copying the probe-rs/src/probe/stlink and made it a separate create. But realized that its very much dependent on probe-rs. And I guess probe-rs would be dependent on probe-stlink, leading to cyclic dependencies.

Even if removing the impl of DebugProbe there are still quite a bit of references to probe-rs, like architecture/arm stuff and errors. I guess one could break out more parts of probe-rs to separate crates which could be reused, or maybe make the probe-stlink tiny, only implementing basic communication and then layer the rest on that in probe-rs.

Anyway, seems like a bit bigger task than what I thought at first glimpse and I might not be able to pull it through at this time. If you have ideas to simplify this they are of course welcome and I might continue when I can.

oll3 avatar Oct 22 '23 14:10 oll3