OutsourcedGuru / OctoPrint-USBControl

An OctoPrint plugin to allow USB ports to be programmatically turned OFF and ON from within the web interface
53 stars 17 forks source link

Raspberry Pi 4B incompatibility #5

Open LinoBarreca opened 5 years ago

LinoBarreca commented 5 years ago

it complains that it isn't installed on a Pi2/3 and doesn't work.

LinoBarreca commented 5 years ago

lsusb -t output: /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M | Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M | Port 4: Dev 4, If 0, Class=Vendor Specific Class, Driver=ch341, 12M <--------3d printer

LinoBarreca commented 5 years ago

yes I did

OutsourcedGuru commented 5 years ago

I guess I will need to wait until I myself get a Raspberry Pi 4B so that I can adjust the software. What's sad is that the three versions (1MB, 2MB and 4MB) will each have different IDs, making this problematic.

LinoBarreca commented 5 years ago

I guess it's just the ram size which is different. what IDs are you talking about? are you using a sort of ID to see if you are running on some PI model?

OutsourcedGuru commented 5 years ago

The output of cat /proc/cpuinfo returns a Revision which has an identifier for the board. I've managed to research this for the three new RAM flavors of the Raspi 4B but I still need to have one now so that I can research what type of USB buses they're now using in this. There are smart buses and otherwise. Of the first type, there are ganged and individually-controllable. The recent 3B+ split the bus into two plus two; I'm guessing they did something similar with the 4B.

mvp commented 5 years ago

You cannot fix this until uhubctl can support it. And that requires updated firmware for 4B, see https://github.com/raspberrypi/linux/issues/3079.

OutsourcedGuru commented 5 years ago

Bummer. I've subscribed to your thread to keep an eye on this.

mvp commented 4 years ago

uhubctl should now support Raspberry Pi 4B (port 4 only) https://github.com/mvp/uhubctl/commit/4aae44ced039. You may need to update USB firmware to https://www.raspberrypi.org/forums/download/file.php?id=33477 Please give it a try and report back.

Dracrius commented 4 years ago

@OutsourcedGuru Any updates on possible pi 4B support after the uhubctl update? I recently installed a new printer mainboard and setup my 4B for Octoprint with psu control. My Ender 3's stock mainboards usb stopped responding to anything but the 5v line so Im super paranoid that octoprints 5v supply fried something in my stock board. This seems like the best setup for preventing it in the future. If not having a 4B is your main limit Id happly do a veriatey of tests to help using my own. I figure my time is better spent helping you get the pluging as universal as possible then it is spending the time unknowingly trying to make uhubctl work for myself!

Vuego123 commented 4 years ago

I'm using a RPI4 with 2GB and with the following uhubctl command I can toggle all the usb ports on /off:

