riscv-rust / riscv-rust-quickstart

A template for building Rust applications for HiFive1 boards
205 stars 24 forks source link

Needs some love before transferring to rust-embedded #2

Closed dvc94ch closed 5 years ago

dvc94ch commented 6 years ago

We should probably deprecate riscv-crates in favor of this crate.

danc86 commented 6 years ago

I was just looking through what there is now in src/main.rs... Do we want it updated to use the embedded-hal stuff, like the examples in riscv-crates are doing?

I started going through to try and convert (mostly by copy-paste...) but the program that is in there right now doesn't easily translate into embedded-hal's resource management model.

In particular it wants to manipulate the LEDs and CLINT inside the interrupt handler, which doesn't work with embedded-hal's model of resource ownership. I guess that is what rtfm was invented for.

Maybe the best approach is to just have a really simple placeholder program in src/main.rs (maybe just "hello world" on the UART) and then move all the other examples from riscv-crates into here as cargo examples?

Let me know what you prefer and I can post a PR for it.

dvc94ch commented 6 years ago

One problem is that the e310x, e310x-hal and hifive crates are not part of the rust-embedded org. The question is if the quickstart template that will be part of the rust-embedded org should use those crates @japaric?

Maybe we want a riscv-quickstart that uses only the riscv/riscv-rt crates and a hifive-quickstart that we keep here.

dvc94ch commented 6 years ago

@danc86 who ever does the work can decide... Your suggestions sound reasonable.

japaric commented 6 years ago

@dvc94ch

One problem is that the e310x, e310x-hal and hifive crates are not part of the rust-embedded org.

in general we prefer to only maintain general purpose crates in the org. In one of the previous meeting we decided avoiding adding board / microcontroller specific crates to the org because that might "avalanche" and we could end up maintaining lots of board specific crates in the org -- though we may make exceptions to this rule in the future (e.g. for highly popular boards, or to have a reference implementation of embedded-hal).

RISCV is a bit special because there are only a few boards in existence right now but that will not always be the case. I would suggest leaving the board specific crates our of the org for now and revisit the decision when there are more hardware implementations out there. Ultimately, taking a decision here is up to the riscv team.

danc86 commented 6 years ago

Yeah that makes sense. I guess there is no reason that this quickstart template couldn't depend on the board-specific crates though, right?

I was thinking of trying to write a minimal src/main.rs that doesn't use any embedded-hal, only depending on riscv and riscv-rt. Maybe just blink some LEDs and write to the UART. Actually a direct port of the Sifive led_fade demo that ships on the Hifive1 might be neat. (Not sure how messy that code will turn out to be though...)

And then we could collect the various other examples in here as well, they would have progressively more dependencies on embedded-hal, the board-specific crates, rtfm, stlog, etc.

Disasm commented 5 years ago

Some love was delivered, but I see no reason to transfer this to rust-embedded. New boards and chips appeared on the market, even multi-core and 64-bit ones. These chips are quite incompatible with FE310, they need their own templates. Despite HiFive1 boards are popular, they are quite expensive and I expect them to lose popularity in the future.

dvc94ch commented 5 years ago

Ok