Skip to content

Instantly share code, notes, and snippets.

@dragon788
Created December 4, 2024 15:38
Show Gist options
  • Save dragon788/8f65073256ed276e1890b7713190da61 to your computer and use it in GitHub Desktop.
Save dragon788/8f65073256ed276e1890b7713190da61 to your computer and use it in GitHub Desktop.
Xous Precursor Android or Debian bootstrap scripts and process documentation

I figured out a way to get the Precursor import/export working on Android, it wasn't that bad though it is fairly tightly coupled to a "feature flag" in the current ctaphid crate, so I might have to do some discovery work if the crates are upgraded in the future, right now it seems like the crates are all being held back by the highest common version across ALL apps within the workspace (aka repository), because each app isn't defined as a separate workspace which sort of makes sense, otherwise a few things would be able to float higher

also included just to impress/annoy bunnie:

a dump of the multiple step shell scripts that I have shoved into 3 separate default basis password credentials, I was rather amazed when it worked

Need to test using backslashes to split the lines up for easier reading while still enabling "one line" of commands to execute.

Just a slight change to the Cargo.toml and I was able to back up on an Android device under AnotherTerm that has a libusb helper that translates requests from libusb to Android through Java

AnotherTerm (they actually added a fix to the Play store and GitHub versions for Android 13 based on a bug I encountered) https://github.com/green-green-avk/AnotherTerm#anotherterm

I used Debian Bookworm/Bullseye, you can copy and run the version that prompts you interactively or you can select it on the site and copy the URL that has the distro and version you want https://green-green-avk.github.io/AnotherTerm-docs/installing-linux-under-proot.html#main\_content

Run the script from the documentation in a root session (faked via PRoot) and then close and reopen it https://green-green-avk.github.io/AnotherTerm-docs/installing-libusb-for-nonrooted-android.html#main\_content

in the same new root session, you'll need to install rust (I use the rustup bootstrap) and a couple other dependencies (protobuf-compiler libusb-1.0-0-dev libhidapi-dev)

Once rust and python are installed you can generally use the tools from a non-root session I think.

diff --git a/apps/vault/tools/vaultbackup-rs/Cargo.toml b/apps/vault/tools/vaultbackup-rs/Cargo.toml
index 0b1d7860..33ac6a22 100644
--- a/apps/vault/tools/vaultbackup-rs/Cargo.toml
+++ b/apps/vault/tools/vaultbackup-rs/Cargo.toml
@@ -7,10 +7,10 @@ edition = "2021"

 [dependencies]
 argh = "0.1.8"
-ctaphid = "0.1.1"
+ctaphid = { version = "0.1.1", default-features = false, features = ["hidapi-linux-static-libusb"]}
 cbor = {path = "../../libraries/cbor"}
 backup = {path = "../../libraries/backup"}
-hidapi = {version = "1.4.1", default_features = false}
+hidapi = {version = "1.4.1", default-features = false, features = ["linux-static-libusb"]}
 serde_json = "1.0.82"
 serde = {version = "1.0.138", features = ["derive"]}
 hex = "0.4.3"

getting the repo Oneliner because otherwise it doesn't get imported into the secret and typed back out by the Precursor properly.

[[ $(id -u) -eq 0 ]] && echo 'root already no need to sudo' || { set -a; apt(){ sudo \apt "$@"; }; set +a; }; apt install -y git; cd; git clone https://github.com/betrusted-io/xous-core && cd ~/xous-core;

a similar script for doing the full backups which has worked on Android fairly seamlessly Oneliner because otherwise it doesn't get imported into the secret and typed back out by the Precursor properly.

echo 'starting pybootstrap'; xousdir=~/xous-core/; pyback=~/xous-core/tools/; [[ $(id -u) -eq 0 ]] && echo 'root already, no need to sudo' || { set -a; apt(){ sudo \apt "$@"; }; set +a; }; apt install -y python3-pip python3-venv python3-wheel python-is-python3; cd $xousdir; python3 -m venv .venv; . .venv/bin/activate; pip install precursorupdater; cd $pyback; ./backup.py;

Rust import/export tool Oneliner because otherwise it doesn't get imported into the secret and typed back out by the Precursor properly.

echo 'starting rustbootstrap'; [[ $(id -u) -eq 0 ]] && echo 'root already, no need to sudo' || { set -a; apt(){ sudo \apt "$@"; }; set +a; }; rustback=~/xous-core/apps/vault/tools/vaultbackup-rs/; curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh \n\n; . $HOME/.cargo/env; apt install -y libhidapi-hidraw0 libhidapi-libusb0 libhidapi-dev libusb-1.0-0-dev pkg-config protobuf-compiler; cd $rustback; cargo run backup password testrun.json;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment