Created
July 28, 2021 20:55
-
-
Save charlie-x/96a92aaaa04346bdf1fb4c3621f3e392 to your computer and use it in GitHub Desktop.
recompile wsl2 kernel, add modules and CAN modules + can utils.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mines ubuntu 20.04 based, WSL2 | |
in windows | |
wsl --list -v | |
* Ubuntu-20.04 Stopped 2 | |
in wsl | |
# the old update routine | |
sudo apt-get update -y | |
# add tools to build kernel, apologies if i missed anything as i already have a bunch of dev stuff setup | |
sudo apt-get install -y autoconf bison build-essential flex libelf-dev libncurses-dev libssl-dev libtool libudev-dev | |
#get kernel version | |
uname -r | |
5.10.16.3-microsoft-standard-WSL2 | |
# get matching version, this is mine | |
wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-5.10.16.3.tar.gz | |
#extract it (change to your kernel version) | |
tar -xf linux-msft-wsl-5.10.16.3.tar.gz | |
# build linux/modules | |
# change to the folder tar extracted too, yours might be different, i usually set a link from WSL-Linux-Kernel to the current | |
cd WSL2-Linux-Kernel-linux-msft-wsl-5.10.16.3/ | |
cat /proc/config.gz | gunzip > .config | |
make prepare modules_prepare -j $(expr $(nproc) - 1) | |
# select vcan and can subsystems here | |
make menuconfig -j $(expr $(nproc) - 1) | |
make modules -j $(expr $(nproc) - 1) | |
sudo make modules_install | |
make -j $(expr $(nproc) - 1) | |
sudo make install | |
# copy it to windows drive | |
cp vmlinux /mnt/c/Users/<yourwindowsloginname>/ | |
#create this file, change /<yourwindowsloginname> to your windows users directory name | |
vi /mnt/c/Users/<yourwindowsloginname>/.wslconfig | |
#with these contents | |
[wsl2] | |
kernel=C:\\Users\\<yourwindowsloginname>\\vmlinux | |
# exit wsl | |
exit | |
in windows | |
rem reboot wsl entirely | |
wsl --shutdown | |
rem restart wsl | |
wsl | |
in wsl | |
sudo modprobe vcan | |
#if it fails, check dmesg as kernel messages are limited back to modprobe and its terse | |
sudo ip link add dev vcan0 type vcan | |
sudo ip link set up vcan0 | |
# add can-utils | |
sudo apt install can-utils | |
#add can_raw | |
sudo modprobe can_raw | |
#do something with it | |
candump -c -c -ta vcan0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @charlie-x @yves-chevallier @david-yyongning. Thanks for your great suggestion!
I am currently encountering the exception that all these commands are executed successfully without errors but running the last line
candump -c -c -ta vcan0
has no responses, no logs and no exceptions and can only exit byctrl+c
.and running
sudo tc qdisc add dev eth0 root handle 1: tbf rate 300mbit burst 256kb latency 800ms
reportsError: Specified qdisc not found.
Could you tell me how can I fixed it? Thanks!