defmt icon indicating copy to clipboard operation
defmt copied to clipboard

defmt-rtt: Update to critical-section 1.0

Open Dirbaio opened this issue 2 years ago • 2 comments

This is a breaking change, because 1.0 no longer supplies any critical section implementation by default. The user has to opt-in to one instead (for example, by enabling the critical-section-single-core feature in cortex-m: https://github.com/rust-embedded/cortex-m/pull/447#issuecomment-1210935188).

Thankfully it needs bumping only defmt-rtt, and not defmt. So it won't cause the painful ecosystem split like the defmt 0.2 -> 0.3 update.

TODO before merging:

  • [x] Wait for critical-section 1.0 release https://github.com/rust-embedded/critical-section/pull/19

Dirbaio avatar Aug 10 '22 17:08 Dirbaio

Thank you for the PR. Is there the possibility to make defmt-rtt enable the critical-section-single-core feature or does it always need to be done by the end user?

Urhengulas avatar Aug 11 '22 09:08 Urhengulas

Is there the possibility to make defmt-rtt enable the critical-section-single-core feature or does it always need to be done by the end user?

Has to be done by the end user.

They might be using a multicore chip, in which case using cortex-m/critical-section-single-core would be unsound. They'd need to use another impl, likely from the chip's HAL, using spinlocks to sync the multiple cores. rp2040-hal has one like this, for example.

Or they might not be using cortex-m at all :)

If defmt-rtt force-enables cortex-m/critical-section-single-core, the user can't use other critical section implementations at all (enabling 2 impls on the same binary intentionally causes linking to fail).

Dirbaio avatar Aug 11 '22 11:08 Dirbaio

There is a small concern of getting the defmt-rtt and defmt version out of sync, which might be confusing to users. But I think we can resolve this soonish.

Additionally, can you please add a section explaining the need to opt-in to a implementation to the docs.rs docs (the doc-comment in the beginning of lib.rs).

Urhengulas avatar Aug 26 '22 08:08 Urhengulas

@Urhengulas

There is a small concern of getting the defmt-rtt and defmt version out of sync, which might be confusing to users.

This is unavoidable if you want to keep compatibility in the main defmt crate. Updating defmt is super problematic. You can't mix major versions of it in the same binary, so if a lib you want to use uses defmt 0.3 you're stuck on that version. This is not a problem for defmt-rtt. It's only used from the main binary, so the end user chooses the version, which can be defmt-rtt 0.4 which is compatible with defmt 0.3.

But I think we can resolve this soonish.

I hope it doesn't mean defmt 0.4, right? :cold_sweat:

Additionally, can you please add a section explaining the need to opt-in to a implementation to the docs.rs docs (the doc-comment in the beginning of lib.rs).

Done!

Dirbaio avatar Sep 04 '22 22:09 Dirbaio

Additionally, can you please add a section explaining the need to opt-in to a implementation to the docs.rs docs (the doc-comment in the beginning of lib.rs).

Done!

Thanks 😄

I hope it doesn't mean defmt 0.4, right? 😰

No no. We want to avoid that as well. We were just thinking how to make it easier for the users. We decided that it is good enough if we document which defmt and defmt-rtt versions are compatible with one another.

Urhengulas avatar Sep 05 '22 06:09 Urhengulas

bors r+

Urhengulas avatar Sep 05 '22 06:09 Urhengulas

Build succeeded:

bors[bot] avatar Sep 05 '22 07:09 bors[bot]