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!

2 Answers 2

0

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

1
  • Thank you! The small C-program did it, totally missed that. Thanks alot! Commented Jul 14, 2016 at 17:29
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

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 github.com/codazoda/hub-ctrl.c
    – MatsK
    Commented Sep 11, 2017 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.