1

I have a USB powered dash-cam that runs off a normal cigarette lighter for its power. I have a use for my car to run a raspberry pi and I wanted to use the pi to power this camera.

I have written some code where once I pull up to my house and the pi connects to my home network, it will run a script to backup content to a cloud storage device in the house. This allows me to not have to touch the camera, take out the SD card etc.

In theory, this would work fine. The issue I am facing is that when I plug the USB into the pi, it is allowing me to navigate the filesystem of the camera instead of just supplying power to it.

Is there a way I can tell the pi to use a specific USB port for power only and prevent the camera from thinking its plugged into a PC that wants to access its media?

I will have a need to toggle this back so that when I do connect to my home network, it connects in "file share" mode so my pi can then access the media files. For the time being though, looking for a way to specify a USB slot as power only.

  • they sell charge only usb cables that only have the power lines no data lines. – Steve Robillard Oct 27 '17 at 17:34
  • @SteveRobillard While I do need the power only at times, I also need a way to toggle this so that when I do arrive home and the wifi network connects, i can tell the USB to now access the file system so I can offload the media files. So the cable would need to be both power/data but the port it self would need to be able to be toggled if possible. – SBB Oct 27 '17 at 17:35
1

A software-only solution that comes to mind would be to disable the kernel module for USB support.

However, the default Raspbian kernel does not have USB compiled as a module, so you would need to rebuild the kernel with CONFIG_USB=m. To set this from make menuconfig (after getting set up to build your own kernel), select Device Drivers -> USB support -> Support for Host-side USB, set to m

Then sudo modprobe -r usbcore to turn USB support off if you turned it on at startup.

While it may be tempting to toggle only usb-storage.ko (USB Mass Storage support), from what I've read it would still get autoloaded whenever a thumb drive is connected.

I will have a need to toggle this back so that when I do connect to my home network, it connects in "file share" mode so my pi can then access the media files.

Can be turned on again afterward via sudo modprobe usbcore

I have not tested this myself. If you don't find a better way and then rebuilding the kernel justifies the effort, let me know what issues you encounter. There might be trouble loading the driver after boot time or disabling while it is in use.

Ideally there would already be a way to do this from userspace alone. You might be aware of this thread. Unfortunately, although you can disable USB power (not what you want), bussuspend for data does not immediately work as expected. I have confirmed the same issue on my Pi 3.

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.