{"id":25513209,"url":"https://github.com/manishholla/enable-socketcan-functionality-in-wsl","last_synced_at":"2025-11-30T05:30:14.008Z","repository":{"id":271004941,"uuid":"912132035","full_name":"manishholla/enable-socketcan-functionality-in-wsl","owner":"manishholla","description":"A brief walkthrough to using compiling custom kernel with SocketCAN functionality enabled and using it on WSL (WSL2 to be specific).","archived":false,"fork":false,"pushed_at":"2025-02-10T19:02:33.000Z","size":13732,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T19:43:01.500Z","etag":null,"topics":["custom-kernel","enable-socketcan-functionality-in-wsl","linux","socketcan","ubuntu","wsl","wsl2"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manishholla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T17:34:13.000Z","updated_at":"2025-02-10T19:02:37.000Z","dependencies_parsed_at":"2025-02-10T19:35:38.635Z","dependency_job_id":"31c575b5-677e-4f37-a99c-4550af59ede0","html_url":"https://github.com/manishholla/enable-socketcan-functionality-in-wsl","commit_stats":null,"previous_names":["manishholla/enable-socketcan-functionality-in-wsl2"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manishholla%2Fenable-socketcan-functionality-in-wsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manishholla%2Fenable-socketcan-functionality-in-wsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manishholla%2Fenable-socketcan-functionality-in-wsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manishholla%2Fenable-socketcan-functionality-in-wsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manishholla","download_url":"https://codeload.github.com/manishholla/enable-socketcan-functionality-in-wsl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239644121,"owners_count":19673582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-kernel","enable-socketcan-functionality-in-wsl","linux","socketcan","ubuntu","wsl","wsl2"],"created_at":"2025-02-19T11:18:50.564Z","updated_at":"2025-11-30T05:30:13.720Z","avatar_url":"https://github.com/manishholla.png","language":null,"readme":"# Enable SocketCAN functionality in WSL\n\nThis tutorial will give a brief walkthrough to enable SocketCAN functionality in WSL. To be specific I am using WSL2 with Ubuntu image and this is the system details:\n\nOS: Ubuntu 24.04.1 LTS on Windows 10 x86_64\n\nKernel: 5.15.146.1-microsoft-standard-WSL2+\n\nCPU: AMD Ryzen 7 5800H with Radeon Graphics (16) @ 3.193GHz\n\nGPU: 219e:00:00.0 Microsoft Corporation Basic Render Driver\n\nSocketCAN does not come shipped with the kernel by default. We need to compile kernel from source in order to enable the same. For that the steps are:\n\n- Update the apt repositories and upgrade all the required packages:\n\n\t\tsudo apt-get update -y\n\t\t\n\t\tsudo apt-get upgrade -y\n\n- Clone the MS WSL2 repository by entering the following URL. In this case I am using 5.15.146.1 version as I was successful in enabling SocketCAN with this version:\n\n\t\tgit clone https://github.com/microsoft/WSL2-Linux-Kernel.git --depth=1 -b linux-msft-wsl-5.15.146\n\n- Install all the required components and packages to build the kernel:\n\n\t\tsudo apt update \u0026\u0026 sudo apt install build-essential flex bison libssl-dev libelf-dev libncurses5-dev\n\n- Clean make and mrproper:\n\n  \t\tsudo make clean\n  \n  \t\tsudo make mrproper\n\n- Configure the kernel by entering into the folder and using menuconfig:\n\n\t\tcd WSL2-Linux-Kernel\n\t\t\n\t\tmake menuconfig KCONFIG_CONFIG=Microsoft/config-wsl\n\n- Enable CANBus functionalityt from the menuconfig:\n\n\t``Networking Support -\u003e CAN BUS subsystem support -\u003e change all to \"M\" -\u003e CAN Device Driver -\u003e change first 4 to \"M\" ``\n\n- Save the configuration and exit\n\n- Compile the new kernel: \n\n\t\tmake -j$(nproc) KCONFIG_CONFIG=Microsoft/config-wsl\n\t\t\n\t\tsudo make modules_install headers_install\n\n- New bzImage will be created. We need to copy it from WSL storage to User storage. Remember to replace USER with windows username in all steps:\n\n\t\tmkdir -p /mnt/c/Users/USER/.wsl-kernels/\n\t\t\n\t\tcp arch/x86/boot/bzImage /mnt/c/Users/USER/.wsl-kernels/\n\n- Now create a .wslconfig file with the content:\n\n\t\t[wsl2] \n\t\tkernel=C:\\\\Users\\\\USER\\\\.wsl-kernels\\\\bzImage\n\n- Power off the WSL instance and shut it down:\n\n\t\tsudo poweroff\n\t\t\n\t\twsl --shutdown\n\t\t\n\t\twsl --list\n\n- Start the instance again by typing \"wsl\" in powershell\n\n- Verify that the instance is using the new kernel by typing \n\n\t\tuname -r\n\n- Install CAN-Utils:\n\n\t\tsudo apt update\n\t\t\n\t\tsudo apt install can-utils\n\n- Initialize the CAN-Utils components:\n\n\t\tsudo modprobe can\n\t\t\n\t\tsudo modprobe vcan\n\t\t\n\t\tsudo modprobe can-raw\n\n\nFollowing the above procedure, all CANBus interfaces will be added. You can verify the same using \"sudo dmesg\" command and searching for CAN.\n\nTo add vcan interface, type:\n\n\t\tsudo ip link add dev vcan0 type vcan\n\t\t\n  \t\tsudo ip link set vcan0 up type vcan\n\nYou can test can-utils functionality:\n\n   terminal1: ``cangen vcan0 -v -v``\n\n   terminal2: ``candump vcan0``\n\n\nFor convenience, I have also included the compiled kernel binary (bzImage) in the release section. However, I would strongly recommend that you compile the kernel from the source code.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanishholla%2Fenable-socketcan-functionality-in-wsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanishholla%2Fenable-socketcan-functionality-in-wsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanishholla%2Fenable-socketcan-functionality-in-wsl/lists"}