From cbd412a461ca840267984bdf3302c82a6c5f06c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Fri, 18 Mar 2022 15:51:58 +0100 Subject: [PATCH 01/17] compile for hosted and real hardware on main push --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ xtask/src/main.rs | 12 ++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..89319318b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +on: + push: + branches: + - main + +name: Build xous-core + +jobs: + build: + name: Setup Rust + runs-on: ubuntu-latest + strategy: + matrix: + task: ["hosted-ci", "renode-image"] + steps: + - name: Install Ubuntu dependencies + run: | + sudo apt update + sudo apt install -y libxkbcommon-dev + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: "1.59.0" + default: true + + - name: Checkout sources + uses: actions/checkout@v2 + + - uses: Swatinem/rust-cache@v1 + + - name: Install RISC-V toolkit + run: cargo xtask install-toolkit + + - name: Build hosted-ci + run: cargo xtask ${{ matrix.task }} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 3f619dac2..631716074 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -165,6 +165,9 @@ fn main() -> Result<(), Box> { let lkey = args.nth(3); let kkey = args.nth(4); match task.as_deref() { + Some("install-toolkit") => { + ensure_compiler(&Some(PROGRAM_TARGET), true)? + } Some("renode-image") => { let mut args = env::args(); args.nth(1); @@ -602,6 +605,7 @@ Various debug configurations: pddb-ci PDDB config for CI testing (eg: TRNG->deterministic for reproducible errors) ffi-test builds an image for testing C-FFI bindings and integration tts builds an image with text to speech support via externally linked C executable + install-toolkit installs Xous toolkit with no prompt, useful in CI " ) } @@ -1015,7 +1019,7 @@ static DONE_COMPILER_CHECK: std::sync::atomic::AtomicBool = /// Ensure we have a compatible compiler toolchain. We use a new Target, /// and we want to give the user a friendly way of installing the latest /// Rust toolchain. -fn ensure_compiler(target: &Option<&str>) -> Result<(), String> { +fn ensure_compiler(target: &Option<&str>, force_install: bool) -> Result<(), String> { use std::process::Stdio; if DONE_COMPILER_CHECK.load(std::sync::atomic::Ordering::SeqCst) { return Ok(()); @@ -1108,6 +1112,10 @@ fn ensure_compiler(target: &Option<&str>) -> Result<(), String> { target ); loop { + if force_install { + break; + } + print!("Would you like this program to attempt to download and install it? [Y/n] "); stdout.flush().unwrap(); buffer.clear(); @@ -1251,7 +1259,7 @@ fn build( extra_args: Option<&[&str]>, features: Option<&[&str]>, ) -> Result { - ensure_compiler(&target)?; + ensure_compiler(&target, false)?; let stream = if debug { "debug" } else { "release" }; let mut args = vec!["build"]; print!("Building"); From 65d2ec64db76d156f4c1cdad15cc621e99a3fc2b Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 18 Mar 2022 23:35:42 +0800 Subject: [PATCH 02/17] xtask: add --force parameter to `install-toolkit` This parameter will remove the existing toolchain and target directories, forcing a reinstall. Signed-off-by: Sean Cross --- xtask/src/main.rs | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 631716074..9196c5b3e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -166,7 +166,12 @@ fn main() -> Result<(), Box> { let kkey = args.nth(4); match task.as_deref() { Some("install-toolkit") => { - ensure_compiler(&Some(PROGRAM_TARGET), true)? + let arg = env::args().nth(2); + ensure_compiler( + &Some(PROGRAM_TARGET), + true, + arg.map(|x| x == "--force").unwrap_or(false), + )? } Some("renode-image") => { let mut args = env::args(); @@ -605,7 +610,7 @@ Various debug configurations: pddb-ci PDDB config for CI testing (eg: TRNG->deterministic for reproducible errors) ffi-test builds an image for testing C-FFI bindings and integration tts builds an image with text to speech support via externally linked C executable - install-toolkit installs Xous toolkit with no prompt, useful in CI + install-toolkit installs Xous toolkit with no prompt, useful in CI. Specify `--force` to remove existing toolchains " ) } @@ -1019,7 +1024,11 @@ static DONE_COMPILER_CHECK: std::sync::atomic::AtomicBool = /// Ensure we have a compatible compiler toolchain. We use a new Target, /// and we want to give the user a friendly way of installing the latest /// Rust toolchain. -fn ensure_compiler(target: &Option<&str>, force_install: bool) -> Result<(), String> { +fn ensure_compiler( + target: &Option<&str>, + force_install: bool, + remove_existing: bool, +) -> Result<(), String> { use std::process::Stdio; if DONE_COMPILER_CHECK.load(std::sync::atomic::Ordering::SeqCst) { return Ok(()); @@ -1083,9 +1092,31 @@ fn ensure_compiler(target: &Option<&str>, force_install: bool) -> Result<(), Str // If the sysroot exists, then we're good. let target = target.unwrap_or(PROGRAM_TARGET); - if get_sysroot(Some(target))?.is_some() { - DONE_COMPILER_CHECK.store(true, std::sync::atomic::Ordering::SeqCst); - return Ok(()); + if let Some(path) = get_sysroot(Some(target))? { + let mut version_path = PathBuf::from(&path); + version_path.push("lib"); + version_path.push("rustlib"); + version_path.push(PROGRAM_TARGET); + if remove_existing { + println!("Target path exists, removing it"); + std::fs::remove_dir_all(version_path) + .or_else(|e| Err(format!("unable to remove existing toolchain: {}", e)))?; + println!("Also removing target directories for existing toolchain"); + let mut target_main = project_root(); + target_main.push("target"); + target_main.push(PROGRAM_TARGET); + std::fs::remove_dir_all(target_main).ok(); + + let mut target_loader = project_root(); + target_loader.push("loader"); + target_loader.push("target"); + target_loader.push(PROGRAM_TARGET); + std::fs::remove_dir_all(target_loader).ok(); + + } else { + DONE_COMPILER_CHECK.store(true, std::sync::atomic::Ordering::SeqCst); + return Ok(()); + } } // Since no sysroot exists, we must download a new one. @@ -1259,7 +1290,7 @@ fn build( extra_args: Option<&[&str]>, features: Option<&[&str]>, ) -> Result { - ensure_compiler(&target, false)?; + ensure_compiler(&target, false, false)?; let stream = if debug { "debug" } else { "release" }; let mut args = vec!["build"]; print!("Building"); From d9f5fd0c6afba3c899da6323842fc86e0e641d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Fri, 18 Mar 2022 16:47:12 +0100 Subject: [PATCH 03/17] use force on install toolkit --- .github/workflows/build.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89319318b..3874ec2d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,9 @@ +#on: +# push: +# branches: +# - main on: push: - branches: - - main name: Build xous-core @@ -11,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - task: ["hosted-ci", "renode-image"] + task: ["hosted-ci"] #, "renode-image"] steps: - name: Install Ubuntu dependencies run: | @@ -31,7 +33,7 @@ jobs: - uses: Swatinem/rust-cache@v1 - name: Install RISC-V toolkit - run: cargo xtask install-toolkit - + run: cargo xtask install-toolkit --force + - name: Build hosted-ci run: cargo xtask ${{ matrix.task }} From ccafeb21a3cca34953662d939804a0c7728a2cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Fri, 18 Mar 2022 17:05:51 +0100 Subject: [PATCH 04/17] if not tty but force install is true, keep going --- xtask/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9196c5b3e..df200fec6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1123,7 +1123,7 @@ fn ensure_compiler( let toolchain_path = get_sysroot(None)?.ok_or_else(|| "default toolchain not installed".to_owned())?; // If the terminal is a tty, offer to download the latest toolchain. - if !atty::is(atty::Stream::Stdin) { + if !atty::is(atty::Stream::Stdin) && !force_install { return Err(format!("Toolchain for {} not found", target)); } From ae2762e7f563c6fefe52be16e3db59d8cb9bfdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Fri, 18 Mar 2022 17:17:34 +0100 Subject: [PATCH 05/17] fix: on non-TTY terminals if forced, proceed with toolchain download and install This is a corner case in Github CI. --- .github/workflows/build.yml | 8 +++----- xtask/src/main.rs | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3874ec2d8..b94b35111 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,7 @@ -#on: -# push: -# branches: -# - main on: push: + branches: + - main name: Build xous-core @@ -13,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - task: ["hosted-ci"] #, "renode-image"] + task: ["hosted-ci", "renode-image"] steps: - name: Install Ubuntu dependencies run: | diff --git a/xtask/src/main.rs b/xtask/src/main.rs index df200fec6..9eee9a152 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1122,7 +1122,8 @@ fn ensure_compiler( // Since no sysroot exists, we must download a new one. let toolchain_path = get_sysroot(None)?.ok_or_else(|| "default toolchain not installed".to_owned())?; - // If the terminal is a tty, offer to download the latest toolchain. + // If the terminal is a tty, or if toolchain installation is forced, + // download the latest toolchain. if !atty::is(atty::Stream::Stdin) && !force_install { return Err(format!("Toolchain for {} not found", target)); } From 3fb30dc619b82a227f266de52b92940d2e6a5b59 Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Fri, 18 Mar 2022 10:57:06 -0500 Subject: [PATCH 06/17] Add a basic 'hello world' app example --- Cargo.lock | 15 +++++ Cargo.toml | 2 + apps/hello/Cargo.toml | 15 +++++ apps/hello/src/main.rs | 146 +++++++++++++++++++++++++++++++++++++++++ apps/manifest.json | 13 +++- 5 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 apps/hello/Cargo.toml create mode 100644 apps/hello/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 7de4171de..b97c1aec5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1029,6 +1029,21 @@ dependencies = [ "xous-names", ] +[[package]] +name = "hello" +version = "0.1.0" +dependencies = [ + "gam", + "graphics-server", + "log", + "log-server", + "num-derive", + "num-traits", + "xous", + "xous-ipc 0.9.7", + "xous-names", +] + [[package]] name = "hermit-abi" version = "0.1.18" diff --git a/Cargo.toml b/Cargo.toml index a0dd4452a..f81365e61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ default-members = [ "services/dns", "services/modals", "apps/ball", + "apps/hello", "apps/repl", ] members = [ @@ -88,6 +89,7 @@ members = [ "services/dns", "services/modals", "apps/ball", + "apps/hello", "apps/repl", "services/libstd-test", "services/ffi-test", diff --git a/apps/hello/Cargo.toml b/apps/hello/Cargo.toml new file mode 100644 index 000000000..2e25ee12f --- /dev/null +++ b/apps/hello/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "hello" +version = "0.1.0" +edition = "2021" + +[dependencies] +log = "0.4.14" +num-derive = {version = "0.3.3", default-features = false} +num-traits = {version = "0.2.14", default-features = false} +xous = { path = "../../xous-rs" } +xous-ipc = { path = "../../xous-ipc" } +log-server = { path = "../../services/log-server" } +xous-names = { path = "../../services/xous-names" } +gam = {path = "../../services/gam" } +graphics-server = {path = "../../services/graphics-server" } diff --git a/apps/hello/src/main.rs b/apps/hello/src/main.rs new file mode 100644 index 000000000..d126d1054 --- /dev/null +++ b/apps/hello/src/main.rs @@ -0,0 +1,146 @@ +#![cfg_attr(target_os = "none", no_std)] +#![cfg_attr(target_os = "none", no_main)] + +use core::fmt::Write; +use graphics_server::api::GlyphStyle; +use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView}; +use num_traits::*; + +/// Basic 'Hello World!' application that draws a simple +/// TextView to the screen. + +pub(crate) const SERVER_NAME_HELLO: &str = "_Hello World_"; + +/// Top level application events. +#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] +pub(crate) enum HelloOp { + /// Redraw the screen + Redraw = 0, + + /// Quit the application + Quit, +} + +struct Hello { + content: Gid, + gam: gam::Gam, + _gam_token: [u32; 4], + screensize: Point, +} + +impl Hello { + fn new(xns: &xous_names::XousNames, sid: xous::SID) -> Self { + let gam = gam::Gam::new(&xns).expect("Can't connect to GAM"); + let gam_token = gam + .register_ux(gam::UxRegistration { + app_name: xous_ipc::String::<128>::from_str(gam::APP_NAME_HELLO), + ux_type: gam::UxType::Chat, + predictor: None, + listener: sid.to_array(), + redraw_id: HelloOp::Redraw.to_u32().unwrap(), + gotinput_id: None, + audioframe_id: None, + rawkeys_id: None, + focuschange_id: None, + }) + .expect("Could not register GAM UX") + .unwrap(); + + let content = gam + .request_content_canvas(gam_token) + .expect("Could not get content canvas"); + let screensize = gam + .get_canvas_bounds(content) + .expect("Could not get canvas dimensions"); + Self { + gam, + _gam_token: gam_token, + content, + screensize, + } + } + + /// Clear the entire screen. + fn clear_area(&self) { + self.gam + .draw_rectangle( + self.content, + Rectangle::new_with_style( + Point::new(0, 0), + self.screensize, + DrawStyle { + fill_color: Some(PixelColor::Light), + stroke_color: None, + stroke_width: 0, + }, + ), + ) + .expect("can't clear content area"); + } + + /// Redraw the text view onto the screen. + fn redraw(&mut self) { + self.clear_area(); + + let mut text_view = TextView::new( + self.content, + TextBounds::GrowableFromBr( + Point::new( + self.screensize.x - (self.screensize.x / 2), + self.screensize.y - (self.screensize.y / 2), + ), + (self.screensize.x / 5 * 4) as u16, + ), + ); + + text_view.border_width = 1; + text_view.draw_border = true; + text_view.clear_area = true; + text_view.rounded_border = Some(3); + text_view.style = GlyphStyle::Regular; + write!(text_view.text, "{}", "Hello world!").expect("Could not write to text view"); + + self.gam + .post_textview(&mut text_view) + .expect("Could not render text view"); + self.gam.redraw().expect("Could not redraw screen"); + } +} + +#[xous::xous_main] +fn xmain() -> ! { + log_server::init_wait().unwrap(); + log::set_max_level(log::LevelFilter::Info); + log::info!("Hello world PID is {}", xous::process::id()); + + let xns = xous_names::XousNames::new().unwrap(); + + // Register the server with xous + let sid = xns + .register_name(SERVER_NAME_HELLO, None) + .expect("can't register server"); + + let mut hello = Hello::new(&xns, sid); + + loop { + let msg = xous::receive_message(sid).unwrap(); + log::debug!("Got message: {:?}", msg); + + match FromPrimitive::from_usize(msg.body.id()) { + Some(HelloOp::Redraw) => { + log::debug!("Got redraw"); + hello.redraw(); + } + Some(HelloOp::Quit) => { + log::info!("Quitting application"); + break; + } + _ => { + log::error!("Got unknown message"); + } + } + } + + log::info!("Quitting"); + xous::terminate_process(0) +} diff --git a/apps/manifest.json b/apps/manifest.json index 5f22a440c..e5d22cc3b 100644 --- a/apps/manifest.json +++ b/apps/manifest.json @@ -10,6 +10,17 @@ } } }, + "hello": { + "context_name": "Hello World", + "menu_name": { + "appmenu.hello": { + "en": "Hello World!", + "ja": "", + "zh": "", + "en-tts": "Hello World!" + } + } + }, "repl": { "context_name": "repl demo app", "menu_name": { @@ -21,4 +32,4 @@ } } } -} \ No newline at end of file +} From eae61df7863caaab9f1d6c48c98bc9c0e06ff338 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 08:58:41 +0800 Subject: [PATCH 07/17] Update factory_reset.sh move soc update to the top to avoid wdt resets --- tools/factory_reset.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/factory_reset.sh b/tools/factory_reset.sh index a93b7fa7e..83b37410b 100755 --- a/tools/factory_reset.sh +++ b/tools/factory_reset.sh @@ -29,6 +29,13 @@ else LOCALE="" fi +wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin +./usb_update.py --soc /tmp/soc_csr.bin --force +rm /tmp/soc_csr.bin + +echo "waiting for device to reboot" +sleep 5 + wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin ./usb_update.py -l /tmp/loader.bin rm /tmp/loader.bin @@ -43,13 +50,6 @@ rm /tmp/xous.img echo "waiting for device to reboot" sleep 5 -wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin -./usb_update.py --soc /tmp/soc_csr.bin --force -rm /tmp/soc_csr.bin - -echo "waiting for device to reboot" -sleep 5 - wget https://ci.betrusted.io/$REVISION/ec_fw.bin -O /tmp/ec_fw.bin ./usb_update.py -e /tmp/ec_fw.bin rm /tmp/ec_fw.bin From d9f4f6d041a0d3785c7c769fc6051f80d0e16006 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 09:00:58 +0800 Subject: [PATCH 08/17] Update factory_reset.ps1 move soc update to top so we don't get resets from latest xous --- tools/factory_reset.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/factory_reset.ps1 b/tools/factory_reset.ps1 index 1e14ef449..1660c195a 100644 --- a/tools/factory_reset.ps1 +++ b/tools/factory_reset.ps1 @@ -13,12 +13,19 @@ if ($decision -eq 0) { Exit } +Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin +python usb_update.py --soc soc_csr.bin --force +Remove-Item soc_csr.bin + +Write-Output "waiting for device to reboot" +Start-Sleep 5 + Invoke-WebRequest https://ci.betrusted.io/releases/latest/loader.bin -OutFile loader.bin python usb_update.py -l loader.bin Remove-Item loader.bin Write-Output "waiting for device to reboot" -Start-Sleep 5 +Start-Sleep 4 Invoke-WebRequest https://ci.betrusted.io/releases/latest/xous-$LOCALE.img -OutFile xous.img python usb_update.py -k xous.img @@ -27,13 +34,6 @@ Remove-Item xous.img Write-Output "waiting for device to reboot" Start-Sleep 5 -Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin -python usb_update.py --soc soc_csr.bin --force -Remove-Item soc_csr.bin - -Write-Output "waiting for device to reboot" -Start-Sleep 5 - Invoke-WebRequest https://ci.betrusted.io/releases/latest/ec_fw.bin -OutFile ec_fw.bin python usb_update.py -e ec_fw.bin Remove-Item ec_fw.bin From 2aa72fae18e2b1204458c8236fe560ee903aaf4b Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 09:01:40 +0800 Subject: [PATCH 09/17] Update factory_reset.sh --- tools/factory_reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/factory_reset.sh b/tools/factory_reset.sh index 83b37410b..5be719139 100755 --- a/tools/factory_reset.sh +++ b/tools/factory_reset.sh @@ -41,7 +41,7 @@ wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin rm /tmp/loader.bin echo "waiting for device to reboot" -sleep 5 +sleep 4 wget https://ci.betrusted.io/$REVISION/xous$LOCALE.img -O /tmp/xous.img ./usb_update.py -k /tmp/xous.img From 1856a83e3e5b6d6b64740419b1b4a26966c835d2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 16:22:09 +0800 Subject: [PATCH 10/17] fix ordering of updates to prevent mid-update resets --- tools/factory_reset.ps1 | 21 ++++++++++----------- tools/factory_reset.sh | 22 +++++++++++----------- tools/usb_update.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/tools/factory_reset.ps1 b/tools/factory_reset.ps1 index 1660c195a..31c4245f5 100644 --- a/tools/factory_reset.ps1 +++ b/tools/factory_reset.ps1 @@ -13,20 +13,10 @@ if ($decision -eq 0) { Exit } -Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin -python usb_update.py --soc soc_csr.bin --force -Remove-Item soc_csr.bin - +python usb_update.py --disable-boot Write-Output "waiting for device to reboot" Start-Sleep 5 -Invoke-WebRequest https://ci.betrusted.io/releases/latest/loader.bin -OutFile loader.bin -python usb_update.py -l loader.bin -Remove-Item loader.bin - -Write-Output "waiting for device to reboot" -Start-Sleep 4 - Invoke-WebRequest https://ci.betrusted.io/releases/latest/xous-$LOCALE.img -OutFile xous.img python usb_update.py -k xous.img Remove-Item xous.img @@ -45,4 +35,13 @@ Invoke-WebRequest https://ci.betrusted.io/releases/latest/wf200_fw.bin -OutFile python usb_update.py -w wf200_fw.bin Remove-Item wf200_fw.bin +Write-Output "waiting for device to reboot" +Start-Sleep 5 + +Invoke-WebRequest https://ci.betrusted.io/releases/latest/soc_csr.bin -OutFile soc_csr.bin +Invoke-WebRequest https://ci.betrusted.io/releases/latest/loader.bin -OutFile loader.bin +python usb_update.py --enable-boot --soc soc_csr.bin -l loader.bin +Remove-Item soc_csr.bin +Remove-Item loader.bin + Write-Output "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects." diff --git a/tools/factory_reset.sh b/tools/factory_reset.sh index 5be719139..9aefdc446 100755 --- a/tools/factory_reset.sh +++ b/tools/factory_reset.sh @@ -29,20 +29,10 @@ else LOCALE="" fi -wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin -./usb_update.py --soc /tmp/soc_csr.bin --force -rm /tmp/soc_csr.bin - +./usb_update.py --disable-boot echo "waiting for device to reboot" sleep 5 -wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin -./usb_update.py -l /tmp/loader.bin -rm /tmp/loader.bin - -echo "waiting for device to reboot" -sleep 4 - wget https://ci.betrusted.io/$REVISION/xous$LOCALE.img -O /tmp/xous.img ./usb_update.py -k /tmp/xous.img rm /tmp/xous.img @@ -60,5 +50,15 @@ wget https://ci.betrusted.io/$REVISION/wf200_fw.bin -O /tmp/wf200_fw.bin ./usb_update.py -w /tmp/wf200_fw.bin rm /tmp/wf200_fw.bin +echo "waiting for device to reboot" +sleep 5 + +# this should sequence last because it overwrites all of the CSR values on the currently loaded SoC +wget https://ci.betrusted.io/$REVISION/soc_csr.bin -O /tmp/soc_csr.bin +wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin +./usb_update.py --enable-boot --soc /tmp/soc_csr.bin -l /tmp/loader.bin +rm /tmp/loader.bin +rm /tmp/soc_csr.bin + echo " " echo "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects." diff --git a/tools/usb_update.py b/tools/usb_update.py index 29fce7610..1ce109493 100755 --- a/tools/usb_update.py +++ b/tools/usb_update.py @@ -404,6 +404,12 @@ def main(): parser.add_argument( "-l", "--loader", required=False, help="Loader", type=str, nargs='?', metavar=('loader file'), const='../target/riscv32imac-unknown-xous-elf/release/loader.bin' ) + parser.add_argument( + "--disable-boot", required=False, action='store_true', help="Disable system boot (for use in multi-stage updates)" + ) + parser.add_argument( + "--enable-boot", required=False, action='store_true', help="Re-enable system boot. Requires both a loader and a soc spec." + ) parser.add_argument( "-k", "--kernel", required=False, help="Kernel", type=str, nargs='?', metavar=('kernel file'), const='../target/riscv32imac-unknown-xous-elf/release/xous.img' ) @@ -539,6 +545,34 @@ def main(): print("Erasing PDDB region") pc_usb.erase_region(locs['LOC_PDDB'][0], locs['LOC_EC'][0] - locs['LOC_PDDB'][0]) + if args.disable_boot: + print("Disabling boot") + pc_usb.erase_region(locs['LOC_LOADER'][0], 1024 * 256) + + if args.enable_boot: + if args.loader == None: + print("Must provide both a loader and soc image") + if args.soc == None: + print("Must provide both a soc and loader image") + print("Enabling boot with {} and {}".format(args.loader, args.soc)) + print("Programming loader image {}".format(args.loader)) + with open(args.loader, "rb") as f: + image = f.read() + pc_usb.flash_program(locs['LOC_LOADER'][0], image, verify=verify) + print("Programming SoC gateware".format(args.soc)) + with open(args.soc, "rb") as f: + image = f.read() + pc_usb.flash_program(locs['LOC_SOC'][0], image, verify=verify) + print("Resuming CPU.") + pc_usb.poke(vexdbg_addr, 0x02000000) + + print("Resetting SOC...") + try: + pc_usb.poke(pc_usb.register('reboot_soc_reset'), 0xac, display=False) + except usb.core.USBError: + pass # we expect an error because we reset the SOC and that includes the USB core + exit(0) + if args.image: image_file, addr_str = args.image addr = int(addr_str, 0) From b06d7c4bb747a7d31188a79a7e1b82116c56a627 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 16:31:37 +0800 Subject: [PATCH 11/17] add a note about the hard reset --- tools/factory_reset.ps1 | 2 ++ tools/factory_reset.sh | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/factory_reset.ps1 b/tools/factory_reset.ps1 index 31c4245f5..34db9dd58 100644 --- a/tools/factory_reset.ps1 +++ b/tools/factory_reset.ps1 @@ -44,4 +44,6 @@ python usb_update.py --enable-boot --soc soc_csr.bin -l loader.bin Remove-Item soc_csr.bin Remove-Item loader.bin +Write-Output "Please insert a paperclip in the hard reset hole in the lower right hand corner to ensure the new FPGA gateware is loaded." +Write-Output "After inserting the paperclip you will need to apply power via USB to boot." Write-Output "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects." diff --git a/tools/factory_reset.sh b/tools/factory_reset.sh index 9aefdc446..8fc13ec07 100755 --- a/tools/factory_reset.sh +++ b/tools/factory_reset.sh @@ -60,5 +60,6 @@ wget https://ci.betrusted.io/$REVISION/loader.bin -O /tmp/loader.bin rm /tmp/loader.bin rm /tmp/soc_csr.bin -echo " " +echo "Please insert a paperclip in the hard reset hole in the lower right hand corner to ensure the new FPGA gateware is loaded." +echo "After inserting the paperclip you will need to apply power via USB to boot." echo "IMPORTANT: you must run 'ecup auto' to update the EC with the staged firmware objects." From b52b73ddfa22e62b8c7d756617fe0bbd0705b149 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 19 Mar 2022 16:56:03 +0800 Subject: [PATCH 12/17] add functionality to override the CSR data in case it is corrupted --- tools/csr_data_0.9.5.bin | Bin 0 -> 32768 bytes tools/csr_data_0.9.6.bin | Bin 0 -> 32768 bytes tools/csr_data_0.9.7.bin | Bin 0 -> 32768 bytes tools/usb_update.py | 15 ++++++++++++--- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 tools/csr_data_0.9.5.bin create mode 100644 tools/csr_data_0.9.6.bin create mode 100644 tools/csr_data_0.9.7.bin diff --git a/tools/csr_data_0.9.5.bin b/tools/csr_data_0.9.5.bin new file mode 100644 index 0000000000000000000000000000000000000000..58f40c876f748183a2b9c86ae4846d1a0d6c4598 GIT binary patch literal 32768 zcmeHOJFo0W5ncq*)n*$Zk|S1vT`~7E_Poy7fLB7oBPGJ}*gfZZ&x}3To;l|T35ke} zh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$+bQ%GFW!|003W5OGi9qE zxk5Etm697biN%w@^)6N4<&NqWm3pZU z#a*p)0;&%mfQ}}Vh4vJMi{5l9mK`&|sP+wOB& zDs3mc^?;WIMrQ&e(7)gXzT4qX4#7O(CHQ6gaj@2Jcu8P%BIxbuAMug^7ct%IeCHAj zx98jprjX7p1fZPR25Mg_0LxjdusJ^bY0Lo?SoTs>eoByZSRLFuDp3t9i;i9$SioM? zs}Be}%7hDg^=<*!i+Xh?>?l+(=v}L<0rsNajlm*>M)e+=`(%%=En0m}+fh7>!u`c_ zH)l_0isZq%3HXGs{UsAQb?pm|F(*>a-%X@yEg+yF}toPu)I0#krT$!j!Z9Buz8mZSNby}^vgvJA?-_c`sj!o4&lfHYLi1SZWQ_xC7g`xfEjsW zV$iPzLUt?k9R+>b#13m$B<9UVEWdIZG6XkD^k<*L($kl4T zvs?Q|aeY4yHR`jyzSS9m+_rb0j9NWJj%y@FT|)F~B8N%&(M{h-1I453s>UNId~J!< zp!=eg?wIK}Td!7&^{l8oluorIS084H-Hvv#cuc=q&*V&ydm{R^J62ViBI!4a)|<^H zhJ~y|_Zl2{y6&alEMBZo85~#x5A9Ihpp6!-C-j>|i)9=^`7N(o<_GX}DyH9zQ>(wD zC6HXG7*H4RohI2idXDCscxWX)UTS z_$2%S1A&3SKwuy+5Euvy1O@^Ffq}q4U?4CM7zhjm1_A?tfxtjuATSUZ2n+-U0t118 zz(8OiFc26B3)*t^BfBn^4e>lAQ@N<9r z?dKovKl;jlKlsTH|MRLY8{^{Ev{SQEB Bw3Pq= literal 0 HcmV?d00001 diff --git a/tools/csr_data_0.9.6.bin b/tools/csr_data_0.9.6.bin new file mode 100644 index 0000000000000000000000000000000000000000..841e75ecd55cd6f453c76382a88ef5d96329eff7 GIT binary patch literal 32768 zcmeHOJ*?zN5k3(REYS&x_(><7?qK#b_WZqfB7lpz3y2T|#$)%q=X*2uV0&iX1{V;M z5Ro8(h>!>&g@~Ml2q7IA5~PR#2?@SxcelISWzPf`_Gn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(ob4oqV4LNGZR#q8nP1?xK-ed{}FbXgS*oFYG3AUmdQmT0|8)mOix zx<#cP_Cs-38l8aZ!v~CbME~3u z!|b;ET$W1P32(jkC4teIzzFmYeu3|H_>)60FMbJr-F_Ub^^;!`7@Y`ud-^xOB)~;X z_n6WDubiUYoIQJW-<%|u0+l-TB%Yo>a6zn~ zham>$8^1jM=-cxcq|Y2#*K$y)7qPSDVnD(?*qbJ>y9w$ zlAE>4yi4yrzO=3Gu6FuHtk~AL%{##!u(8|e`Dov?a+~D$vsUxMZdS8VFN_J%>R5hy zV>Q}s^e(b*TH8&yGL)ZuTJ4e3ZTB#ym&V*~^{Uo2tJxW?dRJgII{~1Y^(U*g4UyA} z{3h0Fez05nH*|eJ4mIj4zrNKOg50)uUzl1wM2>4DMqNVmY9fb8`HfEBNCU+i?W)F` zDSVuX)u8(Tmae4fH(Re(i}kFiJd{qgBv;>YiQSHNv3PsGTF>N6kb5HfaXeO4nj+~p zi`JXXCWeKqME7_cc)IST-z;9NP#GLp0}t&`-Jp#Ytta%GMT=z|LHRweTjmGwbSkFb zj8m&WyCslZs2ETe@SP^vIeL!fn|Np?zIO*qvP2!mYfQdUq51@4cAkIm@WJ}^;`QTt zA)q6A^}p~73x&PDif8PH6zd!%g$6x*R z*Z=ypzx?p9|NPy<&wtSV_k-`g{j)#*_LJXy<)h0lpZ@m!U;JzK*(cxlF#6~3p1=Hm DGC`Cr literal 0 HcmV?d00001 diff --git a/tools/csr_data_0.9.7.bin b/tools/csr_data_0.9.7.bin new file mode 100644 index 0000000000000000000000000000000000000000..0687dd649dd64bb4db6bfbfd81a57a7e82214396 GIT binary patch literal 32768 zcmeHOy^rij5eE@~o&OvFB^|0>lvz!NrKg^4LAQzMZiL+cUc>A%uiP zN<=`6kjNo{zkqv{Y-zP*W-@5S+ZtL3ZD-oC7+l^U$uUcZS<^EVys%hahozhx&w(^>?s%)ygP=Xt;H9Z~^OZd)fF3O$m zGWD98Iz1%fS$Dhjnh)Zz&vMmk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2!N!x$D3RsuSxV*GX&QI z!35~Mri>UVHD3Y^yu8Sr+PpLbnbpayCvt>?S`b~9x z!pqsDO!2nLsOE=KR>v9rWm@r>D%H?2q2-va7x4%N7Yz610pGas5Nuj|lb?#_Vaxk~ zaF@CxjJo7ztupV@dyg+|tGlb6z7Z?7HE#1xum^1Hc6vVAH?7nh6Rr&9C!bb(KyU z@kYC<@n#AiXJR$zK7gewY5L99tJPvXD=H7AQ!UBWcU)q(qg^cC-me(Aei)Axm8M7f z&7$>Yvx#AyoHuf>gYMxt@O0HnzgfIkp(;4A1m4-9vO$|HT1)6Rix$f`g7RBlx6BRT z=|oJw8K+i%a!Vk&NHL%;*gH+KbMzd|H}TL)eCrOFWQaP9*O+*vLiPE@>^y&S_h$2Y z{`x*$<@3Ak-K+nFUtl0G5Euvy1O@^Ffq}q4U?4CM7zhjm1_A?tfxtjuATSUZ2n+-U z0t118z(8OiFc26B3$NFW&#zmwxlNpMUu~|N3_P(XxL358wFJcR&8; JU;g_0{{yTkmIeR- literal 0 HcmV?d00001 diff --git a/tools/usb_update.py b/tools/usb_update.py index 1ce109493..d3af734c7 100755 --- a/tools/usb_update.py +++ b/tools/usb_update.py @@ -197,10 +197,16 @@ class PrecursorUsb: self.spinor_command_value(exec=1, lock_reads=1, cmd_code=self.PP4B, has_arg=1, data_words=(data_bytes//2)) ) - def load_csrs(self): + def load_csrs(self, fname=None): LOC_CSRCSV = 0x20277000 # this address shouldn't change because it's how we figure out our version number + # CSR extraction: + # dd if=soc_csr.bin of=csr_data_0.9.6.bin skip=2524 count=32 bs=1024 + if fname == None: + csr_data = self.burst_read(LOC_CSRCSV, 0x8000) + else: + with open(fname, "rb") as f: + csr_data = f.read(0x8000) - csr_data = self.burst_read(LOC_CSRCSV, 0x8000) hasher = hashlib.sha512() hasher.update(csr_data[:0x7FC0]) digest = hasher.digest() @@ -452,6 +458,9 @@ def main(): parser.add_argument( "--factory-new", help="reset the entire image to mimic exactly what comes out of the factory, including temp files for testing. Warning: this will take a long time.", action="store_true" ) + parser.add_argument( + "--override-csr", required=False, help="CSR file to use instead of CSR values stored with the image. Used to recover in case of partial update of soc_csr.bin", type=str, + ) args = parser.parse_args() if not len(sys.argv) > 1: @@ -494,7 +503,7 @@ def main(): # print("match") exit(0) - pc_usb.load_csrs() # prime the CSR values + pc_usb.load_csrs(args.override_csr) # prime the CSR values if "v0.8" in pc_usb.gitrev: locs = { "LOC_SOC" : [0x0000_0000, "soc_csr.bin"], From e96a7df267f57f0c78c4571b5961d6ced7519ebe Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 20 Mar 2022 10:37:17 +0800 Subject: [PATCH 13/17] xtask: remove `renode-bypass` for `renode-image` The `renode-bypass` flag is used for development in order to speed up certain features. This creates invalid keys and skips many checks, which causes problems in the main image. Remove this flag in order to fix the Renode image. Signed-off-by: Sean Cross --- xtask/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9eee9a152..3e683b9a8 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -193,7 +193,7 @@ fn main() -> Result<(), Box> { &hw_pkgs, &[], None, - Some(&["--features", "renode-bypass"]), + None, )? } Some("renode-test") => { From 526a7374b011edc03dd0e487c3a9e1b8af1f90c2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 20 Mar 2022 15:25:14 +0800 Subject: [PATCH 14/17] re-introduce PDDB structure nuking on SoC reset --- tools/usb_update.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/usb_update.py b/tools/usb_update.py index d3af734c7..0bcf8490c 100755 --- a/tools/usb_update.py +++ b/tools/usb_update.py @@ -572,6 +572,10 @@ def main(): with open(args.soc, "rb") as f: image = f.read() pc_usb.flash_program(locs['LOC_SOC'][0], image, verify=verify) + + print("Erasing PDDB root structures") + pc_usb.erase_region(locs['LOC_PDDB'][0], 1024 * 1024) + print("Resuming CPU.") pc_usb.poke(vexdbg_addr, 0x02000000) From 731b847560baf6d4864ce8c8773eb80c8fd89fa6 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 21 Mar 2022 00:07:07 +0800 Subject: [PATCH 15/17] add translations I think "hello world" might actually be the phrase used by the Japanese in their intro texts so leaving that as English. --- apps/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/manifest.json b/apps/manifest.json index e5d22cc3b..09cfa877c 100644 --- a/apps/manifest.json +++ b/apps/manifest.json @@ -15,8 +15,8 @@ "menu_name": { "appmenu.hello": { "en": "Hello World!", - "ja": "", - "zh": "", + "ja": "Hello World!", + "zh": "大家好!", "en-tts": "Hello World!" } } From b4d20a643c5cf9939251d273249efbcdfc71f069 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 21 Mar 2022 00:22:54 +0800 Subject: [PATCH 16/17] add tts locale to hello example --- Cargo.lock | 2 ++ apps/hello/Cargo.toml | 6 ++++++ apps/hello/locales/i18n.json | 8 ++++++++ apps/hello/src/main.rs | 11 ++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 apps/hello/locales/i18n.json diff --git a/Cargo.lock b/Cargo.lock index b97c1aec5..dafecc03d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,10 +1035,12 @@ version = "0.1.0" dependencies = [ "gam", "graphics-server", + "locales", "log", "log-server", "num-derive", "num-traits", + "tts-frontend", "xous", "xous-ipc 0.9.7", "xous-names", diff --git a/apps/hello/Cargo.toml b/apps/hello/Cargo.toml index 2e25ee12f..961a133ea 100644 --- a/apps/hello/Cargo.toml +++ b/apps/hello/Cargo.toml @@ -13,3 +13,9 @@ log-server = { path = "../../services/log-server" } xous-names = { path = "../../services/xous-names" } gam = {path = "../../services/gam" } graphics-server = {path = "../../services/graphics-server" } +locales = {path = "../../locales"} +tts-frontend = {path="../../services/tts"} + +[features] +tts = [] +default = [] diff --git a/apps/hello/locales/i18n.json b/apps/hello/locales/i18n.json new file mode 100644 index 000000000..19f8bf49e --- /dev/null +++ b/apps/hello/locales/i18n.json @@ -0,0 +1,8 @@ +{ + "helloworld.hello": { + "en": "Hello World!", + "ja": "Hello World!", + "zh": "大家好!", + "en-tts": "Hello World!" + } +} \ No newline at end of file diff --git a/apps/hello/src/main.rs b/apps/hello/src/main.rs index d126d1054..20d9efa82 100644 --- a/apps/hello/src/main.rs +++ b/apps/hello/src/main.rs @@ -5,6 +5,9 @@ use core::fmt::Write; use graphics_server::api::GlyphStyle; use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView}; use num_traits::*; +use locales::t; +#[cfg(feature = "tts")] +use tts_frontend::*; /// Basic 'Hello World!' application that draws a simple /// TextView to the screen. @@ -26,6 +29,8 @@ struct Hello { gam: gam::Gam, _gam_token: [u32; 4], screensize: Point, + #[cfg(feature = "tts")] + tts: TtsFrontend, } impl Hello { @@ -57,6 +62,8 @@ impl Hello { _gam_token: gam_token, content, screensize, + #[cfg(feature = "tts")] + tts: TtsFrontend::new(xns).unwrap(), } } @@ -98,7 +105,9 @@ impl Hello { text_view.clear_area = true; text_view.rounded_border = Some(3); text_view.style = GlyphStyle::Regular; - write!(text_view.text, "{}", "Hello world!").expect("Could not write to text view"); + write!(text_view.text, "{}", t!("helloworld.hello", xous::LANG)).expect("Could not write to text view"); + #[cfg(feature="tts")] + self.tts.tts_simple(t!("helloworld.hello", xous::LANG)).unwrap(); self.gam .post_textview(&mut text_view) From 77b5e7a2bba64d7024d71c976c11a3e7ac645a24 Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Sun, 20 Mar 2022 15:20:02 -0500 Subject: [PATCH 17/17] During sleep, clear the rest of the screen, to avoid any secrets being persistently visible on the display. --- .../graphics-server/src/backend/betrusted.rs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/services/graphics-server/src/backend/betrusted.rs b/services/graphics-server/src/backend/betrusted.rs index ebe09ed69..09c44f9a1 100644 --- a/services/graphics-server/src/backend/betrusted.rs +++ b/services/graphics-server/src/backend/betrusted.rs @@ -1,8 +1,8 @@ use crate::api::Point; +use crate::api::{LINES, WIDTH}; use susres::{ManagedMem, RegManager, RegOrField, SuspendResume}; use utralib::generated::*; use xous::MemoryRange; -use crate::api::{LINES, WIDTH}; pub const FB_WIDTH_WORDS: usize = 11; pub const FB_WIDTH_PIXELS: usize = WIDTH; @@ -10,7 +10,6 @@ pub const FB_LINES: usize = LINES; pub const FB_SIZE: usize = FB_WIDTH_WORDS * FB_LINES; // 44 bytes by 536 lines const CONFIG_CLOCK_FREQUENCY: u32 = 100_000_000; - pub struct XousDisplay { fb: MemoryRange, hwfb: MemoryRange, @@ -91,19 +90,36 @@ impl XousDisplay { if draw_note { let note = crate::sleep_note::LOGO_MAP; let note_lines = note.len() / FB_WIDTH_WORDS; - let start_line = (FB_LINES - note_lines) / 2; + let note_start_line = (FB_LINES - note_lines) / 2; + let note_end_line = note_start_line + note_lines; let hwfb: *mut [u32; FB_SIZE] = self.hwfb.as_mut_ptr() as *mut [u32; FB_SIZE]; - for words in 0..note.len() { - unsafe { - (*hwfb)[words + start_line * FB_WIDTH_WORDS] = note[words]; + + for lines in 0..FB_LINES { + for words in 0..FB_WIDTH_WORDS { + if lines >= note_start_line && lines < note_end_line { + // We're on a line that has the 'Sleeping...' note. + // Draw it into the frame buffer. + let note_index = ((lines - note_start_line) * FB_WIDTH_WORDS) + words; + unsafe { + (*hwfb)[words + lines * FB_WIDTH_WORDS] = note[note_index]; + } + } else { + // We're not on a line that has the note. Clear the pixels, + // since we don't want any secrets to linger in the framebuffer + // and stay visible on the persistent display while the device is + // sleeping. + unsafe { + (*hwfb)[words + lines * FB_WIDTH_WORDS] = 0xFFFF_FFFF; + } + } } - } - for lines in start_line..start_line + note_lines { + // set the dirty bits unsafe { (*hwfb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000; } } + self.update_dirty(); while self.busy() { // busy wait, blocking suspend until this has happened