[RFC] multiarch support for svd2rust #120
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Background
@pftbest has been doing a great work at getting msp430 support at the
cortex-m-quickstart level by porting a bunch of cortex-m-* crates to msp430.
They also have a fork of svd2rust that can generate msp430 device crates from
msp430 SVD files.
In parallel @ahixon has been working with bare metal Cortex-A processors and
they also want to be able to use svd2rust to generate a device crate for their
Cortex-A processor.
This RFC / PR is about adding multiarch support to svd2rust to support these two
cases.
How
As @ahixon suggested this RFC proposes moving non Cortex-M bits from the
cortex-mcrate into a common crate: themcucrate. Both thecortex-mcrate and the
msp430crate, its MSP430 counterpart, will re-export the commoncode from the
mcucrate in their APIs. The shared API includes:NrtraitPeripheralstructCriticalSectionstructMutexstructAdditionally svd2rust will be tweaked to generate code that depends on the
mcucrate rather than on the
cortex-mcrate where possible.Finally, a
--targetflag that accepts the values "cortex-m", "msp430" and"none" will be added to the svd2rust tool. This flag tweaks code generation.
When "msp430" is selected the generated crate will depend on the
msp430crateand optionally (
#[cfg(feature = "rt")]) on themsp430-rtcrate. The"cortex-m" value has a similar effect. The "none" flag forces the generated
crate to not depend on any specific architecture crate.
Unresolved questions
Is there a better name for the
mcucrate?--targetor--arch?Implementation bits
cc @awygle