Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Linux ARM64 executable for "serial". Install script doesn't detect and flag the situation. #189

Open
jimmiedave opened this issue Mar 23, 2025 · 9 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Pull requests are welcome on this issue

Comments

@jimmiedave
Copy link

Trying to install on a Ubuntu VM on Apple Silicon (ARM64):

./install-common.sh: line 20: ./serial-ubuntu-latest/serial: cannot execute binary file: Exec format error

@AllKn
Copy link

AllKn commented Mar 25, 2025

Workaround: Run it via Terminal on MacOS, you'll get the error but you can override it through your settings, privacy, ignoring the security warning. (Click the question mark on your MacOS "refuse to open" dialog for more info). Naturally, make sure that you first install android-platform-tools on Homebrew on your Mac.

@jimmiedave
Copy link
Author

I appreciate the thought, but I didn't have trouble installing on macOS.

Ran into this when trying to do a reinstall via a different platform (Linux on ARM64) as I was trying to solve a problem (which turned out to be issue #151).

So reported b/c there's no serial executable for someone doing a native install on that platform (not a Mac VM), and no alert in the install script that it's not going to work (the install script could know that).

@AllKn
Copy link

AllKn commented Mar 25, 2025

Great, I wasn't able to make it happen at first, my workaround was through a VM but that didn't work as you stated. Just happy I was able to fix it on my own here. Working my way through learning new stuff here...

@cooperq
Copy link
Collaborator

cooperq commented Mar 25, 2025

ah yea it would be worth adding a notification about arm based linux to the install script (a good pull request even!). For now are you able to compile serial by hand and run it that way?

@cooperq cooperq added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Pull requests are welcome on this issue labels Mar 25, 2025
@jimmiedave
Copy link
Author

For now are you able to compile serial by hand and run it that way?

Had a go at this (never compiled any rust before), got an executable out of it, but it won't make the Orbic reboot - stuck there during install.

Not a problem for me as I'd installed with the Mac prior to this.

@jimmiedave
Copy link
Author

Tried again (with a little more info) to build serial for ARM64. I got some kind of executable out of it, but it appears the platform-tools that's getting downloaded is x86. I could be wrong, but that would make sense.

@oopsbagel
Copy link
Contributor

oopsbagel commented Mar 28, 2025

I played around with this yesterday and was able to build a functional ARM64 binary for Linux on my x86_64 machine and an arm64 machine with these changes:

diff --git a/.cargo/config.toml b/.cargo/config.toml
index 318eb3d..559d0d0 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -2,6 +2,10 @@
 linker = "arm-linux-gnueabihf-gcc"
 rustflags = ["-C", "target-feature=+crt-static"]
 
+[target.aarch64-unknown-linux-gnu]
+linker = "aarch64-unknown-linux-gnu-gcc"
+rustflags = ["-C", "target-feature=+crt-static"]
+
 # optimizations to reduce the binary size
 [profile.release]
 strip = true

create rayhunter/serial/shell.nix with:

with import <nixpkgs>
{
  crossSystem = {
    config = "aarch64-unknown-linux-gnu";
  };
};
  mkShell {
    buildInputs = [
      glibc.static
      stdenv
      gcc
    ];
    inputsFrom = [glibc cargo];
  }
rayhunter/serial % nix-shell
rayhunter/serial $ cargo build --release --target aarch64-unknown-linux-gnu
[snip]
    Finished `release` profile ...

rayhunter/serial $ file ../target/aarch64-unknown-linux-gnu/release/serial
../target/aarch64-unknown-linux-gnu/release/serial: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=fe8ff210d5be764a36204ad09208b484a93f123f, for GNU/Linux 3.10.0, with debug_info, not stripped

I confirmed that the serial binary works to put the device into debug mode and reboots it with --root on an M1 running Asahi Fedora Remix.

I was also able to just run cargo build on a checkout on the M1 itself just by running the following after adding the target to rayhunter/.cargo/config.toml (above):

rayhunter/serial % rustup target add aarch64-unknown-linux-gnu
rayhunter/serial % cargo build --release --target aarch64-unknown-linux-gnu

I learned nix for this, someone more familiar with nix could probably help make this more robust. I also have used it to build armv7l-unknown-linux-gnueabihf targets. I haven't been able to get it working with --pure for aarch64 though, so I must be missing something. (I played around with flakes too but didn't get anywhere helpful.)

Note, this will install gcc from source, but only the first time.

@oopsbagel
Copy link
Contributor

You'll need rustup installed on your system, that's not handled in nix ^ -- and ofc you'll need nix.

@oopsbagel
Copy link
Contributor

Honestly though we may be able to sidestep needing gcc for the serial binary now that libusb is gone. I'll poke around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Pull requests are welcome on this issue
Projects
None yet
Development

No branches or pull requests

4 participants