Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rust] rearrange code and implement first part of SyterBoot example #132

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ default-target = "riscv64imac-unknown-none-elf"
[dependencies]
panic-halt = "0.2.0"
embedded-hal = "1.0.0"
syterkit = { path = "../../rust" }
syterkit = { path = "../../rust", features = ["sun20iw1"]}

[[bin]]
name = "syterkit-100ask-d1-h"
Expand Down
13 changes: 10 additions & 3 deletions board/100ask-d1-h-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
#![no_main]

use panic_halt as _;
use syterkit::{entry, println, Clocks, Peripherals};
use syterkit::{clock_dump, entry, println, show_banner, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
println!("Welcome to SyterKit 100ask-d1-h package!");
println!("Please refer to each files in `bin` path for examples.");
// Display the bootloader banner.
show_banner();

// Initialize the DRAM.
let dram_size = syterkit::mctl::init();
println!("DRAM size: {}M 🐏", dram_size);

// Dump information about the system clocks.
clock_dump(&p.ccu);
}
8 changes: 5 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cargo-features = ["per-package-target"]

[package]
name = "syterkit"
version = "0.0.0"
edition = "2021"
default-target = "riscv64imac-unknown-none-elf"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -17,6 +14,9 @@ embedded-io = "0.6.1"
spin = "0.9"
syterkit-macros = { path = "macros" }

[build-dependencies]
rustc_version = "0.4.1"

[lib]
name = "syterkit"
test = false
Expand All @@ -26,3 +26,5 @@ bench = false
default = ["nezha"]
nezha = []
lichee = []

sun20iw1 = []
35 changes: 35 additions & 0 deletions rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::process::Command;

fn main() {
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output();
match output {
Ok(output) => {
let git_hash = String::from_utf8(output.stdout).unwrap();
let git_hash = &git_hash[..8];
println!("cargo:rustc-env=SYTERKIT_GIT_HASH={}", git_hash);
}
Err(e) => {
panic!(
"git command failed on host when compiling SyterKit: {}
during compilation, git must be found, as it is used to generate the git hash version of the current package.",
e
);
}
}
let syterkit_rustc_version = {
let version = rustc_version::version_meta().unwrap();
let hash_date_extra = match (version.commit_hash, version.commit_date) {
(Some(commit_hash), Some(commit_date)) => {
format!(" ({} {})", &commit_hash[..8], commit_date)
}
(Some(commit_hash), None) => format!(" ({})", &commit_hash[..8]),
(None, Some(commit_date)) => format!(" ({})", commit_date),
(None, None) => "".to_string(),
};
format!("{}{}", version.semver, hash_date_extra)
};
println!(
"cargo:rustc-env=SYTERKIT_RUSTC_VERSION={}",
syterkit_rustc_version
);
}
2 changes: 1 addition & 1 deletion rust/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "syterkit-macros"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion rust/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use syn::{

use proc_macro::TokenStream;

/// ROM stage function entry.
/// SyterKit ROM stage function entry.
#[proc_macro_attribute]
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
Expand Down
Loading
Loading