Photon OS

 View Only
Expand all | Collapse all

Photon 4R1 how to passthrough usb

  • 1.  Photon 4R1 how to passthrough usb

    Posted Oct 30, 2021 05:23 PM

    Trying to passthrough a usb controller so my portainer/octoprint can connect to my controller. Not seeing it under systemctl cant find much information on how to set this up. 



  • 2.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 31, 2021 02:30 PM

    Hi ,

    Photon OS knows a few flavors (linux-aws, linux-esx, linux-rt, linux-secure, linux). For non-cloudnative purposes better use the generic (linux) one because the generic config includes much more devices than the ESXi-purposed config. The generic bits are included in full isos x86_64 + arm64.

    A host-connected solution with passthrough of the USB controller requires PCI device and usb controller driver support. ESXi supports passthrough for many years, ESXi-Arm is quite new. Here the Photon OS driver support related links. As example, CONFIG_USB_SERIAL_CH341=m means that the CH341 chip is supported.

    For client-connected usb you could use Virtualhere usb over ip. Virtualhere runs on Photon OS. As example, to list pci and usb devices on a Virtualhere-on-PhotonOS box try this

    tdnf install pciutils usbutils
    lspci
    lsusb

     

    Hope this helps. Daniel



  • 3.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 31, 2021 03:06 PM

    So originally I attempted adding a USB controller like I had done for my powerpanel ups which worked. But I didn't see any devices on this one when I ran systemctl.

    Pollard_0-1635692331549.png

     

     

    So your saying virtual here is already part of photon. What would I use for the device path in portainer?

    Pollard_1-1635692704562.png

     

     



  • 4.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 31, 2021 04:02 PM

    Attempting to do an actual passthrough now is there something I need to change in the config 1st? Or of it shows up in systemctl its supported?

     

    Pollard_0-1635696068761.png

     



  • 5.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 31, 2021 04:44 PM

    For host-connected passthrough, the hardware must be present on the physical ESXi host where the vm runs.

    For usb passthrough, on the vm settings add new device > Host USB Device, and select the usb device (your 3d printer usb device). In addition, a virtual usb controller is needed, too. Can you double check this step? Inside the photon vm, with lsusb -v you can identify usb devices and usb controllers.

    if an usb device is not supported by using the usb passthrough feature, well, you can try using the pci passthrough feature (vmdirectpass). Be aware that connecting the entire physical usb controller does not impact other functionalities (keyboard, mouse). ESXi host > configure > select pci devices in hardware section > select the usb controller. usb 2.0 (EHCI) is supported.

     



  • 6.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 01, 2021 06:34 PM

    Ahh ok I  forgot to pick the usb device. I was able to find it witht lsusb -v. its the Bus 003 Device 003: ID 1a86:7523 QinHeng Electronics CH340 serial converter. What path would I use I tired /dev/ttyUSB0 didn't show up. 

     

     

     

     



  • 7.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 01, 2021 07:59 PM

    Ahh ok I  forgot to pick the usb device. I was able to find it witht lsusb -v. its the Bus 003 Device 003: ID 1a86:7523 QinHeng Electronics CH340 serial converter. What path would I use 

     

     



  • 8.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 02, 2021 04:25 AM

    Journalctl protocol helps identifying the tty device connected over usb.

    journalctl -b -1 | grep tty



  • 9.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 02, 2021 12:50 PM

    I was thinking the CH341 drivers would work for the CH340 but its not showing any tty/usb.

     

     

     

     



  • 10.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 02, 2021 02:03 PM

    The problem is that there is no ttyUSB or similar. Can you post the output from following lines?

    modinfo ch341
    uname -r
    ls /dev/tty*

     

    Here's a sample.

    root@photonos [ ~ ]# modinfo ch341
    filename: /lib/modules/5.10.61-2.ph4/kernel/drivers/usb/serial/ch341.ko.xz
    license: GPL v2
    srcversion: D1F1D2B7899A3E400010C90
    alias: usb:v9986p7523d*dc*dsc*dp*ic*isc*ip*in*
    alias: usb:v4348p5523d*dc*dsc*dp*ic*isc*ip*in*
    alias: usb:v1A86p7523d*dc*dsc*dp*ic*isc*ip*in*
    alias: usb:v1A86p7522d*dc*dsc*dp*ic*isc*ip*in*
    alias: usb:v1A86p5523d*dc*dsc*dp*ic*isc*ip*in*
    alias: usb:v1A86p5512d*dc*dsc*dp*ic*isc*ip*in*
    depends: usbserial,usbcore
    retpoline: Y
    intree: Y
    name: ch341
    vermagic: 5.10.61-2.ph4 SMP mod_unload modversions
    sig_id: PKCS#7
    signer:
    sig_key:
    sig_hashalgo: unknown
    signature:
    root@photonos [ ~ ]# uname -r
    5.10.61-2.ph4
    root@photonos [ ~ ]# ls /dev/tty*
    /dev/tty /dev/tty14 /dev/tty20 /dev/tty27 /dev/tty33 /dev/tty4 /dev/tty46 /dev/tty52 /dev/tty59 /dev/tty8 /dev/ttyS5
    /dev/tty0 /dev/tty15 /dev/tty21 /dev/tty28 /dev/tty34 /dev/tty40 /dev/tty47 /dev/tty53 /dev/tty6 /dev/tty9 /dev/ttyS6
    /dev/tty1 /dev/tty16 /dev/tty22 /dev/tty29 /dev/tty35 /dev/tty41 /dev/tty48 /dev/tty54 /dev/tty60 /dev/ttyS0 /dev/ttyS7
    /dev/tty10 /dev/tty17 /dev/tty23 /dev/tty3 /dev/tty36 /dev/tty42 /dev/tty49 /dev/tty55 /dev/tty61 /dev/ttyS1
    /dev/tty11 /dev/tty18 /dev/tty24 /dev/tty30 /dev/tty37 /dev/tty43 /dev/tty5 /dev/tty56 /dev/tty62 /dev/ttyS2
    /dev/tty12 /dev/tty19 /dev/tty25 /dev/tty31 /dev/tty38 /dev/tty44 /dev/tty50 /dev/tty57 /dev/tty63 /dev/ttyS3
    /dev/tty13 /dev/tty2 /dev/tty26 /dev/tty32 /dev/tty39 /dev/tty45 /dev/tty51 /dev/tty58 /dev/tty7 /dev/ttyS4
    root@photonos [ ~ ]#

     

     



  • 11.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 02, 2021 02:50 PM

    Ahh its saying the ch341 module isn't found. I used the OVA with virtual hardware v13 (UEFI Secure Boot) version can I install that module or do I need to re-install using the full iso version? I think it might be better to do an actual passthrough of the usb controller the usb device appears to not automatically rebind when I cut the 3d printer off and back on. The 8 Series/C220 Series Chipset Family USB EHCI #1 does show up under lspci not sure if it has the drivers.

     

     

     

     

     

     

     

      



  • 12.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 02, 2021 04:27 PM

    The ESXi optimized and hardened Photon OS bits (.phX-esx) do not contain usb port drivers like ch341, belkin, prolific, etc. and only a few of them are included in the generic kernel version.

    As example, an anycubic vyper 3d scanner uses internally a ch341 chip. Hence, for a host-connected solution with passthrough the chain 3d scanner - ESXi - Photon OS - your-management-and-dashboard-solution must be quaranteed. The same approach goes for a client-connected solution as well.

    The ch341 module is already included in the full iso x86_64. Yes you can easily setup Photon OS using the full iso and should have the host-connected interoperability.

    I will try these next days to assemble a recipe on how to add usb port drivers on ph4-esx as it might be an interesting use case for others as well.



  • 13.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 05, 2021 02:52 AM

    Which version of 4 has the CH drivers I tried the realtime since it look to have the most installed. But that's even saying it doesn't have them. Guess I'll try Photon 3 in the meantime

    Minimal
    Developer
    OSTree Host
    Real Time



  • 14.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 16, 2021 12:12 PM

    In Photon 4.0 rev1 (aarch64, developer) on Pi4b I've noticed that the ch341 driver isn't built-in available, indeed. There is a 3rd party github repo with an older ch34x driver and after the installation it is recognized as usb driver.

    The following driver installation recipe isn't optimized. At least accordingly to the dmesg output the functionality seems to work, and there should be a /dev/tty* entry. Unfortunately I do not have a test device. 

    In addition, the author of the driver clearly mentioned the prerequisites - those are important for the Photon 3+4 bits as well: It may happen, that kernel doesn't contain CONFIG_USB_SERIAL_CH341 flag, but you need it or it is disabled. You have to check configs of the kernel you are using.

    Not sure if the following recipe helps in your portainer related scenario on ESXi x86_64 using Photon 3 or 4.

    tdnf distro-sync -y
    tdnf install build-essential git linux-api-headers linux-devel usbutils -y
    # reboot here mkdir /lib/modules/$(uname -r)/build git clone https://github.com/juliagoda/CH341SER cd CH341SER make ls ch34x.ko ¦ xargs gzip cp ch34x.ko.gz /usr/lib/modules/$(uname -r)/kernel/drivers/usb/serial cp ch34x.ko.gz /lib/modules/$(uname -r)/kernel/drivers/usb/serial depmod -a modprobe ch34x lsmod dmesg ¦ grep ch34 ls /dev/tty* modinfo ch34x

     



  • 15.  RE: Photon 4R1 how to passthrough usb

    Posted Nov 27, 2021 02:44 PM

    Just now circling back on this. I ended up getting a new 32-bit board for my printer that shows up as STMicroelectronics GENERICSTM32F103RC CDC in FS Mode.

    Pollard_0-1638024212310.png

    I was able to get octoprint working with it just by passing the usb device through and using g host /dev/ttyUSB0 and container /dev/ttyACM0. 

     

     

     

    ** Adding this in here ** Mine quit working recently after an update ran 

    ls -l /dev/serial/by-id  which informed me for whatever reason my host change from /dev/ttyUSB0 to /dev/ttyACM0 so now I haver to put the for the host and container.



  • 16.  RE: Photon 4R1 how to passthrough usb

    Posted Mar 25, 2023 08:25 PM


     wrote:

    Just now circling back on this. I ended up getting a new 32-bit board for my printer that shows up as STMicroelectronics GENERICSTM32F103RC CDC in FS Mode.

    Pollard_0-1638024212310.png

    I was able to get octoprint working with it just by passing the usb device through and using g host /dev/ttyUSB0 and container /dev/ttyACM0. 

     

     

     

    ** Adding this in here ** Mine quit working recently after an update ran 

    ls -l /dev/serial/by-id  which informed me for whatever reason my host change from /dev/ttyUSB0 to /dev/ttyACM0 so now I haver to put the for the host and container.


    Please, forget the recent replies. Wrong way. It doesn't help for the /dev/ttyACM0 issue.

    If the symlink /dev/ttyACM0 still is an issue, have a look to the directory content /etc/udev/rules.d/  
    - there might be a rules configuration file beside the 99-vmware-hotplug.rules file.
       Inside such a file, you could find something like KERNEL=="ttyACM", Subsystem, VendorId, ProductID, Symlink, ...
    - An usb device attached to the vm should be e.g. /dev/bus/usb/001/003.
      To identify the usb device, run e.g. lsusb -D /dev/bus/usb/001/003 . To identify symlink try e.g. ls -l /dev/bus/usb/001 .
    - udevadm info /dev/bus/usb/001/003 shows device information from udev database.
      udevadm info -q path /dev/bus/usb/001/003 shows the full pci path.
    - Files in /etc/modprobe.d/ are used to pass module settings to udev . On ESXi with attached usb devices for a Photon OS vm, see usb.conf entries sequence ohci and uhci .
    This is the way.



  • 17.  RE: Photon 4R1 how to passthrough usb

    Posted Apr 26, 2022 08:56 AM

    This is working perfectly in Photon minimal (4.0-c001795b8)! I'm using PhotonOS as a VM with the specialised kernel in ESXi vSphere 7.0 Update 3.

    The post initially mentioned passthrough but my problem had more or less to do with what  described as the CH340 USB to serial controller wasn't recognised in the kernel due to the missing driver.

    I don't see the point in installing the full ~4GB image just for this one device when I can use the minimal ~400MB image and this fantastic 'hack' - Thanks!



  • 18.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 29, 2022 02:18 PM

    Trying to determine the path i.e. "ttyACM0" of the webcam so I can pass add the device through docker. 

    Looking for the logitech webcam shown here

     

    This command only return's the 3d printer

     

     

     



  • 19.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 29, 2022 07:28 PM

     the following recipe does not work yet. I will give a try these days to finish it.

    First, see https://docs.vmware.com/en/VMware-Horizon/2206/linux-desktops-setup/GUID-F3F2D262-62DA-4DFC-810D-FFEF5FA49A66.html

    We need the so-called v4l2loopback driver. To list webcam (and audio) devices, the v4l-utils have to be installed. Here the x86_64 snippet.

    tdnf install -y wget curl tar build-essential libjpeg-turbo-devel gettext
    wget http://linuxtv.org/downloads/v4l-utils/v4l-utils-1.22.1.tar.bz2
    tar xf v4l-utils-1.22.1.tar.bz2
    cd v4l-utils-1.22.1
    ./bootstrap.sh
    ./configure
    make
    make install
    ./utils/v4l2-ctl/v4l2-ctl --list-devices

    This should work flawlessly, but v4l2-ctl --list-devices throws out cannot open device /dev/video0, exiting. which makes sense because the v4l2loopback driver isn't installed yet.

    The following code snippet for the v4l2loopback driver produces errors e.g. ERROR: "video_ioctl2" [./v4l2loopback.ko] undefined! on the step make .

    tdnf install -y linux-esx-devel dkms unzip git
    cd /usr/src
    mkdir v4l2loopback
    git clone https://github.com/umlaeute/v4l2loopback.git v4l2loopback
    cd v4l2loopback
    make
    make install

    Accordingly to a github issue entry here of minijackson, the kernel option CONFIG_MEDIA_SUPPORT has to be added.

    Head banging on Photon OS 4.0 rev 2, 5.10.142.4.ph4-esx.

    # 10/30/2022: modified code snippet v4l-utils for Photon OS 3.0 compatibility



  • 20.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 30, 2022 03:09 PM

    Got a few errors

    Running
    VMware Photon OS 3.0
    PHOTON_BUILD_NUMBER=11dd065

     



  • 21.  RE: Photon 4R1 how to passthrough usb

    Posted Oct 30, 2022 07:46 PM

    I've modified the code snippet above with respect to the steps on Photon OS 3.0 as well.

    To allow the Photon OS kernel option mentioned ( zcat /proc/config.gz | grep CONFIG_MEDIA_SUPPORT ), the kernel may be rebuild and this may not be all. I will update this thread as soon as possible.



  • 22.  RE: Photon 4R1 how to passthrough usb

    Posted Mar 18, 2024 02:27 PM

    It's have been a while..

    If someone still is interesting, here a description what it takes to passthrough usb.

    Photon OS is hardened. This is is old stuff and reasonable for cloud-native purposes.

    This also means that you cannot plugin e.g. usb devices and assume sort of plug'n'play feature availability from modules.

    The restriction by Linux kernel configuration is a barrier to protect users, to maintain functionality and provide safety.

    This means do not use Photon OS as yet another common-purpose Linux distro because it never was intended for that.

    As a Linux developer, you must have learned how to make build packages and how to maintain them, resolve package dependencies, taking into account of different cpu architectures and different flavors, etc.

    For this kind of maintenance, the best way for Photon OS actually is to start with docs Building Package or Kernel Modules Using a Script | (vmware.github.io) .

    In this context, how to recompile Linux kernel has been a question in the Photon OS github forum: Is there a menuconfig for Photon OS 4.0 Rev2 to recompile the kernel? · Issue #1412 · vmware/photon (github.com). Kernel Live patching is a 2nd way. Both ways aren't documented yet in the meaning as official tutorial.

    So, is passthrough usb possible within Photon OS? At the edge yes but it depends on taking the extra mile.