From 97609109918614c2adbac5779514eada551bfca9 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 01:23:48 +0800 Subject: [PATCH 1/7] do not renumber explicitly numbered enums In general, if an enum has been explicitly numbered, it means that there are crates that depend on the actual number assigned, and changing them will break other crates. This is done to allow for cross-compatibility reasons, for example, going to a C FFI or to the standard library, where we can't simply refer to a Rust crate to import the symbolic enums and have the compiler figure out a consistent numbering method. Thus even though it's a bit "ugly", please assign only unused numbers to new enums, and when old enums are retired, do not re-use the number. --- services/keyboard/src/api.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/keyboard/src/api.rs b/services/keyboard/src/api.rs index 37fa41a4e..087f3e058 100644 --- a/services/keyboard/src/api.rs +++ b/services/keyboard/src/api.rs @@ -61,28 +61,28 @@ pub(crate) enum Opcode { RegisterRawListener = 3, /// request for updates for *when* keyboard is pressed - RegisterKeyObserver = 4, + RegisterKeyObserver = 12, /// set repeat delay, rate; both in ms - SetRepeat = 5, //(u32, u32), + SetRepeat = 4, //(u32, u32), /// set chording interval (how long to wait for all keydowns to happen before interpreting as a chord), in ms (for braille keyboards) - SetChordInterval = 6, //(u32), + SetChordInterval = 5, //(u32), /// used by host mode emulation and debug UART to inject keys - InjectKey = 7, //(char), + InjectKey = 6, //(char), /// used by the interrupt handler to transfer results to the main loop - HandlerTrigger = 8, + HandlerTrigger = 7, /// used to turn keyboard vibrate on and off - Vibe = 9, + Vibe = 8, /// a blocking key listener - blocks until a key is hit - BlockingKeyListener = 10, + BlockingKeyListener = 9, /// Suspend/resume callback - SuspendResume = 11, + SuspendResume = 10, } // this structure is used to register a keyboard listener. Currently, we only accept From 6a583a5f0ca093c8d1b64cc4c81481b66f36da0b Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 01:25:41 +0800 Subject: [PATCH 2/7] the system as writ does not actually allocate an extra connection Adjust the connection number back to 4. There isn't a connection made for a keyboard backlight server anymore. This is necessary for root key initialization to proceed. --- services/keyboard/src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 6178a2b92..c3f3f5aad 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -739,10 +739,9 @@ fn main() -> ! { // - graphics (if building for hosted mode) // - oqc (for factory test) // - status sub system (for setting the layout) - // - keyboard-backlight (to start backlight when a key is pressed) // - USB (for getting layout) #[cfg(any(target_os = "none", target_os = "xous"))] - let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(6)).expect("can't register server"); + let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(4)).expect("can't register server"); #[cfg(not(any(target_os = "none", target_os = "xous")))] let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(5)).expect("can't register server"); log::trace!("registered with NS -- {:?}", kbd_sid); From ed530888c15beefd8f0b6aed08fcfa0cb24f2d29 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 01:38:05 +0800 Subject: [PATCH 3/7] add check to buildpush script --- buildpush.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buildpush.ps1 b/buildpush.ps1 index cb542d67a..968ea57e6 100644 --- a/buildpush.ps1 +++ b/buildpush.ps1 @@ -3,7 +3,7 @@ # set RUSTFLAGS=--remap-path-prefix=F:\largework\rust-win\code\xous-core\=build # $env:RUSTFLAGS="--remap-path-prefix=$(Get-Location)=build" -cargo xtask app-image vault ball +cargo xtask app-image vault # cargo xtask ffi-test # cargo xtask minimal precursors/soc.svd @@ -23,3 +23,9 @@ scp -i c:/users/bunnie/.ssh/id_pi target/riscv32imac-unknown-xous-elf/release/xo # scp -i c:/users/bunnie/.ssh/id_pi target/riscv32imac-unknown-none-elf/release/xous.img target/riscv32imac-unknown-none-elf/release/loader.bin precursors/soc_csr.bin precursors/bbram-test1.nky pi@10.0.245.90:code/precursors/ # wishbone-tool --load-name target/riscv32imac-unknown-none-elf/release/xous.img --load-address 0x980000 --load-flash + +$file = Get-Item target/riscv32imac-unknown-xous-elf/release/xous.img +$SizeinBytes = $file.Length +if($SizeinBytes -gt 6815743) { + "Warning: xous.img exceeds the 24-bit limit of JTAG. Upload using USB instead!" +} \ No newline at end of file From 0e1fdd528bfce85c5da72832252599810c1d14ca Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 01:59:26 +0800 Subject: [PATCH 4/7] add bloat analyzer script to local builds --- analyze-bloat.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 analyze-bloat.sh diff --git a/analyze-bloat.sh b/analyze-bloat.sh new file mode 100755 index 000000000..f98dca856 --- /dev/null +++ b/analyze-bloat.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +declare -a Crates=( + "kernel" + "loader" + "gam" + "status" + "shellchat" + "ime-frontend" + "ime-plugin-shell" + "graphics-server" + "ticktimer-server" + "log-server" + "com" + "xous-names" + "keyboard" + "trng" + "llio" + "susres" + "codec" + "sha2" + "engine-25519" + "spinor" + "root-keys" + "jtag" + "net" + "dns" + "pddb" + "modals" + "usb-device-xous" + "vault" + "ball" + "repl" +) + +if [ -e "$HOME/.cargo/env" ]; then + . "$HOME/.cargo/env" +fi +RISCV_TOOLS=/opt/riscv64-unknown-elf +export PATH=$RISCV_TOOLS/bin:$PATH + +env | sort > env.txt + +#cargo clean +mkdir -p reports +mkdir -p reports/old +# move just the files, not the directory +find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; + +echo "===== TURNING OF STRIP =====" +sed -i 's/strip = true/strip = false/g' Cargo.toml + +echo "===== STARTING BUILD at $(date) =====" +cargo xtask app-image ball repl vault + +echo "===== ANALYZING at $(date) =====" +for val in ${Crates[@]}; do + # dump the header summary + riscv64-unknown-elf-objdump -h target/riscv32imac-unknown-xous-elf/release/$val > reports/$val.txt + # dump the sorted list of objects + riscv64-unknown-elf-nm -r --size-sort --print-size target/riscv32imac-unknown-xous-elf/release/$val | rustfilt >> reports/$val.txt + # dump the disassembly + riscv64-unknown-elf-objdump -S -d target/riscv32imac-unknown-xous-elf/release/$val | rustfilt > reports/$val.list +done + + +echo "===== REVERTING STRIP =====" +git checkout Cargo.toml From a92cf4e9c08c3016b99697bfb2db98af11a74693 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:00:05 +0800 Subject: [PATCH 5/7] ignore bloat analyzer reports --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index dc5a7b4b3..b807ee298 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ emulation/linux-server-rootfs.jffs2 # don't commit local modifications to the Renode filesystem template emulation/linux-server-rootfs.jffs2 + +# bloat analyzer reports +reports/ \ No newline at end of file From 28f54229c7827ee3dd6623f89b097f3b335b7d5c Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:03:06 +0800 Subject: [PATCH 6/7] fix typo --- analyze-bloat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze-bloat.sh b/analyze-bloat.sh index f98dca856..f7adbd7e4 100755 --- a/analyze-bloat.sh +++ b/analyze-bloat.sh @@ -47,7 +47,7 @@ mkdir -p reports/old # move just the files, not the directory find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; -echo "===== TURNING OF STRIP =====" +echo "===== TURNING OFF STRIP =====" sed -i 's/strip = true/strip = false/g' Cargo.toml echo "===== STARTING BUILD at $(date) =====" From 0abca4229845a4137d0d7e06ef289b5ca64f6302 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:05:31 +0800 Subject: [PATCH 7/7] fix argument to backup copy --- analyze-bloat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze-bloat.sh b/analyze-bloat.sh index f7adbd7e4..2aba5a7ed 100755 --- a/analyze-bloat.sh +++ b/analyze-bloat.sh @@ -45,7 +45,7 @@ env | sort > env.txt mkdir -p reports mkdir -p reports/old # move just the files, not the directory -find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; +find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv {} reports/old/ \; echo "===== TURNING OFF STRIP =====" sed -i 's/strip = true/strip = false/g' Cargo.toml