Skip to content

Commit 9e87243

Browse files
authored
Merge pull request #132 from luojia65/luojia65/syterboot
[rust] rearrange code and implement first part of SyterBoot example
2 parents 8751b29 + 3862133 commit 9e87243

File tree

12 files changed

+412
-287
lines changed

12 files changed

+412
-287
lines changed

Cargo.lock

+20-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

board/100ask-d1-h-rs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ default-target = "riscv64imac-unknown-none-elf"
99
[dependencies]
1010
panic-halt = "0.2.0"
1111
embedded-hal = "1.0.0"
12-
syterkit = { path = "../../rust" }
12+
syterkit = { path = "../../rust", features = ["sun20iw1"]}
1313

1414
[[bin]]
1515
name = "syterkit-100ask-d1-h"

board/100ask-d1-h-rs/src/main.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
#![no_main]
33

44
use panic_halt as _;
5-
use syterkit::{entry, println, Clocks, Peripherals};
5+
use syterkit::{clock_dump, entry, println, show_banner, Clocks, Peripherals};
66

77
#[entry]
88
fn main(p: Peripherals, c: Clocks) {
9-
println!("Welcome to SyterKit 100ask-d1-h package!");
10-
println!("Please refer to each files in `bin` path for examples.");
9+
// Display the bootloader banner.
10+
show_banner();
11+
12+
// Initialize the DRAM.
13+
let dram_size = syterkit::mctl::init();
14+
println!("DRAM size: {}M 🐏", dram_size);
15+
16+
// Dump information about the system clocks.
17+
clock_dump(&p.ccu);
1118
}

rust/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
cargo-features = ["per-package-target"]
2-
31
[package]
42
name = "syterkit"
53
version = "0.0.0"
64
edition = "2021"
7-
default-target = "riscv64imac-unknown-none-elf"
85

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

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

17+
[build-dependencies]
18+
rustc_version = "0.4.1"
19+
2020
[lib]
2121
name = "syterkit"
2222
test = false
@@ -26,3 +26,5 @@ bench = false
2626
default = ["nezha"]
2727
nezha = []
2828
lichee = []
29+
30+
sun20iw1 = []

rust/build.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output();
5+
match output {
6+
Ok(output) => {
7+
let git_hash = String::from_utf8(output.stdout).unwrap();
8+
let git_hash = &git_hash[..8];
9+
println!("cargo:rustc-env=SYTERKIT_GIT_HASH={}", git_hash);
10+
}
11+
Err(e) => {
12+
panic!(
13+
"git command failed on host when compiling SyterKit: {}
14+
during compilation, git must be found, as it is used to generate the git hash version of the current package.",
15+
e
16+
);
17+
}
18+
}
19+
let syterkit_rustc_version = {
20+
let version = rustc_version::version_meta().unwrap();
21+
let hash_date_extra = match (version.commit_hash, version.commit_date) {
22+
(Some(commit_hash), Some(commit_date)) => {
23+
format!(" ({} {})", &commit_hash[..8], commit_date)
24+
}
25+
(Some(commit_hash), None) => format!(" ({})", &commit_hash[..8]),
26+
(None, Some(commit_date)) => format!(" ({})", commit_date),
27+
(None, None) => "".to_string(),
28+
};
29+
format!("{}{}", version.semver, hash_date_extra)
30+
};
31+
println!(
32+
"cargo:rustc-env=SYTERKIT_RUSTC_VERSION={}",
33+
syterkit_rustc_version
34+
);
35+
}

rust/macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "syterkit-macros"
3-
version = "0.1.0"
3+
version = "0.0.0"
44
edition = "2021"
55

66
[lib]

rust/macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syn::{
66

77
use proc_macro::TokenStream;
88

9-
/// ROM stage function entry.
9+
/// SyterKit ROM stage function entry.
1010
#[proc_macro_attribute]
1111
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
1212
let f = parse_macro_input!(input as ItemFn);

0 commit comments

Comments
 (0)