Skip to content

Consistent development experience #44

Closed
@japaric

Description

@japaric

Ideally the development experience for the different embedded targets should be very similar so a
user can easily transition from one target to the target instead of having to redo the setup
process, learn about new tools, learn a new development process, migrate to different crates that
basically do the same things as the ones they were previously using, etc.

This problem can be tackled from different sides:

  • Tooling

It should be possible to use Xargo Cargo, the RLS and some IDE to do development for all the
embedded targets. One click "build, flash and debug" functionality should be present.

I had reports that VS Code plus the cortex-debug plugin works fine for Cortex-M development. The
plugin also has support for printing semihosting and ITM output to the console.

A CLI equivalent should also exist. For example, two subcommands like cargo flash and cargo debug should Do The Right Thing for each embedded target. This may require the user to specify, for
example, what parameters to pass to OpenOCD in some configuration file.

  • Same starting point

Ideally a minimal embedded program should look like this:

#![no_std]

// provides the entry point
extern crate arch_specific_crate;

fn main() {
    // and optionally some debugger based logging functionality
    log!("Hello, world!")
}

for all the embedded targets. This can be accomplish by standardizing a crate like cortex-m-rt and
replicating it for all the embedded targets, and by providing Cargo project templates (with linker
scripts, etc.) for each embedded target.

Cargo doesn't currently provide support for project templates (there was a pre-RFC discussion
months ago but it didn't go anywhere). The solution currently adopted in Cortex-M land is to just
cargo clone a crate from crates.io that serves as a template and go from there (cf.
cortex-m-quickstart). We could adopt that solution or push for proper project template support
in Cargo.

  • Large set of reusable crates

One of Rust's strengths is the crates.io ecosystem. Unfortunately most of the crates.io ecosystem
can't be used in no_std context. There are several reasons for this: the author is not aware that
their crate is compatible with no_std, the author is not willing to depend on unstable crates like
alloc to support no_std, etc.; but hopefully the portability WG will work on this issue.

There's currently an on going community effort of producing generic driver crates (crates to
interface external devices like sensors) that work with any platform that has an implementation of
the embedded-hal traits. Most of the participants are Cortex-M developers; to ensure these
crates and the embedded-hal abstractions work with all the other embedded targets AVR, MSP430 and
RISCV developers must also participate.

  • Ports of multitasking models

There are a few ways to do multitasking on bare metal: RTFM, a Tokio-like cooperative event loop,
good old threads, etc. All these multitasking models should be available for all the embedded
targets. Ideally the different ports of these models should expose the same or very similar APIs.

For more details about multitasking models check issue #45

cc @dvc94ch @pftbest @dylanmckay

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions