Virtualization
You can also use the ICOtronic package with various virtualization software. For that to work you have to make sure that (at least) the PEAK CAN adapter is attached to the virtual guest operating system. For some virtualization software you might have to install additional software for that to work. For example, VirtualBox requires that you install the VirtualBox Extension Pack before you can use USB 2 and USB 3 devices.
Note: Please be advised that the VirtualBox Extension Pack is paid software even though you can download and use it without any license key. Oracle might come after you, if you do not pay for the license, even if you use the Extension Pack in an educational setting.
The table below shows some of the virtualization software we tried and that worked (when we tested it).
Virtualization Software |
Host OS |
Host Architecture |
Guest OS |
Guest Architecture |
Notes |
|---|---|---|---|---|---|
macOS |
|
Ubuntu 20.04 |
|
||
macOS |
|
Windows 10 |
|
||
macOS |
|
Fedora 36 |
|
||
macOS |
|
Windows 11 |
|
JLink (and hence Simplicity Commander) only works with programming adapters that support WinUSB |
|
macOS |
|
Windows 10 |
|
||
Windows |
|
Fedora 36 |
|
||
Windows |
|
Ubuntu 22.04 |
|
Windows Subsystem for Linux 2
Using ICOtronic in the WSL 2 currently requires using a custom Linux kernel. We would not recommend using ICOtronic with this type of virtualization software, since the setup requires quite some amount of work and time. Nevertheless the steps below should show you how you can use the PEAK CAN adapter and hence the ICOtronic package with WSL 2.
Install WSL 2 (Windows Shell):
wsl --install
Install Ubuntu 22.04 VM (Windows Shell):
Open the Ubuntu 22.04 application
Choose a user name
Choose a password
Execute the following commands in a Powershell session
wsl --setdefault Ubuntu-22.04 wsl --set-version Ubuntu-22.04 2
The second command might fail, if
Ubuntu-22.04already uses WSL 2. In this case please just ignore the error message.
-
Windows Shell:
Note: Please replace
<user>with your (Linux) username (e.g.rene)cd ~/Documents mkdir WSL cd WSL wsl --export Ubuntu-22.04 CANbuntu.tar wsl --import CANbuntu CANbuntu CANbuntu.tar wsl --distribution CANbuntu --user <user>
Linux Shell:
sudo apt update sudo apt upgrade -y sudo apt install -y bc build-essential flex bison libssl-dev libelf-dev \ libncurses-dev autoconf libudev-dev libtool dwarves cd ~ git clone https://github.com/microsoft/WSL2-Linux-Kernel.git cd WSL2-Linux-Kernel uname -r # 5.15.74.2-microsoft-standard-WSL2 → branch …5.15.y git checkout linux-msft-wsl-5.15.y cat /proc/config.gz | gunzip > .config make menuconfig
Make sure the following features are enabled:
Device Drivers→USB SupportDevice Drivers→USB Support→USB announce new devicesDevice Drivers→USB Support→USB Modem (CDC ACM) supportDevice Drivers→USB Support→USB/IPDevice Drivers→USB Support→USB/IP→VHCI HCDDevice Drivers→USB Support→USB Serial Converter SupportDevice Drivers→USB Support→USB Serial Converter Support→USB FTDI Single port Serial Driver
Enable the following features:
Networking support→CAN bus subsystem supportNetworking support→CAN bus subsystem support→Raw CAN ProtocolNetworking support→CAN bus subsystem support→CAN device drivers→Virtual Local CAN InterfaceNetworking support→CAN bus subsystem support→CAN device drivers→Serial / USB serial CAN Adaptors (slcan)Networking support→CAN bus subsystem support→CAN device drivers→CAN USB Interfaces→PEAK PCAN-USB/USB Pro interfaces for CAN 2.0b/CAN-FD
Save the modified kernel configuration.
Linux Shell:
touch .scmversion make sudo make modules_install sudo make install
Install
usbipd-win(Linux Shell):cd tools/usb/usbip ./autogen.sh ./configure sudo make install sudo cp libsrc/.libs/libusbip.so.0 /lib/libusbip.so.0 sudo apt-get install -y hwdata
Copy image (Linux Shell):
Note: Please replace
<user>with your (Windows) username (e.g.rene)cd ~/WSL2-Linux-Kernel cp arch/x86/boot/bzImage /mnt/c/Users/<user>/Documents/WSL/canbuntu-bzImage
Create
.wslconfigin (root of) Windows user directory and store the following text:[wsl2] kernel=c:\\users\\<user>\\Documents\\WSL\\canbuntu-bzImage
Note: Please replace
<user>with your (Windows) username (e.g.rene)Set default distribution (Windows Shell)
wsl --setdefault CANbuntu
Shutdown and restart WSL (Windows Shell):
wsl --shutdown wsl -d CANbuntu --cd "~"
Change default user of WSL distro (Linux Shell)
sudo nano /etc/wsl.conf
Insert the following text:
[user] default=<user>
Note: Please replace
<user>with your (Windows) username (e.g.rene)Save the file and exit
nano:Ctrl + O
⏎
Ctrl + X)
Restart WSL: See step
8Install
usbipd(Windows Shell):winget install usbipd
Attach CAN-Adapter to Linux VM (Windows Shell)
usbipd wsl list # … # 5-3 0c72:0012 PCAN-USB FD Not attached # … usbipd wsl attach -d CANbuntu --busid 5-3 usbipd wsl list # … # 5-3 0c72:0012 PCAN-USB FD Attached - CANbuntu # …
Check for PEAK CAN adapter in Linux (Optional, Linux Shell):
dmesg | grep peak_usb # … # peak_usb 1-1:1.0: PEAK-System PCAN-USB FD v1 fw v3.2.0 (1 channels) # … lsusb # … # Bus 001 Device 002: ID 0c72:0012 PEAK System PCAN-USB FD # …
Add virtual link for CAN device (Linux Shell)
sudo ip link set can0 type can bitrate 1000000 sudo ip link set can0 up
Note: If the commands above fail with the error message:
RTNETLINK answers: Connection timed out
then please disconnect and connect the USB CAN adapter. After that attach it to the Linux VM again (see step
12).Install
pip(Linux Shell):sudo apt install -y python3-pip
Install ICOtronic (Linux Shell)
cd ~ mkdir Documents cd Documents git clone https://github.com/MyTooliT/ICOtronic.git cd ICOtronic python3 -m pip install --prefix=$(python3 -m site --user-base) -e .
Run a script to test that everything works as expected (Linux Shell)
icon listIf the command above fails with the message
Command 'icon' not found…
then you might have to logout and login into the WSL session again before you execute
icon listagain.
Notes:
You only need to repeat steps
12: attach the CAN adapter to the VM in Windows and
14: create the link for the CAN device in Linuxafter you set up everything properly once.
Unfortunately configuring the CAN interface automatically does not seem to work (reliably) on WSL yet