-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'hifive1/master' into cargo-workspace-hi…
…five1
- Loading branch information
Showing
20 changed files
with
932 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @rust-embedded/riscv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Cargo.lock | ||
target/ | ||
core | ||
.gdb_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [Unreleased] | ||
- Use inline assembly instead of binary blobs for flash | ||
|
||
## [v0.12.0] - 2023-03-28 | ||
- Update e310x-hal to v0.11 with new svd2rust generated code | ||
|
||
## [v0.11.0] - 2023-03-03 | ||
|
||
### Changed | ||
- Updated riscv dependency to v0.10 with interrupt/critical section changes | ||
|
||
## [v0.10.0] - 2021-07-15 | ||
|
||
### Added | ||
|
||
- Added [SparkFun Red-V RedBoard](https://www.sparkfun.com/products/15594)` support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "hifive1" | ||
version = "0.12.0" | ||
repository = "https://github.com/riscv-rust/hifive1" | ||
authors = ["David Craven <[email protected]>"] | ||
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" | ||
|
||
[dependencies] | ||
e310x-hal = "0.11.0" | ||
embedded-hal = "0.2.7" | ||
riscv = "0.10.1" | ||
nb = "1.0.0" | ||
|
||
[features] | ||
board-hifive1 = [] | ||
board-hifive1-revb = ["e310x-hal/g002"] | ||
board-redv = ["e310x-hal/g002"] | ||
board-lofive = [] | ||
board-lofive-r1 = ["e310x-hal/g002"] | ||
|
||
[package.metadata.docs.rs] | ||
features = ['board-hifive1-revb'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[![crates.io](https://img.shields.io/crates/d/hifive1.svg)](https://crates.io/crates/hifive1) | ||
[![crates.io](https://img.shields.io/crates/v/hifive1.svg)](https://crates.io/crates/hifive1) | ||
[![Build Status](https://travis-ci.org/riscv-rust/hifive1.svg?branch=master)](https://travis-ci.org/riscv-rust/hifive1) | ||
|
||
# `hifive1` | ||
|
||
> Board support crate for HiFive1 and LoFive boards | ||
## Supported Boards | ||
|
||
* [SiFive Hifive1](https://www.sifive.com/boards/hifive1) - use feature `board-hifive1` | ||
* [SiFive Hifive1 RevB](https://www.sifive.com/boards/hifive1-rev-b) - use feature `board-hifive1-revb` | ||
* [SparkFun Red-V RedBoard](https://www.sparkfun.com/products/15594) - use feature `board-redv` | ||
* [lofive1](https://github.com/mwelling/lofive) - use feature `board-lofive` | ||
* [lofive1-r1](https://github.com/mwelling/lofive) - use feature `board-lofive-r1` | ||
|
||
## [Documentation](https://docs.rs/crate/hifive1) | ||
|
||
## Minimum Supported Rust Version (MSRV) | ||
|
||
This crate is guaranteed to compile on stable Rust 1.59.0 and up. It *might* | ||
compile with older versions but that may change in any new patch release. | ||
|
||
## License | ||
|
||
Copyright 2018-2023 [RISC-V team][team] | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose | ||
with or without fee is hereby granted, provided that the above copyright notice | ||
and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. | ||
|
||
## Code of Conduct | ||
|
||
Contribution to this crate is organized under the terms of the [Rust Code of | ||
Conduct][CoC], the maintainer of this crate, the [RISC-V team][team], promises | ||
to intervene to uphold that code of conduct. | ||
|
||
[CoC]: CODE_OF_CONDUCT.md | ||
[team]: https://github.com/rust-embedded/wg#the-risc-v-team |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::path::PathBuf; | ||
use std::{env, fs}; | ||
|
||
fn main() { | ||
// Put the memory definitions somewhere the linker can find it | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
println!("cargo:rustc-link-search={}", out_dir.display()); | ||
|
||
let boards: Vec<_> = env::vars() | ||
.filter_map(|(key, _value)| { | ||
if key.starts_with("CARGO_FEATURE_BOARD") { | ||
Some(key[20..].to_ascii_lowercase()) // Strip 'CARGO_FEATURE_BOARD_' | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect(); | ||
|
||
if boards.is_empty() { | ||
panic!("No board features selected"); | ||
} | ||
if boards.len() > 1 { | ||
panic!("More than one board feature selected: {:?}", boards); | ||
} | ||
|
||
let board = boards.first().unwrap(); | ||
|
||
match board.as_str() { | ||
"hifive1" => { | ||
fs::copy("memory-hifive1.x", out_dir.join("hifive1-memory.x")).unwrap(); | ||
println!("cargo:rerun-if-changed=memory-hifive1.x"); | ||
} | ||
"hifive1_revb" | "redv" => { | ||
fs::copy("memory-hifive1-revb.x", out_dir.join("hifive1-memory.x")).unwrap(); | ||
println!("cargo:rerun-if-changed=memory-hifive1-revb.x"); | ||
} | ||
"lofive" | "lofive_r1" => { | ||
fs::copy("memory-lofive-r1.x", out_dir.join("hifive1-memory.x")).unwrap(); | ||
println!("cargo:rerun-if-changed=memory-lofive-r1.x"); | ||
} | ||
|
||
other => panic!("Unknown board: {}", other), | ||
} | ||
|
||
fs::copy("hifive1-link.x", out_dir.join("hifive1-link.x")).unwrap(); | ||
println!("cargo:rerun-if-changed=hifive1-link.x"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INCLUDE hifive1-memory.x | ||
INCLUDE link.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
INCLUDE device.x | ||
MEMORY | ||
{ | ||
FLASH : ORIGIN = 0x20000000, LENGTH = 4M | ||
} | ||
|
||
REGION_ALIAS("REGION_TEXT", FLASH); | ||
REGION_ALIAS("REGION_RODATA", FLASH); | ||
REGION_ALIAS("REGION_DATA", RAM); | ||
REGION_ALIAS("REGION_BSS", RAM); | ||
REGION_ALIAS("REGION_HEAP", RAM); | ||
REGION_ALIAS("REGION_STACK", RAM); | ||
|
||
/* Skip first 64k allocated for bootloader */ | ||
_stext = 0x20010000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
INCLUDE device.x | ||
MEMORY | ||
{ | ||
FLASH : ORIGIN = 0x20000000, LENGTH = 16M | ||
} | ||
|
||
REGION_ALIAS("REGION_TEXT", FLASH); | ||
REGION_ALIAS("REGION_RODATA", FLASH); | ||
REGION_ALIAS("REGION_DATA", RAM); | ||
REGION_ALIAS("REGION_BSS", RAM); | ||
REGION_ALIAS("REGION_HEAP", RAM); | ||
REGION_ALIAS("REGION_STACK", RAM); | ||
|
||
/* Skip first 4M allocated for bootloader */ | ||
_stext = 0x20400000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
INCLUDE device.x | ||
MEMORY | ||
{ | ||
FLASH : ORIGIN = 0x20000000, LENGTH = 16M | ||
} | ||
|
||
REGION_ALIAS("REGION_TEXT", FLASH); | ||
REGION_ALIAS("REGION_RODATA", FLASH); | ||
REGION_ALIAS("REGION_DATA", RAM); | ||
REGION_ALIAS("REGION_BSS", RAM); | ||
REGION_ALIAS("REGION_HEAP", RAM); | ||
REGION_ALIAS("REGION_STACK", RAM); | ||
|
||
/* Skip first 4M allocated for bootloader */ | ||
_stext = 0x20400000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//! Board-specific clock configuration | ||
use e310x_hal::{ | ||
clock::{AonExt, Clocks, PrciExt}, | ||
e310x::{AONCLK, PRCI}, | ||
time::Hertz, | ||
}; | ||
|
||
#[cfg(any( | ||
feature = "board-hifive1", | ||
feature = "board-hifive1-revb", | ||
feature = "board-redv" | ||
))] | ||
/// Configures clock generation system. | ||
/// | ||
/// 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 { | ||
let coreclk = prci.constrain(); | ||
let coreclk = coreclk | ||
.use_external(Hertz(16_000_000)) | ||
.coreclk(target_coreclk); | ||
|
||
let aonclk = aonclk.constrain(); | ||
let aonclk = aonclk.use_external(Hertz(32_768)); | ||
|
||
Clocks::freeze(coreclk, aonclk) | ||
} | ||
|
||
#[cfg(any(feature = "board-lofive", feature = "board-lofive-r1"))] | ||
/// Configures clock generation system. | ||
/// | ||
/// 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 { | ||
let coreclk = prci.constrain(); | ||
let coreclk = coreclk | ||
.use_external(Hertz(16_000_000)) | ||
.coreclk(target_coreclk); | ||
|
||
let aonclk = aonclk.constrain(); | ||
|
||
Clocks::freeze(coreclk, aonclk) | ||
} |
Oops, something went wrong.