3

I have a problem with disabling any USB ports with the command: sudo sh -c "echo 0 > /sys/devices/platform/soc/3f980000.usb/buspower" Nothing happens at all, though the content of the file IS changed to 0x0 or 0x1.

When entering

sudo sh -c "echo 0 > /sys/devices/platform/soc/3f980000.usb/buspower"

the LED of the webcam I'm trying to turn off flashes of and on for about half a second so it is affecting the USB ports in some way.

Thanks in advance!

Pontus Drejer
  • 33
  • 1
  • 4

2 Answers2

0

Here is a related question where we discussed an app that allows control of USB ports from the command-line.

tlhIngan
  • 3,342
  • 5
  • 18
  • 33
0

Because it's impossible to disable the usb power, I've used udev rules and a script installed in /usr/local/sbin (tested on Raspberry PI3)

The script :

 \#!/bin/bash  
 ROOTUSB=/sys/devices/platform/soc/3f980000.usb/usb1/1-1  
 \#Exceptions network device  
 EXC="1-1.1 1-1:1.0"  
 for host in $ROOTUSB/*  
 do  
if [ -f $host/authorized ];then  
disable=1  
\# Parse exception to allow them to be enabled (network...)  
for device in $EXC  
do  
\# If host ending equal excetion =>> dont change state  
[[ $host =~ \/$device$ ]] && disable=0  
done  
\#Otherwise change state ==> disable  
if [ $disable = 1 ];then  
\#USB host to disable  
echo 0 >  $host/authorized  
fi  
fi  
done  

The udev rules

 /etc/udev/rules.d/10-disableusb.rules  
ACTION=="add", SUBSYSTEMS=="usb", RUN+="/usr/local/sbin/disable-usb.sh"  

Refresh udev rules

udevadm control --reload-rules  

Plug in a storage usb device, now, you are not allowed to enumerate filesystems

Bex
  • 2,919
  • 3
  • 24
  • 34
dhenry
  • 1
  • please read the other answer! There is a way of controlling the power and it's by using the feature that check if the USB port is shorten or not, check https://github.com/codazoda/hub-ctrl.c – MatsK Sep 11 '17 at 16:56