Blockstream / Blockstream/green_qt

Green on Linux should check power saving status of Jade

Open
#89 3 comments 0 reactions 1 assignee Claimed by @ardier16 View on GitHub
bug platform: linux status: confirmed
Dominant language
C++
Stars
262
Forks
44
PR merge metrics
No merged PRs in 30d

Description

On a more modern Linux such as Fedora, a default power saving config option prevents newer Jade units from being able to communicate with the Green app, causing it to crash. Older Jades are unaffected because they have a different serial chip.

We should query if the power saving feature is enabled or not and provide an alert to the user that points them to instructions (I'm thinking [here](https://help.blockstream.com/hc/en-us/articles/900005443223-Why-is-Blockstream-Jade-not-recognized-by-my-computer-) is a good home) for how to install appropriate udev rules that disable this feature every time the Jade is plugged into the host machine.

To check if a Jade is plugged in we can look to see if `/dev/ttyACM0` exists and then proceed to determining if power saving is enabled.

It's possible for a non-root user to query the state of the power saving feature, even when inside a Flatpak sandbox:

```
$ cat /sys/bus/usb/devices/1-2/power/control
auto
```
Note this path is dependent on the user's machine and is very likely to be different across different sets of hardware. But, we can (again, as non-root user) look in each device subdirectory for the `idProduct` and `idVendor` files which contain the product and vendor IDs and see if we can find Jade's:

```
$ pwd
/sys/bus/usb/devices

$ ls -la */idProduct*
-r--r--r--. 1 root root 4096 May 30 07:36 1-10/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 1-7/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 1-8/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 3-1/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb1/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb2/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb3/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb4/idProduct

$ cat 1-10/idProduct
01a2

This particular device is not Jade :(. On to the next one...
```
I've tested the udev rule below (placed in `/etc/udev/rules.d/21-jade.rules`) on a couple different Fedora machines successfully.

```
ATTRS{idProduct}=="55d4", ATTRS{idVendor}=="1a86", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="on"
```
This will turn off the power saving automatically any time a Jade is plugged in.

Older Linux distros like Ubuntu 22.04 do not enable the power saving OOTB and are unaffected by this, but future versions might. It's unclear if it's a difference between Linux kernel versions or their configs or if Ubuntu is intentionally turning this off and Fedora leaves it untouched, so it's a good idea to tackle this ahead of time.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.