3

TLDR

I want toggle between the following usages of a usb-port via the terminal:

  1. use like a normal usb-port
  2. only supply energy to charge

Story

I recently got me something like a magna doodle that can save your drawings to pdf, which can be moved to your computer via usb afterwards. Now the thing is that you can't save anything while it's plugged in.
Because it's the only way to charge it, it bugs me that I can't find a software solution and laziness I want to keep it plugged in and toggle the connection to the computer only when needed.
I noticed that it's charging and usable when it is plugged in and the computer is shut down or suspened. So I guess that there's a way to do it.

Tech info

  • computer: ThinkPad X201
  • Linux Kernel: 3.14.5-1-ARCH
  • "Magna doodle": Boogie Board Sync
1
  • If there isn't a software solution, you can get a USB adapter that does this for less than $10. Google Link – Darth Android Jun 9 '14 at 14:38
4

Try: echo 0 > /sys/bus/usb/devices/${usb}/authorized where ${usb} is the usb port in question; use lsusb -t to get a list. So... 0=disabled, 1=enabled

I actually use this to cut off power to an external hdd although from what I know this doesn't really cut off power but instead it's the hdd's power management features that turn it off because it no longer considers it connected. Cutting the power to an usb port seems to be imposible; the only thing that appears to do it is to remove the entire usb module (although I haven't actually checked the voltages or anything :) ).

2
  • nice approach, although this isn't working for my setting. – Ergot Jun 13 '14 at 11:53
  • 1
    what happens when you set authorized to 0? – alex Jun 16 '14 at 7:33
0

Darth Android's comment is helpful. It's really much easier to get a powered USB hub that does this.

From a Linux perspective, USB support is usually compiled into the kernel, not loaded as a module. This means that USB support can't be effectively disabled in software, even by manipulating driver modules (as one might do with a network card, etc).

Depending on how the device firmware and hoe the device appears to the operating system, it may be possible to tweak the driver into sending a USB disconnect command, which would tell the device to stop accepting further USB commands and enter a charge-only mode. This is non-trivial, however, and this approach is best left to skilled programmers comfortable with device drivers.

1
  • @alex solution above somehow works, so your sentence "USB support can't be effectively disabled in software" doesn't seem accurate. – jjmontes Dec 11 '18 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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