[GUIDE]How to disable a specific USB port on LibreELEC

  • My HTPC is setup for dualboot LibreELEC with Windows 10 and Windows is only used for games and emulators.
    I own a Dolphinbar to be able to use my Wii remotes with Dolphin(Wii emulator) and anyone having the Dolphinbar knows it has those bright blue leds facing you, which can be very distracting when watching a movie in the dark.

    Since the Dolphinbar, in my case, is useless in LibreELEC and don't feel like having to move it or unplug/plug it every time i decided to disable it when LibreELEC boots via the USB port and share this little guide in case someone else is facing a similar situation(this guide will not work for every situations).

    Here is how it's done (i will use my Dolphinbar as an example);

    -First you need to find the USB port of the device by sending the command below via SSH

    Code
    lsusb

    In my case it gives me this output


    The Bus ID of the Dolphinbar is: 057e:0306

    -Now we are going to find where the device is located by sending the command "grep"+ the second part of the Bus ID, which in my case would be: 0306, use your Bus ID

    Code
    grep 0306 /sys/bus/usb/devices/*/idProduct

    In my case it gives me this output

    Quote


    /sys/bus/usb/devices/3-10/idProduct:0306


    The location of your device will be displayed after "/devices" which in my case is: 3-10, and now we can disable the specific USB port of the Dolphinbar by sending 2 commands via SSH.

    Now let's make sure those commands work via SSH before putting them in "autostart.sh" for them to take effect at every boot.
    -Using the location of your device, which in my case the Dolphinbar is located at "3-10" use your device location after /devices, send these 2 commands via SSH;

    Code
    echo "0" > "/sys/bus/usb/devices/3-10/power/autosuspend_delay_ms"
    Code
    echo "auto" > "/sys/bus/usb/devices/3-10/power/control"


    If it worked your device should now be disabled/powered off and you can now create an "autostart.sh" file and place it at: storage/.config
    Now we need to edit the "autostart.sh" file and we will add a little delay to those commands because if they are executed too early during boot they might not take effect.

    -Again using the location of your device, which in my case the Dolphinbar is located at "3-10" edit the "autostart.sh" like so;

    Bash
    #!/bin/sh
    sleep 3; echo "0" > "/sys/bus/usb/devices/3-10/power/autosuspend_delay_ms" &
    sleep 5; echo "auto" > "/sys/bus/usb/devices/3-10/power/control"


    You can increase or decrease the delay but in my case the minimum delay for this to work is, "sleep 1" for the first command and "sleep 2" for the second.

    Save it and if you need to make it executable send this command;

    Code
    chmod +x /storage/.config/autostart.sh


    Now after rebooting the system your USB device should automatically disable itself not long after the Kodi splash screen.

    Edited once, last by vitorp07 (March 22, 2017 at 1:41 PM).