-
Notifications
You must be signed in to change notification settings - Fork 205
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
Provide defmt feature in BSPs, that enables atsamd-hal/defmt #810
Comments
I think part of the difficulty here is that defmt requires an addition to the linker script? |
I'm not sure I follow - yes using defmt in a firmware requires modifying the linker script, but even with that in place it's not straightforward to use defmt in a firmware that depends on a BSP directly. For example, if my firmware's Cargo.toml has something like this: [dependencies]
metro_m4 = { version = "0.16.1", features = ["usb"] } and in my firmware, I want to use something like: use metro_m4 as bsp;
use bsp::hal;
#[derive(Error, defmt::Format, Debug)]
enum Error {
#[error("UART error:")]
UartError(hal::sercom::uart::UartError),
// ...more variants...
} Currently, the only way AFAICT to do this, is to modify Cargo.toml to add a dependency on the HAL, using the same version as the BSP: [dependencies.atsamd-hal]
version = "0.20.2"
default-features = false
features = ["defmt"] What I'm proposing is that it would be nice to be able to just do: [dependencies]
metro_m4 = { version = "0.16.1", features = ["usb", "defmt"] } |
Oh, yeah, I know, I'm just saying adding the dep to the default linker script might be slightly annoying and I don't think it can be feature gated. But it's probably not an issue. Just something to consider. |
Ah, you're a step ahead of me: if the feature is enabled, but the linker script doesn't have the defmt piece, then the build fails. This means that the So yes, probably deserves a bit more thought, I'll remove the "good first issue" tag! |
In a firmware that depends on a BSP, it's a bit awkward to use defmt for types that originate in the HAL. One needs to add the same version of the HAL as the BSP uses to Cargo.toml, to enable the defmt feature.
To resolve this, we chould have all the BSPs (at least, that use a new-enough HAL) support a defmt feature themselves.
The text was updated successfully, but these errors were encountered: