3

I have a raspberry pi 2 Model B and I want to disable the power to ethernet and USB hub port, I try using hub ctrl. c command, and it doesn't work.

Is this happening because of the limitation of the hardware? Will this be working on Raspberry Pi 3 Model B?

Actually, I want to control the USB port. Since there are four USB ports on my raspberry pi 2 model B, I want to know If it is possible to turn off the power of USB ports with software, not with hardware.

M. Rostami
  • 4,323
  • 1
  • 17
  • 36
Wei Lin
  • 41
  • 2
  • Hello and welcome -- Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – M. Rostami Mar 28 '20 at 09:05
  • 1
    Hello I want to control the USB port. Since there are four USB ports on my raspberry pi 2 model B, I want to know If it is possible to turn off the power of USB ports with software, not with hardware. – Wei Lin Mar 28 '20 at 11:25

1 Answers1

3

Installation

You can block the power of all USB ports by the following procedure.

sudo apt-get install libusb-dev git  

Get the required source:

git clone https://github.com/codazoda/hub-ctrl.c

Go to the new directory by cd hub-ctrl.c and install it:

gcc -o hub-ctrl hub-ctrl.c -lusb

Usage

Turn off Ethernet Port:

sudo ./hub-ctrl -h 0 -P 1 -p 0

Turn on Ethernet Port:

sudo ./hub-ctrl -h 0 -P 1 -p 1

Turn off all USB Ports:

sudo ./hub-ctrl -h 0 -P 2 -p 0

Turn on all USB Ports:

sudo ./hub-ctrl -h 0 -P 2 -p 1 

Will this be working on Raspberry Pi 3 Model B?

Yes, you can use it on Raspberry Pi 3B. The Raspberry Pi 2 has this feature to cut/block the power of USB ports. If this procedure doesn't work, you accomplish it by uhubctl. It supports Raspberry Pi models B+, 2B, 3B, 3B+, and 4B.
Another approach is binding/unbinding the individual post but not work on all types of connected devices.


References:

M. Rostami
  • 4,323
  • 1
  • 17
  • 36