<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/index.php?action=history&amp;feed=atom&amp;title=PineCube_as_a_webcam</id>
	<title>PineCube as a webcam - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/index.php?action=history&amp;feed=atom&amp;title=PineCube_as_a_webcam"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineCube_as_a_webcam&amp;action=history"/>
	<updated>2026-05-25T08:42:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineCube_as_a_webcam&amp;diff=19110&amp;oldid=prev</id>
		<title>Fxc: style</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineCube_as_a_webcam&amp;diff=19110&amp;oldid=prev"/>
		<updated>2023-03-30T10:30:28Z</updated>

		<summary type="html">&lt;p&gt;style&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:30, 30 March 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The [[PineCube]] can be powered by the host and communicate as a peripheral. First, you'll need to a dual USB-A (male) cable to plug it into your computer. Note that the Micro-USB port can be used only for power because the data lines are not connected.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The [[PineCube]] can be powered by the host and communicate as a peripheral. First, you'll need to a dual USB-A (male) cable to plug it into your computer. Note that the Micro-USB port can be used only for power because the data lines are not connected.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/del&gt;File:Pinecube_webcam1.jpg&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|400px]] [[&lt;/del&gt;File:Pinecube_webcam2.jpg&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|400px]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Pictures ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;gallery&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;File:Pinecube_webcam1.jpg&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;File:Pinecube_webcam2.jpg&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/gallery&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== USB as an Ethernet gadget ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== USB as an Ethernet gadget ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff::1.12:old-19108:rev-19110 --&gt;
&lt;/table&gt;</summary>
		<author><name>Fxc</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PineCube_as_a_webcam&amp;diff=19108&amp;oldid=prev</id>
		<title>Fxc: Outsourced</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PineCube_as_a_webcam&amp;diff=19108&amp;oldid=prev"/>
		<updated>2023-03-30T10:29:33Z</updated>

		<summary type="html">&lt;p&gt;Outsourced&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The [[PineCube]] can be powered by the host and communicate as a peripheral. First, you'll need to a dual USB-A (male) cable to plug it into your computer. Note that the Micro-USB port can be used only for power because the data lines are not connected.&lt;br /&gt;
&lt;br /&gt;
[[File:Pinecube_webcam1.jpg|400px]] [[File:Pinecube_webcam2.jpg|400px]]&lt;br /&gt;
&lt;br /&gt;
== USB as an Ethernet gadget ==&lt;br /&gt;
&lt;br /&gt;
Goal: To achieve fast (low latency) wired network connection via USB-A port of PineCube. PineCube will be shown as a network device when connected to a computer via USB-A port. You can set up the computer to be in the same network as PineCube and connect to PineCube via SSH and/or Stream Videos from it.&lt;br /&gt;
&lt;br /&gt;
1. Additional patch to PineCube device tree disable ehci0 and ohci0, enabling usb_otg device instead and setting '''dr_mode''' to '''otg'''. If otg is not working for you, try setting '''dr_mode''' to '''peripheral'''. ''On Armbian there is no need for disabling ehci0 and ohci0. Device tree can be edited via armbian-config tool on Armbian OS. (armbian-config -&amp;gt; System -&amp;gt; DTC)''&lt;br /&gt;
: sample DTC on Armbian:&lt;br /&gt;
                -----&lt;br /&gt;
                &lt;br /&gt;
                usb@1c19000 {&lt;br /&gt;
                        compatible = &amp;quot;allwinner,sun8i-h3-musb&amp;quot;;&lt;br /&gt;
                        reg = &amp;lt;0x1c19000 0x400&amp;gt;;&lt;br /&gt;
                        clocks = &amp;lt;0x03 0x1d&amp;gt;;&lt;br /&gt;
                        resets = &amp;lt;0x03 0x11&amp;gt;;&lt;br /&gt;
                        interrupts = &amp;lt;0x00 0x47 0x04&amp;gt;;&lt;br /&gt;
                        interrupt-names = &amp;quot;mc&amp;quot;;&lt;br /&gt;
                        phys = &amp;lt;0x0e 0x00&amp;gt;;&lt;br /&gt;
                        phy-names = &amp;quot;usb&amp;quot;;&lt;br /&gt;
                        extcon = &amp;lt;0x0e 0x00&amp;gt;;&lt;br /&gt;
                        status = &amp;quot;okay&amp;quot;;&lt;br /&gt;
                        dr_mode = &amp;quot;otg&amp;quot;;&lt;br /&gt;
                        phandle = &amp;lt;0x2c&amp;gt;;&lt;br /&gt;
                };&lt;br /&gt;
                &lt;br /&gt;
                -----&lt;br /&gt;
&lt;br /&gt;
2. Load necessary kernel modules. ''You can skip this step if you use Armbian OS because necessary modules are already loaded by default'' (Detailed instructions for sunxi and Ethernet gadget: https://linux-sunxi.org/USB_Gadget/Ethernet)&lt;br /&gt;
 modprobe sunxi&lt;br /&gt;
 modprobe configfs&lt;br /&gt;
 modprobe libcomposite&lt;br /&gt;
 modprobe u_ether&lt;br /&gt;
 modprobe usb_f_rndis&lt;br /&gt;
&lt;br /&gt;
3. Add sunxi and g_ether to /etc/modules to get them to load on startup&lt;br /&gt;
 /etc/modules:&lt;br /&gt;
 sunxi&lt;br /&gt;
 g_ether&lt;br /&gt;
&lt;br /&gt;
4. Configure the g_ether device to start with a stable MAC address&lt;br /&gt;
 /etc/modprobe.d/g_ether.conf:&lt;br /&gt;
 options g_ether host_addr=f6:11:fd:ed:ec:6e&lt;br /&gt;
&lt;br /&gt;
5. Set a static IP address for usb0 on startup with network manager&lt;br /&gt;
 /etc/network/interfaces:&lt;br /&gt;
   auto usb0&lt;br /&gt;
   iface usb0 inet static&lt;br /&gt;
       address 192.168.10.2&lt;br /&gt;
       netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
6. Boot the PineCube plugging it into a computer&lt;br /&gt;
7. Configure the USB Ethernet device on the computer to be in the same subnet as the PineCube&lt;br /&gt;
: Sample setting:&lt;br /&gt;
 network setting: Manual&lt;br /&gt;
 address: 192.168.10.5&lt;br /&gt;
 netmask: 255.255.255.0&lt;br /&gt;
 gateway: 192.168.10.2&lt;br /&gt;
8. Done. ''You can use above methods to stream video through this USB Ethernet connection. Bandwidth and response time is much faster compared to usual network methods''&lt;br /&gt;
&lt;br /&gt;
== USB as a Webcam (UVC) gadget (Work In Progress) ==&lt;br /&gt;
&lt;br /&gt;
Goal: Make PineCube behave almost as same as like normal Webcam. When you connect PineCube to a computer it will be shown as a webcam device. No need for an additional set up you can use it straight after plugging the PineCube to a computer. ''USB-A port is for data transfer between PineCube and computer/phone. Micro-USB port is for power.''&lt;br /&gt;
&lt;br /&gt;
Action Plan (by Newton688):&lt;br /&gt;
 -Attempt to load the uvc_gadget (usb_f_uvc) or g_webcam&lt;br /&gt;
 -Look at this project to see if it can bridge UVC gadget output with the v4l from the OV5650 camera sensor&lt;br /&gt;
  https://github.com/wlhe/uvc-gadget&lt;br /&gt;
&lt;br /&gt;
Progress report so far (by Disctanger):&lt;br /&gt;
&lt;br /&gt;
Configfs method is going to be used to control OTG port.&lt;br /&gt;
&lt;br /&gt;
1. Additional patch to PineCube device tree disable ehci0 and ohci0, enabling usb_otg device instead and setting '''dr_mode''' to '''otg'''. If otg is not working for you, try setting '''dr_mode''' to '''peripheral'''. ''On Armbian there is no need for disabling ehci0 and ohci0. Device tree can be edited via armbian-config tool on Armbian OS. (armbian-config -&amp;gt; System -&amp;gt; DTC)''&lt;br /&gt;
: sample DTC on Armbian:&lt;br /&gt;
                -----&lt;br /&gt;
                &lt;br /&gt;
                usb@1c19000 {&lt;br /&gt;
                        compatible = &amp;quot;allwinner,sun8i-h3-musb&amp;quot;;&lt;br /&gt;
                        reg = &amp;lt;0x1c19000 0x400&amp;gt;;&lt;br /&gt;
                        clocks = &amp;lt;0x03 0x1d&amp;gt;;&lt;br /&gt;
                        resets = &amp;lt;0x03 0x11&amp;gt;;&lt;br /&gt;
                        interrupts = &amp;lt;0x00 0x47 0x04&amp;gt;;&lt;br /&gt;
                        interrupt-names = &amp;quot;mc&amp;quot;;&lt;br /&gt;
                        phys = &amp;lt;0x0e 0x00&amp;gt;;&lt;br /&gt;
                        phy-names = &amp;quot;usb&amp;quot;;&lt;br /&gt;
                        extcon = &amp;lt;0x0e 0x00&amp;gt;;&lt;br /&gt;
                        status = &amp;quot;okay&amp;quot;;&lt;br /&gt;
                        dr_mode = &amp;quot;otg&amp;quot;;&lt;br /&gt;
                        phandle = &amp;lt;0x2c&amp;gt;;&lt;br /&gt;
                };&lt;br /&gt;
                &lt;br /&gt;
                -----&lt;br /&gt;
&lt;br /&gt;
2. Load necessary kernel modules.&lt;br /&gt;
 modprobe sunxi&lt;br /&gt;
 modprobe configfs&lt;br /&gt;
 modprobe libcomposite&lt;br /&gt;
&lt;br /&gt;
3. Set up camera so that it would capture images in YUYV format (Currently only supported format in UVC gadget). You can adjust resolutions but have to adjust Configfs set up step as well.&lt;br /&gt;
 media-ctl --set-v4l2 '&amp;quot;ov5640 1-003c&amp;quot;:0[fmt:YUYV8_2X8/640x480@1/30]'&lt;br /&gt;
&lt;br /&gt;
4. Clone UVC gadget repo for raspberry pi to your PineCube&lt;br /&gt;
 git clone https://github.com/peterbay/uvc-gadget.git&lt;br /&gt;
 cd uvc_gadget&lt;br /&gt;
&lt;br /&gt;
5. Comment out 1182~1185 lines of `uvc-gadget.c` file:&lt;br /&gt;
 //    if (!uvc_shutdown_requested &amp;amp;&amp;amp; ((uvc_dev.dqbuf_count + 1) &amp;gt;= uvc_dev.qbuf_count)) {&lt;br /&gt;
 //        return;&lt;br /&gt;
 //    }&lt;br /&gt;
&lt;br /&gt;
6. Build the source code inside PineCube using make command. It takes only few seconds to build the code.&lt;br /&gt;
 make&lt;br /&gt;
 gcc -W -Wall -g   -c -o uvc-gadget.o uvc-gadget.c&lt;br /&gt;
 gcc -g -o uvc-gadget uvc-gadget.o&lt;br /&gt;
&lt;br /&gt;
7. Set up configfs (multi-gadget):&lt;br /&gt;
&lt;br /&gt;
You can have the following script as a bash script as well.&lt;br /&gt;
&lt;br /&gt;
  GADGET_PATH=/sys/kernel/config/usb_gadget/pinecube&lt;br /&gt;
  &lt;br /&gt;
  mkdir $GADGET_PATH&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  echo 0x1d6b &amp;gt; $GADGET_PATH/idVendor&lt;br /&gt;
  echo 0x0104 &amp;gt; $GADGET_PATH/idProduct&lt;br /&gt;
  echo 0x0100 &amp;gt; $GADGET_PATH/bcdDevice&lt;br /&gt;
  echo 0x0200 &amp;gt; $GADGET_PATH/bcdUSB&lt;br /&gt;
  &lt;br /&gt;
  echo 0xEF &amp;gt; $GADGET_PATH/bDeviceClass&lt;br /&gt;
  echo 0x02 &amp;gt; $GADGET_PATH/bDeviceSubClass&lt;br /&gt;
  echo 0x01 &amp;gt; $GADGET_PATH/bDeviceProtocol&lt;br /&gt;
  &lt;br /&gt;
  mkdir $GADGET_PATH/strings/0x409&lt;br /&gt;
  echo 100000000d2386db &amp;gt; $GADGET_PATH/strings/0x409/serialnumber&lt;br /&gt;
  echo &amp;quot;Pine64&amp;quot; &amp;gt; $GADGET_PATH/strings/0x409/manufacturer&lt;br /&gt;
  echo &amp;quot;PineCube Webcam&amp;quot; &amp;gt; $GADGET_PATH/strings/0x409/product&lt;br /&gt;
  mkdir $GADGET_PATH/configs/c.1&lt;br /&gt;
  mkdir $GADGET_PATH/configs/c.1/strings/0x409&lt;br /&gt;
  echo 500 &amp;gt; $GADGET_PATH/configs/c.1/MaxPower&lt;br /&gt;
  echo &amp;quot;UVC&amp;quot; &amp;gt; $GADGET_PATH/configs/c.1/strings/0x409/configuration&lt;br /&gt;
  &lt;br /&gt;
  mkdir $GADGET_PATH/functions/uvc.usb0&lt;br /&gt;
  mkdir $GADGET_PATH/functions/acm.usb0&lt;br /&gt;
  echo 512 &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming_maxpacket&lt;br /&gt;
  # cat &amp;lt;&amp;lt;EOF $GADGET_PATH/functions/uvc.usb0/control/processing/default/bmControls&lt;br /&gt;
  # 0&lt;br /&gt;
  # 0&lt;br /&gt;
  # EOF&lt;br /&gt;
  &lt;br /&gt;
  mkdir -p $GADGET_PATH/functions/uvc.usb0/control/header/h&lt;br /&gt;
  ln -s $GADGET_PATH/functions/uvc.usb0/control/header/h $GADGET_PATH/functions/uvc.usb0/control/class/fs/h&lt;br /&gt;
  # ln -s $GADGET_PATH/functions/uvc.usb0/control/header/h $GADGET_PATH/functions/uvc.usb0/control/class/hs/h&lt;br /&gt;
  # ln -s $GADGET_PATH/functions/uvc.usb0/control/header/h $GADGET_PATH/functions/uvc.usb0/control/class/ss/h&lt;br /&gt;
  &lt;br /&gt;
  config_frame () {&lt;br /&gt;
      FORMAT=$1&lt;br /&gt;
      NAME=$2&lt;br /&gt;
    WIDTH=$3&lt;br /&gt;
    HEIGHT=$4&lt;br /&gt;
  &lt;br /&gt;
      framedir=$GADGET_PATH/functions/uvc.usb0/streaming/$FORMAT/$NAME/${HEIGHT}p&lt;br /&gt;
  &lt;br /&gt;
      mkdir -p $framedir&lt;br /&gt;
  &lt;br /&gt;
      echo $WIDTH &amp;gt; $framedir/wWidth&lt;br /&gt;
      echo $HEIGHT &amp;gt; $framedir/wHeight&lt;br /&gt;
      echo 333333 &amp;gt; $framedir/dwDefaultFrameInterval&lt;br /&gt;
      echo $(($WIDTH * $HEIGHT * 80)) &amp;gt; $framedir/dwMinBitRate&lt;br /&gt;
      echo $(($WIDTH * $HEIGHT * 160)) &amp;gt; $framedir/dwMaxBitRate&lt;br /&gt;
      echo $(($WIDTH * $HEIGHT * 2)) &amp;gt; $framedir/dwMaxVideoFrameBufferSize&lt;br /&gt;
      cat &amp;lt;&amp;lt;EOF &amp;gt; $framedir/dwFrameInterval&lt;br /&gt;
  333333&lt;br /&gt;
  400000&lt;br /&gt;
  666666&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  config_frame mjpeg m 640 360&lt;br /&gt;
  config_frame mjpeg m 640 480&lt;br /&gt;
  config_frame mjpeg m 800 600&lt;br /&gt;
  config_frame mjpeg m 1024 768&lt;br /&gt;
  config_frame mjpeg m 1280 720&lt;br /&gt;
  config_frame mjpeg m 1280 960&lt;br /&gt;
  config_frame mjpeg m 1440 1080&lt;br /&gt;
  config_frame mjpeg m 1536 864&lt;br /&gt;
  config_frame mjpeg m 1600 900&lt;br /&gt;
  config_frame mjpeg m 1600 1200&lt;br /&gt;
  config_frame mjpeg m 1920 1080&lt;br /&gt;
  &lt;br /&gt;
  SMALL_WIDTH=480p&lt;br /&gt;
  &lt;br /&gt;
  mkdir -p $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH&lt;br /&gt;
  &lt;br /&gt;
  echo 640 &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/wWidth&lt;br /&gt;
  echo 480 &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/wHeight&lt;br /&gt;
  echo 333333 &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/dwDefaultFrameInterval&lt;br /&gt;
  echo $((640 * 480 * 80)) &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/dwMinBitRate&lt;br /&gt;
  echo $((640 * 480 * 160)) &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/dwMaxBitRate&lt;br /&gt;
  echo $((640 * 480 * 2)) &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/dwMaxVideoFrameBufferSize&lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; $GADGET_PATH/functions/uvc.usb0/streaming/uncompressed/u/$SMALL_WIDTH/dwFrameInterval&lt;br /&gt;
  333333&lt;br /&gt;
  400000&lt;br /&gt;
  666666&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  mkdir $GADGET_PATH/functions/uvc.usb0/streaming/header/h&lt;br /&gt;
  cd $GADGET_PATH/functions/uvc.usb0/streaming/header/h&lt;br /&gt;
  # ln -s ../../mjpeg/m&lt;br /&gt;
  ln -s ../../uncompressed/u&lt;br /&gt;
  cd ../../class/fs&lt;br /&gt;
  ln -s ../../header/h&lt;br /&gt;
  cd ../../class/hs&lt;br /&gt;
  ln -s ../../header/h&lt;br /&gt;
  cd ../../../../..&lt;br /&gt;
  &lt;br /&gt;
  ln -s $GADGET_PATH/functions/uvc.usb0 $GADGET_PATH/configs/c.1/uvc.usb0&lt;br /&gt;
  ln -s $GADGET_PATH/functions/acm.usb0 $GADGET_PATH/configs/c.1/acm.usb0&lt;br /&gt;
  udevadm settle -t 5 || :&lt;br /&gt;
  ls /sys/class/udc &amp;gt; $GADGET_PATH/UDC&lt;br /&gt;
&lt;br /&gt;
If above script goes without issues you should be able to see one more additional `/dev/video*` device.&lt;br /&gt;
&lt;br /&gt;
8. run uvc-gadget&lt;br /&gt;
&lt;br /&gt;
UVC Gadget software links camera of PineCube and UVC gadget (OTG port).&lt;br /&gt;
&lt;br /&gt;
&amp;quot;-v&amp;quot; is for video input device - PineCube Camera, &amp;quot;-u&amp;quot; is for output video device UVC device or OTG port, -x shows FPS.&lt;br /&gt;
 ./uvc-gadget -u /dev/video1 -v /dev/video0 -x&lt;br /&gt;
&lt;br /&gt;
9. Plug the PineCube to your laptop or pc and check if you can see PineCube Webcam.&lt;br /&gt;
&lt;br /&gt;
Known issues:&lt;br /&gt;
&lt;br /&gt;
# Low Frame rate(3FPS~5FPS). That is because:&lt;br /&gt;
## At the time of writing this section, `streaming_maxpacket` value cannot be set to max value (2048 bytes.) It can be set only to 512 bytes. If `streaming_maxpacket` is set to max (2048) value, UDC cannot be turned on with `Invalid Value` error.&lt;br /&gt;
## YUYV (uncompressed) file format is being used to stream the images. Uncompressed images take a lot of USB bandwidth compared to compressed. We can stream more frames, if MJPEG or even H254 (compressed images) would be used. I will be investigating further on how to stream more frames through USB port.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PineCube]]&lt;/div&gt;</summary>
		<author><name>Fxc</name></author>
	</entry>
</feed>