From ad0074141e12e96a5530d84c79a658abb439f276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Mon, 7 Oct 2024 19:20:14 +0200 Subject: [PATCH] adapt to Cargo workspace --- .github/workflows/changelog.yaml | 10 +++++ .github/workflows/hifive1.yaml | 52 ++++++++++++++++++++++ Cargo.toml | 1 + hifive1/.github/CODEOWNERS | 1 - hifive1/.github/bors.toml | 10 ----- hifive1/.github/workflows/ci.yaml | 61 -------------------------- hifive1/.github/workflows/rustfmt.yaml | 24 ---------- hifive1/.gitignore | 4 -- hifive1/CHANGELOG.md | 2 + hifive1/CODE_OF_CONDUCT.md | 37 ---------------- hifive1/Cargo.toml | 9 ++-- hifive1/src/clock.rs | 6 +-- hifive1/src/flash.rs | 6 +-- hifive1/src/gpio.rs | 12 ++--- hifive1/src/lib.rs | 5 +++ hifive1/src/stdout.rs | 8 ++-- 16 files changed, 91 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/hifive1.yaml delete mode 100644 hifive1/.github/CODEOWNERS delete mode 100644 hifive1/.github/bors.toml delete mode 100644 hifive1/.github/workflows/ci.yaml delete mode 100644 hifive1/.github/workflows/rustfmt.yaml delete mode 100644 hifive1/.gitignore delete mode 100644 hifive1/CODE_OF_CONDUCT.md diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml index 61dcc37..3de2072 100644 --- a/.github/workflows/changelog.yaml +++ b/.github/workflows/changelog.yaml @@ -21,6 +21,8 @@ jobs: - 'e310x/**' e310x-hal: - 'e310x-hal/**' + hifive1: + - 'hifive1/**' - name: Check for CHANGELOG.md (e310x) if: steps.changes.outputs['e310x'] == 'true' @@ -37,4 +39,12 @@ jobs: changeLogPath: ./e310x-hal/CHANGELOG.md skipLabels: 'skip changelog' missingUpdateErrorMessage: 'Please add a changelog entry in the e310x-hal/CHANGELOG.md file.' + + - name: Check for CHANGELOG.md (hifive1) + if: steps.changes.outputs['hifive1'] == 'true' + uses: dangoslen/changelog-enforcer@v3 + with: + changeLogPath: ./hifive1/CHANGELOG.md + skipLabels: 'skip changelog' + missingUpdateErrorMessage: 'Please add a changelog entry in the hifive1/CHANGELOG.md file.' \ No newline at end of file diff --git a/.github/workflows/hifive1.yaml b/.github/workflows/hifive1.yaml new file mode 100644 index 0000000..27e5efd --- /dev/null +++ b/.github/workflows/hifive1.yaml @@ -0,0 +1,52 @@ +on: + push: + branches: [ master ] + pull_request: + merge_group: + +name: Build check (hifive1) + +jobs: + # We check that the crate builds and links for all the toolchains and targets. + build-riscv: + strategy: + matrix: + # All generated code should be running on stable now, MRSV is 1.70.0 + toolchain: [nightly, stable, 1.70.0] + board: [hifive1, hifive1-revb, redv, lofive, lofive-r1] + include: + # Nightly is only for reference and allowed to fail + - toolchain: nightly + experimental: true + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental || false }} + steps: + - uses: actions/checkout@v4 + - name: Update Rust toolchain + run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - name: Install Rust target + run: rustup target install riscv32imc-unknown-none-elf + - name: Build (direct) + run: cargo build --package hifive1 --features board-${{ matrix.board }} + - name: Build (vectored) + run: cargo build --package hifive1 --features board-${{ matrix.board }},virq + + # On MacOS and Ubuntu, we at least make sure that the crate builds and links. + # On Windows, linking fails when the rt feature is enabled. + build-others: + strategy: + matrix: + os: [ macos-latest, ubuntu-latest ] + board: [hifive1, hifive1-revb, redv, lofive, lofive-r1] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Update Rust toolchain + run: rustup update stable && rustup default stable + - name: Rename .cargo/config to .cargo/config.bak to ignore it + run: mv .cargo/config.toml .cargo/config.bak + - name: Build (direct) + run: cargo test --package hifive1 --features board-${{ matrix.board }} + - name: Build (vectored) + run: cargo test --package hifive1 --features board-${{ matrix.board }},virq + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index b29765b..2cdd788 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,5 @@ resolver = "2" members = [ "e310x", "e310x-hal", + "hifive1", ] diff --git a/hifive1/.github/CODEOWNERS b/hifive1/.github/CODEOWNERS deleted file mode 100644 index 87f6c03..0000000 --- a/hifive1/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @rust-embedded/riscv \ No newline at end of file diff --git a/hifive1/.github/bors.toml b/hifive1/.github/bors.toml deleted file mode 100644 index ca7d72a..0000000 --- a/hifive1/.github/bors.toml +++ /dev/null @@ -1,10 +0,0 @@ -block_labels = ["needs-decision"] -delete_merged_branches = true -required_approvals = 1 -status = [ - "ci-linux (stable)", - "ci-linux (1.59.0)", - "build-other (macOS-latest)", - "build-other (windows-latest)", - "Rustfmt" -] diff --git a/hifive1/.github/workflows/ci.yaml b/hifive1/.github/workflows/ci.yaml deleted file mode 100644 index 8f219a4..0000000 --- a/hifive1/.github/workflows/ci.yaml +++ /dev/null @@ -1,61 +0,0 @@ -on: - push: - branches: [ staging, trying, master ] - pull_request: - -name: Continuous integration - -jobs: - ci-linux: - runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.experimental || false }} - strategy: - matrix: - # All generated code should be running on stable now, MRSV is 1.59.0 - rust: [nightly, stable, 1.59.0] - - include: - # Nightly is only for reference and allowed to fail - - rust: nightly - experimental: true - - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - name: Install all Rust targets for ${{ matrix.rust }} - run: rustup target install --toolchain=${{ matrix.rust }} x86_64-unknown-linux-gnu riscv32imac-unknown-none-elf riscv64imac-unknown-none-elf riscv64gc-unknown-none-elf - - name: Run CI script for riscv32imac-unknown-none-elf under ${{ matrix.rust }} - run: | - cargo check --target riscv32imac-unknown-none-elf --features board-hifive1 - cargo check --target riscv32imac-unknown-none-elf --features board-hifive1-revb - cargo check --target riscv32imac-unknown-none-elf --features board-redv - cargo check --target riscv32imac-unknown-none-elf --features board-lofive - cargo check --target riscv32imac-unknown-none-elf --features board-lofive-r1 - - # On macOS and Windows, we at least make sure that the crate builds and links. - build-other: - strategy: - matrix: - os: - - macOS-latest - - windows-latest - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Build crate for host OS - run: | - cargo build --features board-hifive1 - cargo build --features board-hifive1-revb - cargo build --features board-redv - cargo build --features board-lofive - cargo build --features board-lofive-r1 \ No newline at end of file diff --git a/hifive1/.github/workflows/rustfmt.yaml b/hifive1/.github/workflows/rustfmt.yaml deleted file mode 100644 index 0727384..0000000 --- a/hifive1/.github/workflows/rustfmt.yaml +++ /dev/null @@ -1,24 +0,0 @@ - -on: - push: - branches: [ staging, trying, master ] - pull_request: - -name: Code formatting check - -jobs: - fmt: - name: Rustfmt - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check \ No newline at end of file diff --git a/hifive1/.gitignore b/hifive1/.gitignore deleted file mode 100644 index becb52e..0000000 --- a/hifive1/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Cargo.lock -target/ -core -.gdb_history \ No newline at end of file diff --git a/hifive1/CHANGELOG.md b/hifive1/CHANGELOG.md index e229ad8..37ba143 100644 --- a/hifive1/CHANGELOG.md +++ b/hifive1/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Bump MSRV to 1.65 +- Adapt to new Cargo workspace - Use inline assembly instead of binary blobs for flash ## [v0.12.0] - 2023-03-28 diff --git a/hifive1/CODE_OF_CONDUCT.md b/hifive1/CODE_OF_CONDUCT.md deleted file mode 100644 index fccadf9..0000000 --- a/hifive1/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,37 +0,0 @@ -# The Rust Code of Conduct - -## Conduct - -**Contact**: [RISC-V team](https://github.com/rust-embedded/wg#the-riscv-team) - -* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. -* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all. -* Please be kind and courteous. There's no need to be mean or rude. -* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. -* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. -* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the [Citizen Code of Conduct](http://citizencodeofconduct.org/); if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. -* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [RISC-V team][team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. -* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome. - -## Moderation - -These are the policies for upholding our community's standards of conduct. - -1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) -2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed. -3. Moderators will first respond to such remarks with a warning. -4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off. -5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded. -6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology. -7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed. -8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others. - -In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely. - -And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. - -The enforcement policies listed above apply to all official embedded WG venues; including official IRC channels (#rust-embedded); GitHub repositories under rust-embedded; and all forums under rust-embedded.org (forum.rust-embedded.org). - -*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* - -[team]: https://github.com/rust-embedded/wg#the-riscv-team diff --git a/hifive1/Cargo.toml b/hifive1/Cargo.toml index d875ffd..edf2632 100644 --- a/hifive1/Cargo.toml +++ b/hifive1/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "hifive1" -version = "0.12.0" +version = "0.13.0" repository = "https://github.com/riscv-rust/hifive1" authors = ["David Craven "] categories = ["embedded", "hardware-support", "no-std"] description = "Board support crate for HiFive1 and LoFive boards" keywords = ["riscv", "register", "peripheral"] license = "ISC" -edition = "2018" -rust-version = "1.59" +edition = "2021" +rust-version = "1.65" [dependencies] -e310x-hal = "0.11.0" +e310x-hal = { path = "../e310x-hal", version = "0.11.0" } embedded-hal = "0.2.7" riscv = "0.10.1" nb = "1.0.0" @@ -22,6 +22,7 @@ board-hifive1-revb = ["e310x-hal/g002"] board-redv = ["e310x-hal/g002"] board-lofive = [] board-lofive-r1 = ["e310x-hal/g002"] +virq = ["e310x-hal/virq"] [package.metadata.docs.rs] features = ['board-hifive1-revb'] diff --git a/hifive1/src/clock.rs b/hifive1/src/clock.rs index 05bd348..d91867a 100644 --- a/hifive1/src/clock.rs +++ b/hifive1/src/clock.rs @@ -2,7 +2,7 @@ use e310x_hal::{ clock::{AonExt, Clocks, PrciExt}, - e310x::{AONCLK, PRCI}, + e310x::{Aonclk, Prci}, time::Hertz, }; @@ -15,7 +15,7 @@ use e310x_hal::{ /// /// For HiFive1 and HiFive1 Rev B boards external oscillators are enabled for /// both high-frequency and low-frequency clocks. -pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks { +pub fn configure(prci: Prci, aonclk: Aonclk, target_coreclk: Hertz) -> Clocks { let coreclk = prci.constrain(); let coreclk = coreclk .use_external(Hertz(16_000_000)) @@ -32,7 +32,7 @@ pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks { /// /// For the LoFive and LoFive R1 boards, external oscillator is enabled for /// high-frequency clock. For low-frequency clock internal oscillator is used. -pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks { +pub fn configure(prci: Prci, aonclk: Aonclk, target_coreclk: Hertz) -> Clocks { let coreclk = prci.constrain(); let coreclk = coreclk .use_external(Hertz(16_000_000)) diff --git a/hifive1/src/flash.rs b/hifive1/src/flash.rs index 4208379..71c2992 100644 --- a/hifive1/src/flash.rs +++ b/hifive1/src/flash.rs @@ -1,7 +1,7 @@ //! On-board SPI Flash use e310x_hal::clock::Clocks; -use e310x_hal::e310x::QSPI0; +use e310x_hal::e310x::Qspi0; #[cfg(target_arch = "riscv32")] core::arch::global_asm!( @@ -55,7 +55,7 @@ core::arch::global_asm!( /// Configure SPI Flash interface to maximum supported speed #[inline(always)] -pub fn configure_spi_flash(qspi: &QSPI0, clocks: &Clocks) { +pub fn configure_spi_flash(qspi: &Qspi0, clocks: &Clocks) { unsafe { extern "C" { fn _setup_is25lp(dummy8: bool); @@ -67,5 +67,5 @@ pub fn configure_spi_flash(qspi: &QSPI0, clocks: &Clocks) { _setup_is25lp(true) } } - qspi.sckdiv.modify(|_, w| unsafe { w.div().bits(0) }); + qspi.sckdiv().modify(|_, w| unsafe { w.div().bits(0) }); } diff --git a/hifive1/src/gpio.rs b/hifive1/src/gpio.rs index 4ba26e8..abb2d74 100644 --- a/hifive1/src/gpio.rs +++ b/hifive1/src/gpio.rs @@ -12,8 +12,8 @@ /// /// # Example /// -/// ``` -/// let mosi = pin!(gpio, spi0_mosi); // gpio.pin3 +/// ```ignore +/// let mosi = hifive1::pin!(gpio, spi0_mosi); // gpio.pin3 /// ``` /// #[macro_export] @@ -143,8 +143,8 @@ macro_rules! pin { /// /// # Example /// -/// ``` -/// let mosi = pin!(gpio, spi0_mosi); // gpio.pin3 +/// ```ignore +/// let mosi = hifive1::pin!(gpio, spi0_mosi); // gpio.pin3 /// ``` /// #[macro_export] @@ -268,8 +268,8 @@ macro_rules! pin { /// /// # Example /// -/// ``` -/// let (mosi, miso, sck, cs) = pins!(gpio, (spi0_mosi, spi0_miso, spi0_sck, spi0_ss0)); +/// ```ignore +/// let (mosi, miso, sck, cs) = hifive1::pins!(gpio, (spi0_mosi, spi0_miso, spi0_sck, spi0_ss0)); /// // (gpio.pin3, gpio.pin4, gpio.pin5, gpio.pin2) /// ``` /// diff --git a/hifive1/src/lib.rs b/hifive1/src/lib.rs index 9ed422b..f05de91 100644 --- a/hifive1/src/lib.rs +++ b/hifive1/src/lib.rs @@ -25,4 +25,9 @@ pub mod stdout; pub use stdout::configure as configure_stdout; #[doc(hidden)] +#[cfg(any( + feature = "board-hifive1", + feature = "board-hifive1-revb", + feature = "board-redv" +))] pub mod gpio; diff --git a/hifive1/src/stdout.rs b/hifive1/src/stdout.rs index 829cbbd..59be531 100644 --- a/hifive1/src/stdout.rs +++ b/hifive1/src/stdout.rs @@ -3,7 +3,7 @@ use core::fmt; use e310x_hal::{ clock::Clocks, - e310x::UART0, + e310x::Uart0, gpio::gpio0::{Pin16, Pin17}, prelude::*, serial::{Rx, Serial, Tx}, @@ -14,7 +14,7 @@ use riscv::interrupt; static mut STDOUT: Option = None; -struct SerialWrapper(Tx); +struct SerialWrapper(Tx); impl core::fmt::Write for SerialWrapper { fn write_str(&mut self, s: &str) -> fmt::Result { @@ -39,12 +39,12 @@ impl core::fmt::Write for SerialWrapper { /// Configures stdout pub fn configure( - uart: UART0, + uart: Uart0, tx: Pin17, rx: Pin16, baud_rate: Bps, clocks: Clocks, -) -> Rx { +) -> Rx { let tx = tx.into_iof0(); let rx = rx.into_iof0(); let serial = Serial::new(uart, (tx, rx), baud_rate, clocks);