Giter VIP home page Giter VIP logo

wsl2_linux_kernel_usbcam_enable_conf's Introduction

wsl2_linux_kernel_usbcam_enable_conf

Configuration file to build the kernel to access the USB camera connected to the host PC using USBIP from inside the WSL2. Windows 11 + WSL2 + USB Camera + Serial

1. Environment

  • Windows 11 (OS build: 22000.194)
  • Windows 11 (OS build: 22000.469)
  • Windows 11 (OS build: 22000.918)
  • Windows 10 (OS build: 19043.1237+)
  • Windows 10 (OS build: 19045.2846)
  • WSL2
  • [Mandatory] WSL2 Ubuntu 20.04 or 22.04
  • https://github.com/microsoft/WSL2-Linux-Kernel

2. Usage

yth06
On WSL2.

$ uname -r -v
5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023

On Windows Terminal.

C:\> wsl --update
Checking for updates...
Downloading update...
Installing update...
This change will take effect the next time you reboot WSL. To force a reboot, run 'wsl --shutdown'.
Kernel version: 5.10.102.1

C:\> wsl --shutdown
# Ubuntu 20.04
C:\> wsl --install -d Ubuntu-20.04

# Ubuntu 22.04
C:\> wsl --install -d Ubuntu-22.04

On WSL2. The <windows username> part should be replaced with the user name you are logging on to the Windows host PC. There are two corrections.

$ uname -r -v
5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023

$ sudo apt update && sudo apt upgrade -y
$ sudo apt install -y \
    build-essential flex bison \
    libgtk-3-dev libelf-dev libncurses-dev autoconf \
    libudev-dev libtool zip unzip v4l-utils libssl-dev \
    python3-pip cmake git iputils-ping net-tools dwarves \
    guvcview python-is-python3 bc

$ cd /usr/src
$ TAGVERNUM=5.15.90.1 \
  && TAGVER=linux-msft-wsl-${TAGVERNUM} \
  && WINUSERNAME=<windows username>
$ sudo git clone --depth 1 -b ${TAGVER} \
    https://github.com/microsoft/WSL2-Linux-Kernel.git \
    ${TAGVERNUM}-microsoft-standard \
  && cd ${TAGVERNUM}-microsoft-standard

$ sudo wget -O .config https://github.com/PINTO0309/wsl2_linux_kernel_usbcam_enable_conf/raw/main/${TAGVER}/config-${WSL_DISTRO_NAME} \
  && sudo chmod 777 .config \
  && sudo make clean

$ sudo make -j$(nproc) KCONFIG_CONFIG=.config \
  && sudo make modules_install -j$(nproc) \
  && sudo make install -j$(nproc)

$ sudo rm /mnt/c/Users/${WINUSERNAME}/vmlinux
$ sudo cp /usr/src/${TAGVERNUM}-microsoft-standard/vmlinux /mnt/c/Users/${WINUSERNAME}/

w3vld 49p0d

$ cat << 'EOT' > /mnt/c/Users/${WINUSERNAME}/.wslconfig
[wsl2]
kernel=C:\\Users\\<windows username>\\vmlinux
EOT

fyh68
On Windows Terminal.

C:\> wsl --shutdown

On WSL2. If the built kernel has been loaded successfully, you will see + at the end of the kernel name. #n is the number of times the kernel was built.

$ uname -r -v
5.15.90.1-microsoft-standard-WSL2+ #1 SMP Sun Apr 16 18:14:34 JST 2023

3. Note

3-1. New WSL Linux kernel configuration changes

From here, select the TAG for the target kernel version.

https://github.com/microsoft/WSL2-Linux-Kernel/tags

On WSL2.

$ cd /usr/src
$ TAGVERNUM=x.x.x.x
$ TAGVER=linux-msft-wsl-${TAGVERNUM}
$ sudo git clone \
    -b ${TAGVER} \
    https://github.com/microsoft/WSL2-Linux-Kernel.git \
    ${TAGVERNUM}-microsoft-standard \
  && cd ${TAGVERNUM}-microsoft-standard
$ sudo cp /proc/config.gz config.gz \
  && sudo gunzip config.gz \
  && sudo mv config .config

$ sudo make menuconfig

# After completing all necessary configurations,
# "save" will save the modified `.config` file.

3-2. Troubleshooting

If you receive the following error, please follow the additional steps: USB bandwidth issues may cause the information exchange with the camera to time out.

  • Error Message
[ WARN:0] global /tmp/pip-req-build-xw6jtoah/opencv/modules/videoio/src/cap_v4l.cpp (1001) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.

Try one or both of the following.

  • Try1. Additional command
$ sudo apt install v4l-utils \
  && sudo chmod 777 /dev/video0 \
  && v4l2-ctl -d /dev/video0 --all

Driver Info:
	Driver name      : uvcvideo
	Card type        : papalook FHD Camera: papalook F
	Bus info         : usb-0000:00:14.0-11.1
	Driver version   : 5.11.22
	Capabilities     : 0x84a00001
		Video Capture
		Metadata Capture
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04200001
		Video Capture
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : uvcvideo
	Model            : papalook FHD Camera: papalook F
	Serial           : 
	Bus info         : usb-0000:00:14.0-11.1
	Media version    : 5.11.22
	Hardware revision: 0x00000100 (256)
	Driver version   : 5.11.22
Interface Info:
	ID               : 0x03000002
	Type             : V4L Video
Entity Info:
	ID               : 0x00000001 (1)
	Name             : papalook FHD Camera: papalook F
	Function         : V4L2 I/O
	Flags         : default
	Pad 0x01000007   : 0: Sink
	  Link 0x02000010: from remote pad 0x100000a of entity 'Extension 3': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
	Width/Height      : 1280/720
	Pixel Format      : 'MJPG' (Motion-JPEG)
	Field             : None
	Bytes per Line    : 0
	Size Image        : 1843200
	Colorspace        : sRGB
	Transfer Function : Rec. 709
	YCbCr/HSV Encoding: ITU-R 601
	Quantization      : Default (maps to Full Range)
	Flags             : 
Crop Capability Video Capture:
	Bounds      : Left 0, Top 0, Width 1280, Height 720
	Default     : Left 0, Top 0, Width 1280, Height 720
	Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 1280, Height 720, Flags: 
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1280, Height 720, Flags: 


$ sudo apt install v4l-utils \
  && sudo chmod 777 /dev/video2 \
  && v4l2-ctl -d /dev/video2 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'GREY' (8-bit Greyscale)
                Size: Discrete 256x144
                        Interval: Discrete 0.003s (300.000 fps)
                        Interval: Discrete 0.011s (90.000 fps)
                Size: Discrete 424x240
                        Interval: Discrete 0.011s (90.000 fps)
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.167s (6.000 fps)
    :
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.167s (6.000 fps)
        [2]: 'GREY' (8-bit Greyscale)
                Size: Discrete 256x144
                        Interval: Discrete 0.003s (300.000 fps)
                        Interval: Discrete 0.011s (90.000 fps)
                Size: Discrete 424x240
                        Interval: Discrete 0.011s (90.000 fps)

Check the WIDTH and HEIGHT of the standard resolution displayed, and correct the input resolution listed in usbcam_test.py.

e.g.

From:

frame = cv2.resize(frame, (640, 480))

To:

frame = cv2.resize(frame, (1280, 720))

Run it again.

$ sudo chmod 777 /dev/video* && python ${HOME}/usbcam_test.py

wsl2_linux_kernel_usbcam_enable_conf's People

Contributors

pinto0309 avatar nobuotsukamoto avatar mitukou1109 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.