trezord-go icon indicating copy to clipboard operation
trezord-go copied to clipboard

`error when initializing LibUSB` aarch64-linux (arm64, asahi linux, nixos)

Open mitchmindtree opened this issue 9 months ago • 3 comments

Hi folks, running trezord-go on an asahi linux based nixos build and noticed the following error:

$ trezord-go -v
2025/02/24 00:27:59 trezord v2.0.33 (rev 2680d5e) is starting
[0.000037 : 00:27:59] [trezord.go 78 main.initUsb] Initing libusb
[0.000047 : 00:27:59] [usb/libusb.go 63 usb.InitLibUSB] init
2025/02/24 00:27:59 libusb: error when initializing LibUSB.
If you run trezord in an environment without USB (for example, docker or travis), use '-u=false'. For example, './trezord-go -e 21324 -u=false'.

Original error: LIBUSB_ERROR_OTHER

Originally noticed when the nixos trezord service activation script failed after nixos-rebuild switch-ing a new configuration with the daemon for the first time on this machine.

Some system info:

$ nix run nixpkgs#nix-info -- -m
 - system: `"aarch64-linux"`
 - host os: `Linux 6.12.12-asahi, NixOS, 25.05 (Warbler), 25.05.20250221.32fb99b`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.25.5`
 - nixpkgs: `/nix/store/qc7n2v5yl42m2wq59f59ly6igiwljh11-source`

mitchmindtree avatar Feb 24 '25 00:02 mitchmindtree

Hmmm this seemed to magically begin working today, perhaps after a nixos-rebuild switch with some more of my user groups or udev rules in place. Maybe a system restart since triggered udev rules that I didn't have present last time I tried or something? Either way closing for now.

mitchmindtree avatar Feb 28 '25 13:02 mitchmindtree

Re-opening as I'm running into this once more.

Specifically, starting the trezord service fails with the error above if no device is plugged in.

Here's the service output:

$ systemctl status trezord.service
× trezord.service - Trezor Bridge
     Loaded: loaded (/etc/systemd/system/trezord.service; enabled; preset: ignored)
     Active: failed (Result: exit-code) since Sun 2025-08-17 22:43:33 AEST; 3s ago
   Duration: 18ms
 Invocation: b0a19a5b103f43fb9e148b3bf9f31ced
    Process: 3000 ExecStart=/nix/store/s2dfn6qbr9wgdpcnzpmkvrsijcqxb6qj-trezord-go-2.0.33/bin/trezord-go (code=exited, status=1/FAILURE)
   Main PID: 3000 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
   Mem peak: 5.8M
        CPU: 3ms

Aug 17 22:43:33 mindasahi systemd[1]: Started Trezor Bridge.
Aug 17 22:43:33 mindasahi trezord-go[3000]: 2025/08/17 22:43:33 trezord v2.0.33 (rev 2680d5e) is starting
Aug 17 22:43:33 mindasahi trezord-go[3000]: 2025/08/17 22:43:33 libusb: error when initializing LibUSB.
Aug 17 22:43:33 mindasahi trezord-go[3000]: If you run trezord in an environment without USB (for example, docker or travis), use '-u=false'. For example, './trezord-go -e 21324 -u=false'.
Aug 17 22:43:33 mindasahi trezord-go[3000]: Original error: LIBUSB_ERROR_OTHER
Aug 17 22:43:33 mindasahi systemd[1]: trezord.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 22:43:33 mindasahi systemd[1]: trezord.service: Failed with result 'exit-code'.

My current system:

$ nix run nixpkgs#nix-info -- -m
 - system: `"aarch64-linux"`
 - host os: `Linux 6.14.8-asahi, NixOS, 25.11 (Xantusia), 25.11.20250809.85dbfc7`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.30.2`
 - nixpkgs: `/nix/store/c39q7pww80997lz0fyqxpvsr29q6f7ld-source`

Workaround

If I restart the systemd service while the device is plugged in via USB, then the service starts correctly:

$ systemctl status trezord.service
● trezord.service - Trezor Bridge
     Loaded: loaded (/etc/systemd/system/trezord.service; enabled; preset: ignored)
     Active: active (running) since Sun 2025-08-17 22:53:13 AEST; 3s ago
 Invocation: 338457763c5842c3aeaaa69c02366d79
   Main PID: 3360 (trezord-go)
         IP: 0B in, 0B out
         IO: 128K read, 0B written
      Tasks: 7 (limit: 14175)
     Memory: 5.2M (peak: 7M)
        CPU: 4ms
     CGroup: /system.slice/trezord.service
             └─3360 /nix/store/s2dfn6qbr9wgdpcnzpmkvrsijcqxb6qj-trezord-go-2.0.33/bin/trezord-go

Aug 17 22:53:13 mindasahi systemd[1]: Started Trezor Bridge.
Aug 17 22:53:13 mindasahi trezord-go[3360]: 2025/08/17 22:53:13 trezord v2.0.33 (rev 2680d5e) is starting

mitchmindtree avatar Aug 17 '25 13:08 mitchmindtree

This also reproduces on Gentoo (with Asahi Linux), so it is not a NixOS-specific problem. A good next step would be to see if it reproduces on any other ARM platforms.

waltmck avatar Sep 14 '25 21:09 waltmck