Difference between revisions of "PineCube"

Jump to navigation Jump to search
(Undo revision 13145 by Disctanger (talk))
Tag: Undo
m (→‎PineCube as a webcam: Few additional comments for "PineCube as a webcam" section)
Line 494: Line 494:
[[File:Pinecube_webcam1.jpg|400px]] [[File:Pinecube_webcam2.jpg|400px]]
[[File:Pinecube_webcam1.jpg|400px]] [[File:Pinecube_webcam2.jpg|400px]]


TBD:
==== USB as an Ethernet gadget: ====
-Kernel patches applied from here (perhaps already available in NixOS): https://github.com/danielfullmer/pinecube-nixos/blob/master/kernel/Pine64-PineCube-support.patch
 
-Additional patch to pinecube device tree disable ehci0 and ohci0, enabling usb_otg device instead and setting dr_mode to otg
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.
-Instructions for sunxi and ethernet gadget: https://linux-sunxi.org/USB_Gadget/Ethernet
 
  -Add sunxi and g_ether to /etc/modules to get them to load on startup
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 -> System -> DTC)''
  -Configure the g_ether device to start with a stable MAC address
: sample DTC on Armbian:
  /etc/modprobe.d/g_ether.conf:
                -----
  options g_ether host_addr=f6:11:fd:ed:ec:6e
               
-Set a static IP address for usb0 on startup with network manager (/etc/network/interfaces)
                usb@1c19000 {
                        compatible = "allwinner,sun8i-h3-musb";
                        reg = <0x1c19000 0x400>;
                        clocks = <0x03 0x1d>;
                        resets = <0x03 0x11>;
                        interrupts = <0x00 0x47 0x04>;
                        interrupt-names = "mc";
                        phys = <0x0e 0x00>;
                        phy-names = "usb";
                        extcon = <0x0e 0x00>;
                        status = "okay";
                        dr_mode = "otg";
                        phandle = <0x2c>;
                };
               
                -----
 
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)
modprobe sunxi
modprobe configfs
  modprobe libcomposite
modprobe u_ether
modprobe usb_f_rndis
 
3. Add sunxi and g_ether to /etc/modules to get them to load on startup
  /etc/modules:
sunxi
g_ether
 
4. Configure the g_ether device to start with a stable MAC address
/etc/modprobe.d/g_ether.conf:
options g_ether host_addr=f6:11:fd:ed:ec:6e
 
5. Set a static IP address for usb0 on startup with network manager
/etc/network/interfaces:
   auto usb0
   auto usb0
   iface usb0 inet static
   iface usb0 inet static
       address 192.168.10.2
       address 192.168.10.2
       netmask 255.255.255.0
       netmask 255.255.255.0
-Boot the pinecube plugging it into a computer
-Configure the USB ethernet device on the computer to be in the same subnet as the pinecube


6. Boot the PineCube plugging it into a computer
7. Configure the USB ethernet device on the computer to be in the same subnet as the pinecube
: Sample setting:
network setting: Manual
address: 192.168.10.5
netmask: 255.255.255.0
gateway: 192.168.10.2
8. Done. ''You can use above methods to stream video through this USB ethernet connection. Bandwith and response time is much faster compared to usual network methods''
==== USB as a Webcam (UVC) gadget (Work In Progress): ====
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.''
Action Plan (by Newton688):
  -Attempt to load the uvc_gadget (usb_f_uvc) or g_webcam
  -Attempt to load the uvc_gadget (usb_f_uvc) or g_webcam
  -Look at this project to see if it can bridge UVC gadget output with the v4l from the OV5650 camera sensor
  -Look at this project to see if it can bridge UVC gadget output with the v4l from the OV5650 camera sensor
   https://github.com/wlhe/uvc-gadget
   https://github.com/wlhe/uvc-gadget
Progress report so far (by Disctanger):
Unfortunately, could not get UVC gadget working on the device so far. USB Gadget wiki page (https://linux-sunxi.org/USB_Gadget) also missing UVC section.
Getting almost the same error in both (g_webcam and configfs) methods at the final stage of enabling UVC gadget:
g_webcam error:
```
[ 1741.996382] g_webcam gadget: uvc: uvc_function_bind()
[ 1741.996423] g_webcam gadget: uvc: Unable to allocate streaming EP
[ 1741.996468] udc musb-hdrc.2.auto: failed to start g_webcam: -22
```
configfs error:
```
[ 2035.636565] configfs-gadget gadget: uvc: uvc_function_bind()
[ 2035.636608] configfs-gadget gadget: uvc: Unable to allocate streaming EP
[ 2035.636647] udc musb-hdrc.2.auto: failed to start g1: -22
```


== PineCube as a recorder for loud noises ==
== PineCube as a recorder for loud noises ==