-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SocketCAN support #5533
Comments
I gather this is CONFIG_CAN_RAW et al. |
Yes, I think this is the minimum useful set: Would also be good to get support for some CAN USB adapters. I am using CONFIG_CAN_PEAK_USB |
In the interim between now and when those configs hypothetically became enabled in a stock release, you can try rolling your own kernel and see if it is viable.
USB passthrough at the kernel level would be another kettle of fish. |
Oh cool, I didn't know you could run your own custom kernel with WSL 2! |
You can also compile just the modules and |
For anyone trying this, these were my steps:
So far so good, however, candump does not cooperate: This is an interesting effect:
Update: building your own kernel for WSL works! You can enable |
I opened a proposal here: https://github.com/microsoft/WSL2-Linux-Kernel/pull/242/files |
Did not work for my current kernel (
but unfortunately, I did not get it installed with your steps, still getting: $ modprobe vcan
modprobe: FATAL: Module vcan not found in directory /lib/modules/5.4.72-microsoft-standard-WSL2 maybe I have other issues with my install? $ ll /lib/modules
total 44
drwxr-xr-x 11 root root 4096 Mar 20 09:32 ./
drwxr-xr-x 21 root root 4096 Dec 23 21:53 ../
drwxr-xr-x 2 root root 4096 Sep 4 2020 4.15.0-106-generic/
drwxr-xr-x 2 root root 4096 Sep 4 2020 4.15.0-112-generic/
drwxr-xr-x 2 root root 4096 Sep 4 2020 4.15.0-115-generic/
drwxr-xr-x 2 root root 4096 Sep 28 08:36 4.15.0-117-generic/
drwxr-xr-x 2 root root 4096 Sep 28 11:58 4.15.0-118-generic/
drwxr-xr-x 2 root root 4096 Nov 24 23:43 4.15.0-124-generic/
drwxr-xr-x 3 root root 4096 Mar 9 22:24 4.15.0-136-generic/
drwxr-xr-x 3 root root 4096 Mar 20 09:14 4.15.0-139-generic/
drwxr-xr-x 3 root root 4096 Mar 20 09:35 5.4.72-microsoft-standard-WSL2+/ |
The problem is in the
I do not know what to compare it against, but I guess there are differences in the binary layout between the tagged and released version. |
I should probably walk back the "sometimes a safer approach" comment in the sense it does introduce the potential for a symbol version conflict. There was no conflict last I tried checking out the correct |
I left the modules as
|
@microsoft can we get this as a default feature? |
+1, my organization also develops embedded Linux projects and would benefit greatly from this feature as a default! |
+1, my organization also develops embedded Linux projects |
+1, my organization also develops embedded Linux projects and work from WSL2 when developing. I Would love this. |
Thanks for all the information! $ candump vcan0
socket: Address family not supported by protocol What am I missing? |
Please add can support ! |
Hi Deakon997,
This way you should be able to load vcan without any complaints. In addition to the whole thread:To end up with success, I had to recompile also the kernel itself and swap the stock WSL2 kernel with the newly compiled one to get rid of the following message:
So the additional steps to windelbouwman's guide are:
Then copy the kernel to Windows:
and finally restart your WSL:
This way I finally added SocketCAN support to WSL. |
@ak-aptiv 🥇
Thank you very much! That made my day! |
@jiayali-ms closed microsoft/WSL2-Linux-Kernel#242 indicating that pull requests are not accepted there, and to file issues here - but we can't issue a PR against a kernel config here? Per discussion on that PR - even though WSL2 has no hardware support, enabling the vcan (virtual CAN) support and its dependencies at a minimum allows for things such as: But these userspace solutions can't be used without kernel support for vcan at a minimum |
@Entropy512 VCAN support in WSL would be a great addition. |
+1 for default support for vcan in WSL2, would love to be able to locally develop/test on a virtual CAN network |
Oof, not having SocketCAN is kind of a deal breaker for me. |
If you're on Win10, you need to recompile the kernel anyway to support USB devices. Since the last discussion on this topic, much of the rationale for not supporting SocketCAN support (no support for external hardware) in the WSL2 kernel has become invalid: WSL2 now supports USB devices. CAN support should be enabled as part of this effort. (I'll be testing an EMS CPC-USB later today with a custom kernel) |
No SocketCAN => bye-bye Windows |
+1 I need socketCAN with usb2can too! |
A little update compared to my previous post: |
I try to add gs_usb can device kernel module and it works fine. |
CAN and docker is a whole other can of worms likely unrelated to WSL. https://github.com/wsovalle/docker-vxcan may be useful, I've been looking into it but haven't had an opportunity to actually try it out. |
@windelbouwman instruction worked perfectly, even got it to work with kvaser usb-device using wsl uspipd. |
Thanks for all the help. I got socketcan to work in WSL after recompiling the kernel. For any of you that need to access socketcan from the windows host (or the other way around), I made a simple gateway to do so. Run socketcand on the WSL side, and pycangw.py on Windows: I've found this setup to be particularly useful where a software in the loop simulation running in WSL requires (virtual) CAN bus connectivity with some software running in Windows. |
Thanks @windelbouwman for sharing those steps on #5533 (comment). Unfortunately, step 3,
It eventually leads to failures trying to load modules with On top of that, applying followup comments such as #5533 (comment) by @ak-aptiv ends up yielding more errors anyway:
Those modules should be compiled by default, @microsoft :/ |
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request. Thank you! |
My company is working on several embedded Linux projects and we would like to switch from running Ubuntu under VirtualBox to WSL. However, we need SocketCAN support along with the Virtual CAN (vcan) driver. Can you please add these to the WSL kernel?
The text was updated successfully, but these errors were encountered: