PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
eALduderino
Posts: 2
Joined: Thu 23. Mar 2023, 20:47

PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by eALduderino » Thu 23. Mar 2023, 21:40

Hi there,
should the Linux default drivers run in WSL2 Ubuntu 20.04 with Microsoft's custom Linux Kernel?
WSL2-Linux-Kernel-linux-msft-wsl-5.15.90.1
Also, should the proprietary driver package be buildable and installable in WSL2? So far I managed to build and install the custom Kernel and connect USB devices to WSL2 but I didn't manage to get my PCAN-USB to work in WSL since I couldn't initialize the default driver and/or install the proprietary one. I'd appreciate it if anyone could share some knowledge or point me in the right direction to get it to work.
When I tried to build the driver package the following errors occurred. Thanks for your help.

Code: Select all

eal@ealwsl2:~/drivers/peak-linux-driver-8.15.2$ make clean all
make[1]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/driver'
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected (expecting "then")
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected (expecting "then")
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: [: missing ]
/bin/sh: 1: Syntax error: end of file unexpected
rm -f src/*o src/*~ src/.*cmd *o *ko *~ .*cmd  pcan.mod.c Module.symvers modules.order .cache.mk
make[1]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/driver'
make[1]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/lib'
rm -f src/*~
rm -rf obj lib obj32 lib32
make[1]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/lib'
make[1]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/test'
rm -f src/*~ src/*.o *~ receivetest transmitest bitratetest filtertest pcanfdtst pcan-settings receivetest_posix transmitest_posix
make[1]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/test'
make[1]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic'

***
*** Processing 'pcanbasic' directory...
***
make[2]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/pcanbasic'

***
*** Cleaning PCANBasic library...
***
rm -f src/*~ out/*.o out/*.gcno *~ *.so.* *.so lib/*~ lib/*.so.* lib/*.so lib32/*~ lib32/*.so.* lib32/*.so out32/*.o out32/*.gcno
make[2]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/pcanbasic'

***
*** Processing 'pcaninfo' directory...
***
make[2]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/pcaninfo'

***
*** Cleaning pcaninfo...
***
rm -f src/*~ src/*.o ../pcanbasic/src/*~ ../pcanbasic/src/*.o *~ *.so.* *.so pcaninfo.1.3.1 pcaninfo
make[2]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/pcaninfo'

***
*** Processing 'examples' directory...
***
make[2]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples'

***
*** Processing examples 'console' directory...
***
make[3]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console'

***
*** Processing 'C' directory (console examples)...
***
make[4]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/c'

***
*** Cleaning PCANBasic C examples
rm -f src/*~ src/*.o *~ pcanwrite pcanread pcaneventread pcaneventwrite
make[4]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/c'

***
*** Processing 'NativeC++' directory (console examples)...
***
make[4]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++'

***
*** Cleaning PCANBasic C++ examples...
***
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/01_LookUpChannel'
rm -f *.o *~ ../LookUpChannel
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/01_LookUpChannel'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/02_GetSetParameter'
rm -f *.o *~ ../GetSetParameter
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/02_GetSetParameter'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/03_ManualRead'
rm -f *.o *~ ../ManualRead
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/03_ManualRead'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/04_ManualWrite'
rm -f *.o *~ ../ManualWrite
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/04_ManualWrite'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/05_TimerRead'
rm -f *.o *~ ../TimerRead
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/05_TimerRead'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/06_TimerWrite'
rm -f *.o *~ ../TimerWrite
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/06_TimerWrite'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/07_ThreadRead'
rm -f *.o *~ ../ThreadRead
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/07_ThreadRead'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/08_EventDrivenRead'
rm -f *.o *~ ../EventDrivenRead
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/08_EventDrivenRead'
make[5]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/09_TraceFiles'
rm -f *.o *~ ../TraceFiles
make[5]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++/09_TraceFiles'
make[4]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console/NativeC++'
make[3]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/console'

***
*** Processing examples 'gui' directory...
***
make[3]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/gui'

***
*** Processing 'python' directory (GUI examples)...
***
make[4]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/gui/python'
rm -f *.pyc
make[4]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/gui/python'
make[3]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples/gui'
make[2]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic/examples'
make[1]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/libpcanbasic'
make[1]: Entering directory '/home/eal/drivers/peak-linux-driver-8.15.2/driver'
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected (expecting "then")
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected (expecting "then")
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: [: missing ]
/bin/sh: 1: Syntax error: end of file unexpected
/bin/sh: 1: Syntax error: end of file unexpected
***
*** Making pcan driver in chardev mode
***
*** Host OS Release=Ubuntu v20.04
*** Host machine kernel version=5.15.90.1-microsoft-standard-WSL2
*** Driver kernel version=5.15.90.1-microsoft-standard-WSL2 (5.15.90)
/bin/sh: 1: Syntax error: Unterminated quoted string
make[1]: *** [Makefile:774: message] Error 2
make[1]: Leaving directory '/home/eal/drivers/peak-linux-driver-8.15.2/driver'
make: *** [Makefile:84: all] Error 2

G.Lang
Support
Support
Posts: 164
Joined: Wed 22. Sep 2010, 14:58

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by G.Lang » Fri 24. Mar 2023, 07:23

Windows Subsystem for Linux (WSL) is not a real fully working Linux system (it´s a virtualized Linux with special kernel) and therefore the PCAN-USB will not work. Please install a real Linux distribution and then the PCAN-USB will properly work.

eALduderino
Posts: 2
Joined: Thu 23. Mar 2023, 20:47

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by eALduderino » Fri 24. Mar 2023, 10:11

I was afraid this is the case. Thanks for your quick reply.

tim.rosenkrantz
Posts: 1
Joined: Wed 16. Aug 2023, 07:07

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by tim.rosenkrantz » Wed 16. Aug 2023, 07:15

The driver might not work but you can still use PCAN-USB with the built in kernel support via socketcan

I am using WSL2 (win10 , 22H2, 19045.3208) with a custom built kernel based on 5.15.90.1 where I have added CAN and USB support.
Then using usbipd to forward the usb to WSL2 hxxps://github.com/dorssel/usbipd-win

I configure the can0 interface with systemd and load can and can_raw modules at boot

/etc/systemd/network/80-can.network

Code: Select all

[Match]
Name=can0

[CAN]
BitRate=500000
SamplePoint=80%
FDNonISO=False
DataBitRate=2000000
DataSamplePoint=80%
FDMode=True
/etc/modules-load.d/can.conf

Code: Select all

can
can_raw

gsibley
Posts: 2
Joined: Wed 6. Dec 2023, 01:56

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by gsibley » Wed 6. Dec 2023, 02:08

Hi all,

Tim's suggestion seems to be a workable path to use PCAN-USB FD device under wsl, but I still don't see can0 showing up.

I setup usbipd, systemd and /etc/modules-load.d/can.conf as suggested. In wsl dmesg shows the driver being loaded when I activate the device from windows (with "usbipd wsl attach --busid=8-1"):

Code: Select all

[ 6517.793791] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3)
[ 6517.793825] vhci_hcd vhci_hcd.0: devid(524289) speed(3) speed_str(high-speed)
[ 6517.793851] vhci_hcd vhci_hcd.0: Device attached
[ 6518.160335] usb 1-1: new high-speed USB device number 3 using vhci_hcd
[ 6518.310224] usb 1-1: SetAddress Request (3) to port 0
[ 6518.343093] usb 1-1: New USB device found, idVendor=0c72, idProduct=0012, bcdDevice= 0.00
[ 6518.343122] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 6518.343124] usb 1-1: Product: PCAN-USB FD
[ 6518.343125] usb 1-1: Manufacturer: PEAK-System Technik GmbH
However this does not activate can0 and "ip -s -d link show type can" comes up blank. I was previously only able to get the can0 to show up if I compiled the pcan drivers with "netdev" option, and for now I'm using the driver from the kernel (make menuconfig etc). What step am I missing to get can0 to show up? Many thanks for your help.

G.Lang
Support
Support
Posts: 164
Joined: Wed 22. Sep 2010, 14:58

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by G.Lang » Wed 6. Dec 2023, 09:43

Hi,

maybe you don´t have uninstalled our PCAN driver correctly. Please go to the PCAN driver directory and type "sudo make uninstall" and reboot the linux system afterwards, then the normal kernel-integrated SocketCAN driver should be present. After the system was rebooted please check if the CAN driver is part of your Linux and also if the device is initialized.

linux_driver.png
linux_driver.png (102.63 KiB) Viewed 35312 times

Please note that WSL2 don´t support USB officially. To make USB work with the help of the "usbipd-win " project is not really supportable from PEAK.
Such a system may work or may not.

gsibley
Posts: 2
Joined: Wed 6. Dec 2023, 01:56

Re: PCAN-USB in Windows Subsystem for Linux WSL2, Ubuntu 20.04

Post by gsibley » Thu 7. Dec 2023, 00:18

Hi All,

I was able to get it working by compiling the 6.1 kernel from MS github. Roughly following the instructions here: hxxxs://learn.microsoft.com/en-us/community/content/wsl-user-msft-kernel-v6 and here: xxx.reddit.com/r/CarHacking/comments/ot3gjf/socketcancanutils_on_windows/.

I did this because Check #3 here xxx.peak-system.com/fileadmin/media/linux/index.htm indicated the device was only supported with Linux >= 6.0. (Check #1 and #2 passed)

Thanks!

(active links are Not allowed - see forum RULES - changed by Admin)

Post Reply