mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
hello world exercise
This commit is contained in:
parent
ea3b032fbe
commit
526d8353fd
6 changed files with 118 additions and 14 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
|
@ -1308,26 +1308,25 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curve25519-dalek"
|
name = "curve25519-dalek"
|
||||||
version = "4.1.2"
|
version = "4.1.2"
|
||||||
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#bef542a781348054c32a9beaf6bd1195814cace2"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cpufeatures",
|
"cpufeatures",
|
||||||
"curve25519-dalek-derive",
|
"curve25519-dalek-derive",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"engine25519-as",
|
|
||||||
"fiat-crypto 0.2.7",
|
"fiat-crypto 0.2.7",
|
||||||
"log",
|
"platforms",
|
||||||
"rustc_version 0.4.0",
|
"rustc_version 0.4.0",
|
||||||
"subtle",
|
"subtle",
|
||||||
"utralib 0.1.25",
|
|
||||||
"xous 0.9.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curve25519-dalek-derive"
|
name = "curve25519-dalek-derive"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#bef542a781348054c32a9beaf6bd1195814cace2"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -4075,6 +4074,12 @@ version = "0.3.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
|
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "platforms"
|
||||||
|
version = "3.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d43467300237085a4f9e864b937cf0bc012cef7740be12be1a48b10d2c8a3701"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "plotters"
|
name = "plotters"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,8 @@ use usb::*;
|
||||||
mod pddb;
|
mod pddb;
|
||||||
#[cfg(feature = "with-pddb")]
|
#[cfg(feature = "with-pddb")]
|
||||||
use pddb::*;
|
use pddb::*;
|
||||||
|
mod cute;
|
||||||
|
use cute::*;
|
||||||
|
|
||||||
pub struct CmdEnv {
|
pub struct CmdEnv {
|
||||||
common_env: CommonEnv,
|
common_env: CommonEnv,
|
||||||
|
|
@ -138,11 +140,14 @@ impl CmdEnv {
|
||||||
let mut echo_cmd = Echo {}; // this command has no persistent storage, so we can "create" it every time we call dispatch (but it's a zero-cost absraction so this doesn't actually create any instructions)
|
let mut echo_cmd = Echo {}; // this command has no persistent storage, so we can "create" it every time we call dispatch (but it's a zero-cost absraction so this doesn't actually create any instructions)
|
||||||
let mut ver_cmd = Ver {};
|
let mut ver_cmd = Ver {};
|
||||||
let mut console_cmd = Test {};
|
let mut console_cmd = Test {};
|
||||||
|
let mut cute_cmd = Cute{};
|
||||||
|
|
||||||
let commands: &mut [&mut dyn ShellCmdApi] = &mut [
|
let commands: &mut [&mut dyn ShellCmdApi] = &mut [
|
||||||
///// 4. add your command to this array, so that it can be looked up and dispatched
|
///// 4. add your command to this array, so that it can be looked up and dispatched
|
||||||
&mut echo_cmd,
|
&mut echo_cmd,
|
||||||
&mut ver_cmd,
|
&mut ver_cmd,
|
||||||
&mut self.trng_cmd,
|
&mut self.trng_cmd,
|
||||||
|
&mut cute_cmd,
|
||||||
&mut console_cmd,
|
&mut console_cmd,
|
||||||
#[cfg(feature = "usb")]
|
#[cfg(feature = "usb")]
|
||||||
&mut self.usb,
|
&mut self.usb,
|
||||||
|
|
|
||||||
92
services/bao-console/src/cmds/cute.rs
Normal file
92
services/bao-console/src/cmds/cute.rs
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
use String;
|
||||||
|
|
||||||
|
use crate::{CommonEnv, ShellCmdApi};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cute {}
|
||||||
|
|
||||||
|
impl<'a> ShellCmdApi<'a> for Cute {
|
||||||
|
cmd_api!(cute);
|
||||||
|
|
||||||
|
fn process(&mut self, args: String, _env: &mut CommonEnv) -> Result<Option<String>, xous::Error> {
|
||||||
|
use core::fmt::Write;
|
||||||
|
let mut ret = String::new();
|
||||||
|
let helpstring = "Usage:
|
||||||
|
cute cat - prints cat ascii art
|
||||||
|
cute bread - prints bread ascii art
|
||||||
|
cute breadcat - prints breadcat ascii art";
|
||||||
|
|
||||||
|
let mut tokens = args.split_whitespace();
|
||||||
|
|
||||||
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
|
match sub_cmd {
|
||||||
|
"cat" => {
|
||||||
|
let cat_art = r#"
|
||||||
|
⠀⠀⠀⠀⢀⠠⠤⠀⢀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠐⠀⠐⠀⠀⢀⣾⣿⡇⠀⠀⠀⠀⠀⢀⣼⡇⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⠀⠀⠀⠀⣴⣿⣿⠇⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣇⠀⠀⢀⣾⣿⣿⣿⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠐⠀⡀
|
||||||
|
⠀⠀⠀⠀⢰⡿⠉⠀⡜⣿⣿⣿⡿⠿⢿⣿⣿⡃⠀⠀⠂⠄⠀
|
||||||
|
⠀⠀⠒⠒⠸⣿⣄⡘⣃⣿⣿⡟⢰⠃⠀⢹⣿⡇⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠚⠉⠀⠊⠻⣿⣿⣿⣿⣿⣮⣤⣤⣿⡟⠁⠘⠠⠁⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠠⠀⠀⠈⠙⠛⠛⠛⠛⠛⠁⠀⠒⠤⠀⠀⠀⠀
|
||||||
|
⠨⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠀⠀⠀⠀⠀⠀
|
||||||
|
⠁⠃⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
"#;
|
||||||
|
write!(ret, "{}", cat_art).unwrap();
|
||||||
|
}
|
||||||
|
"bread" => {
|
||||||
|
let bread_art = r#"
|
||||||
|
⠀⠀⠀⠀⣀⣠⣤⣤⣤⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⣴⣿⣿⠿⠛⣉⣁⣠⣤⣤⣤⣬⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⢸⣿⣿⣿⣿⣿⣿⡿⠛⣉⣁⣠⣤⣤⣤⣬⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⢸⣿⣿⣿⣿⣿⣵⣾⣿⡿⠟⠛⠉⣉⣉⣉⣉⠉⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⢸⣿⣿⣿⣿⣿⣿⡟⢁⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⢸⣿⣿⣿⣿⣿⣿⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⢿⣿⣿⣿⣿⣿⣿⡄⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠈⠻⣿⣿⣿⣿⣿⣷⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠈⠻⣿⣿⣿⣿⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠙⢿⣿⠇⢰⣿⣿⣿⣿⡿⠛⢉⣩⣉⡉⠛⠻⠇⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠙⠀⠸⠿⠿⠟⢉⣠⣾⣿⣿⣿⣿⣷⣶⣦⣤⣄⣀⣀⡀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣉⣉⠉⠛⠛⠻⠿⣿⣿⣿⣿⣿⣿⣿⠿⠋⣀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠛⠛⠛⠻⠶⣶⣤⣈⣉⣉⣉⣁⣤⣴⠾⠛⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠉⠉⠉⠀⠀⠀⠀
|
||||||
|
"#;
|
||||||
|
write!(ret, "{}", bread_art).unwrap();
|
||||||
|
}
|
||||||
|
"breadcat" => {
|
||||||
|
let breadcat_art = r#"
|
||||||
|
⠀⠀⠀⠰⣦⣤⣤⣀⠀⠀⡀⠀⠀⠀⠀⣀⣀⠀⠠⢤⣶⣶⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⢿⣿⢋⣵⣾⣿⣿⡿⣥⣮⢻⣿⣿⣿⣿⣶⣌⢿⣿⢰⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠘⢡⣿⣿⣿⣿⣿⣷⡹⠟⣵⣿⣿⣿⣿⣿⣿⣦⢃⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⢺⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢨⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⣿⡟⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠙⣿⣷⣬⣿⣿⣿⣿⣿⣿⣿⡼⣿⣿⡟⣱⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⣿⣧⣠⣿⣿⣿⣿⣿⣿⣿⣀⣾⣿⡇⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣅⣽⣿⣿⣿⣿⣿⣿⡇⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠛⠙⠋⠋⠋⠋⠋⠋⠋⠋⠛⠙⠙⠁⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⢿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⣴⣶⣉⢿⣿⣿⣿⡟⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣆⡻⣿⣷⠜⣿⣏⣾⣿⣿⡿⠁⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣇⣿⣿⣽⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
"#;
|
||||||
|
write!(ret, "{}", breadcat_art).unwrap();
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
write!(ret, "{}\n", helpstring).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write!(ret, "{}\n", helpstring).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Some(ret))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -15,6 +15,7 @@ pub struct PddbCmd {
|
||||||
}
|
}
|
||||||
impl PddbCmd {
|
impl PddbCmd {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
log::info!("here");
|
||||||
let pddb = pddb::Pddb::new();
|
let pddb = pddb::Pddb::new();
|
||||||
log::info!("PDDB mount result: {:?}", pddb.try_mount());
|
log::info!("PDDB mount result: {:?}", pddb.try_mount());
|
||||||
PddbCmd { pddb }
|
PddbCmd { pddb }
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,13 @@ fn main() {
|
||||||
let mut buf = [0u8, 0u8];
|
let mut buf = [0u8, 0u8];
|
||||||
loop {
|
loop {
|
||||||
tt.sleep_ms(2_000).ok();
|
tt.sleep_ms(2_000).ok();
|
||||||
for (name, offset) in measurements {
|
// for (name, offset) in measurements {
|
||||||
i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap();
|
// i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap();
|
||||||
let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32;
|
// let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32;
|
||||||
log::info!("{}: {:0.3}V", name, v as f32 / 1000.0);
|
// log::info!("{}: {:0.3}V", name, v as f32 / 1000.0);
|
||||||
i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap();
|
// i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap();
|
||||||
log::info!("SOC: {}%", buf[0]);
|
// log::info!("SOC: {}%", buf[0]);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(any(feature = "hosted-baosec", not(feature = "battery-readout")))]
|
#[cfg(any(feature = "hosted-baosec", not(feature = "battery-readout")))]
|
||||||
|
|
|
||||||
|
|
@ -612,13 +612,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// - [planned] vault application
|
// - [planned] vault application
|
||||||
let bao_rram_pkgs =
|
let bao_rram_pkgs =
|
||||||
["xous-ticktimer", "xous-log", "xous-names", "keystore" /* "usb-cramium" */].to_vec(); /* "usb-cramium" */
|
["xous-ticktimer", "xous-log", "xous-names", "keystore" /* "usb-cramium" */].to_vec(); /* "usb-cramium" */
|
||||||
let bao_swap_pkgs = ["cram-hal-service", "bao-console", "modals", "pddb", "bao-video"].to_vec(); /* "bao-video" */
|
let bao_swap_pkgs = ["cram-hal-service", "bao-console", /*"modals", "pddb", "bao-video"*/].to_vec(); /* "bao-video" */
|
||||||
if !builder.is_swap_set() {
|
if !builder.is_swap_set() {
|
||||||
builder.set_swap(0, 8 * 1024 * 1024);
|
builder.set_swap(0, 8 * 1024 * 1024);
|
||||||
}
|
}
|
||||||
builder.add_loader_feature("swap");
|
builder.add_loader_feature("swap");
|
||||||
builder.add_kernel_feature("swap");
|
builder.add_kernel_feature("swap");
|
||||||
builder.add_feature("swap");
|
builder.add_feature("swap");
|
||||||
|
// builder.add_feature("autotest");
|
||||||
|
|
||||||
builder.add_loader_feature("debug-print");
|
builder.add_loader_feature("debug-print");
|
||||||
// the following feature needs to be uncommented if we also enable
|
// the following feature needs to be uncommented if we also enable
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue