udev Rules for Red Hydrogen One
on Android
Symptom
So you have your shiny new H4v-enabled Red Hydrogen in your hands, you’ve enabled USB Debugging on-device and you attach your cable… No confirmation prompt.
Firing up adb logcat
you are told that you have no permissions even though the user is in the plugdev group.
Solution
You need to add a new rule for the device.
Connect the usb cable and run dmesg
. At the end, you should see something like:
[ 2356.608888] usb 7-3.4: new high-speed USB device number 6 using xhci_hcd
[ 2356.733916] usb 7-3.4: New USB device found, idVendor=2ff0, idProduct=000e
[ 2356.733918] usb 7-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2356.733920] usb 7-3.4: Product: RED Hydrogen One
[ 2356.733922] usb 7-3.4: Manufacturer: RED
[ 2356.733923] usb 7-3.4: SerialNumber: xxxxxxxx
Edit the rules file. Your filename may be slightly different.
sudo nano /lib/udev/rules.d/51-android.rules
(or vi or emacs or whatever you prefer)
The vendors are usually alphabetical. Add a new entry. For me, based on the above, it was:
#Red
SUBSYSTEM=="usb", ATTR{idVendor}=="2ff0", ENV{adb_user}="yes"
Unplug the device, and then re-attach it. You should now be prompted to allow the connection.
If Android Studio or IntelliJ were already running, you may need to restart them.
Caveat
What if you have a version of 51-android.rules that is being updated by a third party? You might be getting it from
someone’s github repo, or maybe by going to the Android developer site
and running sudo apt-get install android-tools-adb
.
If you have a copy of that file that will be dynamically updated, any changes you make could get wiped out. In that case, I’d recommend having a secondary file for your own changes.
sudo nano /etc/udev/rules.d/51-android-extra.rules
and enter the following:
# Skip this section below if this device is not connected by USB
SUBSYSTEM!="usb", GOTO="android_extra_usb_rules_end"
# Devices listed here in android_usb_rules_{begin...end} are connected by USB
LABEL="android_extra_usb_rules_begin"
#Red
SUBSYSTEM=="usb", ATTR{idVendor}=="2ff0", ENV{adb_user}="yes"
# Enable device as a user device if found
ENV{adb_user}=="yes", MODE="0660", GROUP="plugdev", TAG+="uaccess"
LABEL="android_extra_usb_rules_end"
The beginning and end of this are very similar to the original, with the LABEL tweaked to not conflict.
Make sure to unplug the device and re-attach it.