(don't forget to give sudo rights to the user without password via "sudo visudo" ... )

The plugin could detect the type of RPI (2/3/4) based on the output of cat /proc/cpuinfo In case it is a RPI4, then the plugin could show 1 toggle to toggle all ports.

Might it be possible to add that logic to the plugin?

OutsourcedGuru commented 4 years ago

I might. I've just been busy doing other things lately.

JHale716 commented 4 years ago

I have a Pi4-2GB for Octoprint, if I can help, ping me.

TokugawaHeavyIndustries commented 4 years ago

Just submitted a pull to update for RPi4. Note this is a bigger rewrite that removes the ability to toggle individual ports on RPi3B+, per the latest uhubctl update. This is tested and confirmed working on RPi3B+ and RPi4B boards.

sr1329 commented 3 years ago

How do I install your branch?

nemccarthy commented 3 years ago

@sr1329 if you add a plugin from URL and use https://github.com/TokugawaHeavyIndustries/OctoPrint-USBControl/archive/master.zip it should work on the Pi4

@TokugawaHeavyIndustries thanks for this!!! Have installed on a 4gb Pi 4B and its working great. Can now turn off my printer and screen! Would be great to see this merged into master.

Coolie1101 commented 3 years ago

@sr1329 if you add a plugin from URL and use https://github.com/TokugawaHeavyIndustries/OctoPrint-USBControl/archive/master.zip it should work on the Pi4

@TokugawaHeavyIndustries thanks for this!!! Have installed on a 4gb Pi 4B and its working great. Can now turn off my printer and screen! Would be great to see this merged into master.

Just installed on a Pi 4 B 4GB and toggling the switch doesn't seem to control the power, but "sudo /home/pi/uhubctl/uhubctl -l 1-1 -a 0" works, seems like the switch is executing the wrong command. 2020-10-30 12:08:54,661 - octoprint.plugins.usbcontrol - INFO - usb4off... 2020-10-30 12:08:54,713 - octoprint.plugins.usbcontrol - INFO - uhubctl failed, throwing error 2020-10-30 12:09:11,373 - octoprint.plugins.usbcontrol - INFO - usb4on... 2020-10-30 12:09:11,417 - octoprint.plugins.usbcontrol - INFO - uhubctl failed, throwing error

TokugawaHeavyIndustries commented 3 years ago

@Coolie1101 Did you install the commit from my pull/branch or did you install the main from OutsourcedGuru?

mvp commented 3 years ago

@OutsourcedGuru , if you have abandoned this project, perhaps you should pass the helm to @TokugawaHeavyIndustries. I would be happy to update uhubctl readme to point to @TokugawaHeavyIndustries repository instead.

Coolie1101 commented 3 years ago

@Coolie1101 Did you install the commit from my pull/branch or did you install the main from OutsourcedGuru?

Installed via link with "https://github.com/TokugawaHeavyIndustries/OctoPrint-USBControl/archive/master.zip"

mvp commented 3 years ago

@Coolie1101 , did you upgrade RPI 4 firmware? Also, please show output of sudo uhubctl

mvp commented 3 years ago

@TokugawaHeavyIndustries , @Coolie1101 , your plugin should be calling uhubctl -l 2 -a 0 (or uhubctl -l 1-1 -a 0. Also, need to make sure to use uhubctl version 2.2.0 or later.

TokugawaHeavyIndustries commented 3 years ago

@mvp I just updated my fork to the latest ver of uhubctl. Looks like the I was originally using v2.1.0-38-gb73213dd.

TokugawaHeavyIndustries commented 3 years ago

And yes the command for the 4B that the plugin is sending is uhubctl -l 1-1 -p 1-4 -a 0

mvp commented 3 years ago

Note that -p 1-4 is the same as -p all or not specifying ports at all.

TokugawaHeavyIndustries commented 3 years ago

Yeah that was leftover from @OutsourcedGuru 's original work, and I just haven't cleaned it up. 😄

Coolie1101 commented 3 years ago

did you upgrade RPI 4 firmware? Yes.

sudo uhubctl pi@octoprint:~ $ sudo uhubctl Current status for hub 2 [1d6b:0003 Linux 5.4.72-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0, USB 3.00, 4 ports] Port 1: 02a0 power 5gbps Rx.Detect Port 2: 02a0 power 5gbps Rx.Detect Port 3: 02a0 power 5gbps Rx.Detect Port 4: 02a0 power 5gbps Rx.Detect Current status for hub 1-1 [2109:3431 USB2.0 Hub, USB 2.10, 4 ports] Port 1: 0103 power enable connect [1a86:7523 USB Serial] Port 2: 0503 power highspeed enable connect [05a3:9331 HD Web Camera HD Web Camera Ucamera001] Port 3: 0100 power Port 4: 0503 power highspeed enable connect [2ab8:0531 Sonix Technology Co., Ltd. USB 2.0 Camera SN0001] Current status for hub 1 [1d6b:0002 Linux 5.4.72-v7l+ xhci-hcd xHCI Host Controller 0000:01:00.0] Port 1: 0503 power highspeed enable connect [2109:3431 USB2.0 Hub, USB 2.10, 4 ports]

pi@octoprint:~ $ uhubctl --version 2.2.0-13-gdcb1e611

Coolie1101 commented 3 years ago

Also, is the only way to use the feature is by going to settings>USBControl?

And is there any way to restore the usb camera connection after restoring power?

mvp commented 3 years ago

@Coolie1101 , USB camera should reconnect after restoring power. If that doesn't work, try adding -R to uhubctl command line - it should force USB bus reset.

Coolie1101 commented 3 years ago

@mvp, Tx, I tried with "sudo /home/pi/uhubctl/uhubctl -R", but no go.

mvp commented 3 years ago

@Coolie1101 , I meant adding this flag to other flags. Try this to turn power back on:

sudo uhubctl -l 2 -a 1 -R
Coolie1101 commented 3 years ago

sudo uhubctl -l 2 -a 1 -R

Doesn't seem to work, still no video until a host reboot.

TokugawaHeavyIndustries commented 3 years ago

@Coolie1101 Does the plugin work now (at least for turning off the power)?