mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
maybe, just maybe...we finally have version info baked into the kernel correctly.
This commit is contained in:
parent
0a1c5dc07f
commit
faa51908d7
13 changed files with 99 additions and 69 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,6 +5,8 @@
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
/emulation/peripherals.csproj
|
/emulation/peripherals.csproj
|
||||||
/emulation/obj
|
/emulation/obj
|
||||||
|
# auto-generated
|
||||||
|
services/ticktimer-server/src/version.rs
|
||||||
|
|
||||||
*.map
|
*.map
|
||||||
|
|
||||||
|
|
|
||||||
15
Cargo.lock
generated
15
Cargo.lock
generated
|
|
@ -2447,9 +2447,11 @@ dependencies = [
|
||||||
"log-server",
|
"log-server",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"rkyv",
|
||||||
"susres",
|
"susres",
|
||||||
"utralib",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
|
"xous-ipc",
|
||||||
"xous-names",
|
"xous-names",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -2563,17 +2565,6 @@ version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vergen"
|
|
||||||
version = "3.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e7141e445af09c8919f1d5f8a20dae0b20c3b57a45dee0d5823c6ed5d237f15a"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"chrono",
|
|
||||||
"rustc_version 0.4.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.0.10"
|
version = "0.0.10"
|
||||||
|
|
@ -2921,10 +2912,10 @@ name = "xtask"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
|
"chrono",
|
||||||
"curl",
|
"curl",
|
||||||
"filetime",
|
"filetime",
|
||||||
"rustc_version 0.4.0",
|
"rustc_version 0.4.0",
|
||||||
"vergen",
|
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -675,6 +675,7 @@ fn xmain() -> ! {
|
||||||
loop {
|
loop {
|
||||||
com.txrx(ComState::LOOP_TEST.verb);
|
com.txrx(ComState::LOOP_TEST.verb);
|
||||||
let ack = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds
|
let ack = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds
|
||||||
|
// TODO: offer a more robust sequence than 0x00 for detecting if sync is back...
|
||||||
if (ack & 0xff) != 0x00 { //it will read 0xdd or 0xff if the EC is actually still in reset or held up
|
if (ack & 0xff) != 0x00 { //it will read 0xdd or 0xff if the EC is actually still in reset or held up
|
||||||
log::warn!("Wf200 reset took too long, trying to re-establish link sync...{:x}", ack);
|
log::warn!("Wf200 reset took too long, trying to re-establish link sync...{:x}", ack);
|
||||||
com.txrx(ComState::LINK_SYNC.verb);
|
com.txrx(ComState::LINK_SYNC.verb);
|
||||||
|
|
|
||||||
|
|
@ -394,25 +394,6 @@ fn handle_opcode(
|
||||||
fn reader_thread(arg: usize) {
|
fn reader_thread(arg: usize) {
|
||||||
let output = unsafe { &mut *(arg as *mut implementation::OutputWriter) };
|
let output = unsafe { &mut *(arg as *mut implementation::OutputWriter) };
|
||||||
writeln!(output, "LOG: Xous Logging Server starting up...").unwrap();
|
writeln!(output, "LOG: Xous Logging Server starting up...").unwrap();
|
||||||
|
|
||||||
writeln!(
|
|
||||||
output,
|
|
||||||
"LOG: ****************************************************************"
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
writeln!(
|
|
||||||
output,
|
|
||||||
"LOG: *** Welcome to Xous {:40} ***",
|
|
||||||
env!("VERGEN_SHA")
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
writeln!(output, "LOG: *** Built: {:49} ***", env!("VERGEN_BUILD_TIMESTAMP")).unwrap();
|
|
||||||
writeln!(output, "LOG: *** Semver: {:48} ***", env!("VERGEN_SEMVER")).unwrap();
|
|
||||||
writeln!(
|
|
||||||
output,
|
|
||||||
"LOG: ****************************************************************"
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let server_addr = xous::create_server_with_address(b"xous-log-server ").unwrap();
|
let server_addr = xous::create_server_with_address(b"xous-log-server ").unwrap();
|
||||||
writeln!(output, "LOG: Server listening on address {:?}", server_addr).unwrap();
|
writeln!(output, "LOG: Server listening on address {:?}", server_addr).unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,16 +36,8 @@ impl<'a> ShellCmdApi<'a> for Ver {
|
||||||
"dna" => {
|
"dna" => {
|
||||||
write!(ret, "SoC silicon DNA: 0x{:x}", env.llio.soc_dna().unwrap()).unwrap();
|
write!(ret, "SoC silicon DNA: 0x{:x}", env.llio.soc_dna().unwrap()).unwrap();
|
||||||
}
|
}
|
||||||
"shellchat" => {
|
"xous" => {
|
||||||
// note that this only picks up new build info when shellchat is rebuilt
|
write!(ret, "Xous version: {}", env.ticktimer.get_version()).unwrap();
|
||||||
// we don't retrigger a shellchat rebuild every time we rebuild xous because it
|
|
||||||
// would make small builds take much longer. A fix to this would be to create
|
|
||||||
// a "version server" that is tiny, fast to re-link, and rebuilt on every build pass.
|
|
||||||
write!(ret, "Shellchat version info:\n{}\n{}\n{}\n{}",
|
|
||||||
env!("VERGEN_SEMVER"),
|
|
||||||
env!("VERGEN_BRANCH"),
|
|
||||||
env!("VERGEN_SHA_SHORT"),
|
|
||||||
env!("VERGEN_BUILD_TIMESTAMP")).unwrap();
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
write!(ret, "{}", helpstring).unwrap();
|
write!(ret, "{}", helpstring).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ version = "0.1.0"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
log-server = {path = "../log-server"}
|
log-server = {path = "../log-server"}
|
||||||
xous = {path = "../../xous-rs"}
|
xous = {path = "../../xous-rs"}
|
||||||
|
xous-ipc = {path = "../../xous-ipc"}
|
||||||
|
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
|
||||||
num-derive = {version = "0.3.3", default-features = false}
|
num-derive = {version = "0.3.3", default-features = false}
|
||||||
num-traits = {version = "0.2.14", default-features = false}
|
num-traits = {version = "0.2.14", default-features = false}
|
||||||
susres = {path = "../susres"}
|
susres = {path = "../susres"}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,12 @@ pub(crate) enum Opcode {
|
||||||
|
|
||||||
/// force a WDT update
|
/// force a WDT update
|
||||||
PingWdt = 4,
|
PingWdt = 4,
|
||||||
|
|
||||||
|
/// return the version string of Xous. We bury it here because this is a small, lightweight server we can rebuild on every run.
|
||||||
|
GetVersion = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
pub struct VersionString {
|
||||||
|
pub version: xous_ipc::String::<512>,
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +60,16 @@ impl Ticktimer {
|
||||||
)
|
)
|
||||||
.expect("Couldn't send WDT ping");
|
.expect("Couldn't send WDT ping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_version(&self) -> String {
|
||||||
|
let alloc = api::VersionString {
|
||||||
|
version: xous_ipc::String::new(),
|
||||||
|
};
|
||||||
|
let mut buf = xous_ipc::Buffer::into_buf(alloc).expect("couldn't convert version request");
|
||||||
|
buf.lend_mut(self.conn, api::Opcode::GetVersion.to_u32().unwrap()).expect("couldn't get version");
|
||||||
|
let v = buf.to_original::<api::VersionString, _>().expect("couldn't revert buffer");
|
||||||
|
String::from(v.version.as_str().unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
use core::sync::atomic::{AtomicU32, Ordering};
|
use core::sync::atomic::{AtomicU32, Ordering};
|
||||||
static REFCOUNT: AtomicU32 = AtomicU32::new(0);
|
static REFCOUNT: AtomicU32 = AtomicU32::new(0);
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,11 @@ fn xmain() -> ! {
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
info!("my PID is {}", xous::process::id());
|
info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
log::info!("****************************************************************");
|
||||||
|
log::info!("Welcome to Xous {}", version::SEMVER);
|
||||||
|
log::info!("Built at {}", version::TIMESTAMP);
|
||||||
|
log::info!("****************************************************************");
|
||||||
|
|
||||||
let ticktimer_server = xous::create_server_with_address(b"ticktimer-server")
|
let ticktimer_server = xous::create_server_with_address(b"ticktimer-server")
|
||||||
.expect("Couldn't create Ticktimer server");
|
.expect("Couldn't create Ticktimer server");
|
||||||
info!("Server started with SID {:?}", ticktimer_server);
|
info!("Server started with SID {:?}", ticktimer_server);
|
||||||
|
|
@ -498,7 +503,7 @@ fn xmain() -> ! {
|
||||||
//#[cfg(feature = "watchdog")] // for debugging the watchdog
|
//#[cfg(feature = "watchdog")] // for debugging the watchdog
|
||||||
//ticktimer.check_wdt();
|
//ticktimer.check_wdt();
|
||||||
|
|
||||||
let msg = xous::receive_message(ticktimer_server).unwrap();
|
let mut msg = xous::receive_message(ticktimer_server).unwrap();
|
||||||
log::trace!("msg: {:?}", msg);
|
log::trace!("msg: {:?}", msg);
|
||||||
match num_traits::FromPrimitive::from_usize(msg.body.id()) {
|
match num_traits::FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(api::Opcode::ElapsedMs) => {
|
Some(api::Opcode::ElapsedMs) => {
|
||||||
|
|
@ -533,6 +538,10 @@ fn xmain() -> ! {
|
||||||
Some(api::Opcode::PingWdt) => {
|
Some(api::Opcode::PingWdt) => {
|
||||||
ticktimer.reset_wdt();
|
ticktimer.reset_wdt();
|
||||||
}
|
}
|
||||||
|
Some(api::Opcode::GetVersion) => {
|
||||||
|
let mut buf = unsafe{xous_ipc::Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap())};
|
||||||
|
buf.replace(version::get_version()).unwrap();
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
error!("couldn't convert opcode");
|
error!("couldn't convert opcode");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
// Versioning information is kept in a separate file, attached to a small, well-known server in the Xous System
|
|
||||||
// This is a trade-off between rebuild times and flexibility.
|
|
||||||
|
|
||||||
//LOG: ****************************************************************
|
|
||||||
//LOG: *** Welcome to Xous 2a1ab53e6b271feb3ea791cdf3ae822612f59d30 ***
|
|
||||||
//LOG: *** Built: 2022-01-31T05:13:03.355604900+00:00 ***
|
|
||||||
//LOG: *** Semver: v0.9.5-352-g2a1ab53e ***
|
|
||||||
//LOG: ****************************************************************
|
|
||||||
|
|
@ -12,7 +12,4 @@ atty = "0.2.14"
|
||||||
filetime = "0.2.14"
|
filetime = "0.2.14"
|
||||||
rustc_version = "0.4.0"
|
rustc_version = "0.4.0"
|
||||||
zip = "0.5.13"
|
zip = "0.5.13"
|
||||||
|
chrono = "0.4"
|
||||||
[build-dependencies]
|
|
||||||
vergen = "3.2.0"
|
|
||||||
filetime = "0.2.14"
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
use vergen::{ConstantsFlags, generate_cargo_keys};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
// Setup the flags, toggling off the 'SEMVER_FROM_CARGO_PKG' flag
|
|
||||||
let flags = ConstantsFlags::all();
|
|
||||||
|
|
||||||
// Generate the 'cargo:' key output
|
|
||||||
generate_cargo_keys(flags).expect("Unable to generate the cargo keys!");
|
|
||||||
|
|
||||||
// touch the log server to force it to pick up the version
|
|
||||||
let ts = filetime::FileTime::from_system_time(std::time::SystemTime::now());
|
|
||||||
filetime::set_file_mtime("../services/log-server/src/main.rs", ts).unwrap();
|
|
||||||
|
|
||||||
// note that shellchat won't pick up the vesion, but because it's a big crate to rebuild we aren't re-triggering it
|
|
||||||
}
|
|
||||||
|
|
@ -5,6 +5,8 @@ use std::{
|
||||||
path::{Path, PathBuf, MAIN_SEPARATOR},
|
path::{Path, PathBuf, MAIN_SEPARATOR},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
use std::fs::OpenOptions;
|
||||||
|
use chrono::Local;
|
||||||
|
|
||||||
type DynError = Box<dyn std::error::Error>;
|
type DynError = Box<dyn std::error::Error>;
|
||||||
|
|
||||||
|
|
@ -34,6 +36,8 @@ impl std::fmt::Display for BuildError {
|
||||||
impl std::error::Error for BuildError {}
|
impl std::error::Error for BuildError {}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
generate_version(); // really brute force way to try and get a version into the build system.
|
||||||
|
|
||||||
let hw_pkgs = [
|
let hw_pkgs = [
|
||||||
// core OS services
|
// core OS services
|
||||||
"gam",
|
"gam",
|
||||||
|
|
@ -1014,3 +1018,59 @@ fn whycheproof_import() -> Result<(), DynError> {
|
||||||
// fn dist_dir() -> PathBuf {
|
// fn dist_dir() -> PathBuf {
|
||||||
// project_root().join("target/dist")
|
// project_root().join("target/dist")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
fn generate_version() {
|
||||||
|
let output = if cfg!(target_os = "windows") {
|
||||||
|
Command::new("cmd")
|
||||||
|
.args(["/C", "git describe --tags"])
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute process")
|
||||||
|
} else {
|
||||||
|
Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("git describe --tags")
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute process")
|
||||||
|
};
|
||||||
|
let gitver = output.stdout;
|
||||||
|
let semver = String::from_utf8_lossy(&gitver);
|
||||||
|
|
||||||
|
let mut vfile = OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open("services/ticktimer-server/src/version.rs").expect("Can't open our version file for writing");
|
||||||
|
print_header(&mut vfile);
|
||||||
|
let now = Local::now();
|
||||||
|
write!(vfile, "pub const TIMESTAMP: &'static str = \"{}\";\n", now.to_rfc2822()).expect("couldn't add our timestamp");
|
||||||
|
write!(vfile, "pub const SEMVER: &'static str = \"{}\";\n",
|
||||||
|
semver
|
||||||
|
.strip_suffix("\r\n")
|
||||||
|
.or(semver.strip_suffix("\n"))
|
||||||
|
.unwrap_or(&semver)
|
||||||
|
).expect("couldn't add our semver");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_header<U: Write>(out: &mut U) {
|
||||||
|
let s = r####"// Versioning information is kept in a separate file, attached to a small, well-known server in the Xous System
|
||||||
|
// This is a trade-off between rebuild times and flexibility.
|
||||||
|
// This was autogenerated by xtask/build.rs.
|
||||||
|
|
||||||
|
pub(crate) fn get_version() -> crate::api::VersionString {
|
||||||
|
let mut v = crate::api::VersionString {
|
||||||
|
version: xous_ipc::String::new()
|
||||||
|
};
|
||||||
|
// NOTE: the semver is only updated if you can somehow trigger build.rs on xtask to re-run. AFAIK, it basically never re-runs,
|
||||||
|
// because it will only rerun if something *inside xtask* changes (not the rest of the code).
|
||||||
|
// so if you want to pick up the "correct" SEMVER, you have to do a cargo clean.
|
||||||
|
v.version.append(SEMVER).ok();
|
||||||
|
v.version.append("\n").ok();
|
||||||
|
// This timestamp *will* be correct because we are actually forcing it to be rebuilt every build.
|
||||||
|
v.version.append(TIMESTAMP).ok();
|
||||||
|
v.version.append("\n").ok();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
"####;
|
||||||
|
out.write_all(s.as_bytes()).expect("couldn't write our version template header");
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue