Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
[target.aarch64-apple-darwin]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

[target.aarch64-unknown-linux-musl]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

# apt install build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
[target.armv7-unknown-linux-gnueabihf]
Copy link
Collaborator Author

@oopsbagel oopsbagel Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included to not break anyone's existing setups, but no longer used by github actions, make.sh, or tools/devenv.

linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-C", "target-feature=+crt-static"]

[target.armv7-unknown-linux-musleabihf]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-apple-darwin]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-unknown-linux-musl]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

# optimizations to reduce the binary size
[profile.release]
strip = true
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,13 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: armv7-unknown-linux-gnueabihf
- name: Install cross-compilation dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
version: 1.0
targets: armv7-unknown-linux-musleabihf
- name: Build rootshell (arm32)
run: cargo build --bin rootshell --target armv7-unknown-linux-gnueabihf --release
run: cargo build --bin rootshell --target armv7-unknown-linux-musleabihf --release
- uses: actions/upload-artifact@v4
with:
name: rootshell
path: target/armv7-unknown-linux-gnueabihf/release/rootshell
path: target/armv7-unknown-linux-musleabihf/release/rootshell
if-no-files-found: error
build_rayhunter:
strategy:
Expand All @@ -81,18 +76,13 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: armv7-unknown-linux-gnueabihf
- name: Install cross-compilation dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
version: 1.0
targets: armv7-unknown-linux-musleabihf
- name: Build rayhunter-daemon (arm32)
run: cargo build --bin rayhunter-daemon --target armv7-unknown-linux-gnueabihf --release --no-default-features --features ${{ matrix.device.name }}
run: cargo build --bin rayhunter-daemon --target armv7-unknown-linux-musleabihf --release --no-default-features --features ${{ matrix.device.name }}
- uses: actions/upload-artifact@v4
with:
name: rayhunter-daemon-${{ matrix.device.name }}
path: target/armv7-unknown-linux-gnueabihf/release/rayhunter-daemon
path: target/armv7-unknown-linux-musleabihf/release/rayhunter-daemon
if-no-files-found: error
build_release_zip:
needs:
Expand Down
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,27 @@ Follow these instructions if you need to build Rayhunter from source rather than
* [linux](https://askubuntu.com/questions/652936/adding-android-sdk-platform-tools-to-path-downloaded-from-umake)
* [macOS](https://www.repeato.app/setting-up-adb-on-macos-a-step-by-step-guide/)
* [Windows](https://medium.com/@yadav-ajay/a-step-by-step-guide-to-setting-up-adb-path-on-windows-0b833faebf18)
* Install `curl` on your computer to run the install scripts. It is not needed to build binaries.

### If you're on x86 linux
### Install Rust targets

Install Rust the usual way and then install cross compiling dependences:
[Install Rust the usual way](https://www.rust-lang.org/tools/install). Then,

```bash
sudo apt install curl build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
rustup target add x86_64-unknown-linux-gnu
rustup target add armv7-unknown-linux-gnueabihf
- install the cross-compilation target for the device rayhunter will run on:
```sh
rustup target add armv7-unknown-linux-musleabihf
```

- install the statically compiled target for your host machine to build the binary installer [`serial`](./serial).
```sh
# check which toolchain you have installed by default with
rustup show
# now install the correct variant for your host platform, one of:
rustup target add x86_64-unknown-linux-musl
rustup target add aarch64-unknown-linux-musl
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
rustup target add x86_64-pc-windows-gnu
```

Now you can root your device and install Rayhunter by running `./tools/install-dev.sh`
Expand Down
16 changes: 10 additions & 6 deletions lib/src/diag_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,22 @@ pub const LOG_CODES_FOR_RAW_PACKET_LOGGING: [u32; 11] = [
const BUFFER_LEN: usize = 1024 * 1024 * 10;
const MEMORY_DEVICE_MODE: u32 = 2;

#[cfg(target_arch = "arm")]
#[cfg(target_env = "musl")]
const DIAG_IOCTL_REMOTE_DEV: i32 = 32;
#[cfg(all(not(target_env = "musl"), target_arch = "arm"))]
const DIAG_IOCTL_REMOTE_DEV: u32 = 32;
#[cfg(target_arch = "x86_64")]
#[cfg(all(not(target_env = "musl"), target_arch = "x86_64"))]
const DIAG_IOCTL_REMOTE_DEV: u64 = 32;
#[cfg(target_arch = "aarch64")]
#[cfg(all(not(target_env = "musl"), target_arch = "aarch64"))]
const DIAG_IOCTL_REMOTE_DEV: u64 = 32;

#[cfg(target_arch = "arm")]
#[cfg(target_env = "musl")]
const DIAG_IOCTL_SWITCH_LOGGING: i32 = 7;
#[cfg(all(not(target_env = "musl"), target_arch = "arm"))]
const DIAG_IOCTL_SWITCH_LOGGING: u32 = 7;
#[cfg(target_arch = "x86_64")]
#[cfg(all(not(target_env = "musl"), target_arch = "x86_64"))]
const DIAG_IOCTL_SWITCH_LOGGING: u64 = 7;
#[cfg(target_arch = "aarch64")]
#[cfg(all(not(target_env = "musl"), target_arch = "aarch64"))]
const DIAG_IOCTL_SWITCH_LOGGING: u64 = 7;

pub struct DiagDevice {
Expand Down
4 changes: 2 additions & 2 deletions make.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
cargo build --release --target="armv7-unknown-linux-gnueabihf" #--features debug
cargo build --release --target="armv7-unknown-linux-musleabihf" #--features debug
adb shell '/bin/rootshell -c "/etc/init.d/rayhunter_daemon stop"'
adb push target/armv7-unknown-linux-gnueabihf/release/rayhunter-daemon /data/rayhunter/rayhunter-daemon
adb push target/armv7-unknown-linux-musleabihf/release/rayhunter-daemon /data/rayhunter/rayhunter-daemon
echo "rebooting the device..."
adb shell '/bin/rootshell -c "reboot"'
4 changes: 1 addition & 3 deletions tools/devenv.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FROM rust:1.86-bullseye

RUN apt-get update
RUN apt-get install -y build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
RUN rustup target add armv7-unknown-linux-gnueabihf
RUN rustup target add armv7-unknown-linux-musleabihf
4 changes: 2 additions & 2 deletions tools/run-docker-devenv
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# ./tools/run-docker-devenv
#
# Inside the shell:
# cargo build --bin rayhunter-daemon --target armv7-unknown-linux-gnueabihf --release
# cargo build --bin rayhunter-daemon --target armv7-unknown-linux-musleabihf --release
#
# Your output binary is in ./target/armv7-unknown-linux-gnueabihf/release/rayhunter-daemon
# Your output binary is in ./target/armv7-unknown-linux-musleabihf/release/rayhunter-daemon

docker build -t rayhunter-devenv -f tools/devenv.dockerfile .
exec docker run --user $UID:$GID -v ./:/workdir -w /workdir -it rayhunter-devenv "$@"