You can also use (parts of) ICOc 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 |
---|---|---|---|---|---|
Parallels Desktop | macOS | x64 |
Ubuntu 20.04 | x64 |
|
Parallels Desktop | macOS | x64 |
Windows 10 | x64 |
|
Parallels Desktop | macOS | ARM64 |
Fedora 36 | ARM64 |
|
Parallels Desktop | macOS | ARM64 |
Windows 11 | ARM64 , x64 |
JLink (and hence Simplicity Commander) only works with programming adapters that support WinUSB |
VirtualBox | macOS | x64 |
Windows 10 | x64 |
|
VirtualBox | Windows | x64 |
Fedora 36 | x64 |
|
WSL 2 | Windows | x64 |
Ubuntu 22.04 | x64 |
Using ICOc in the WSL 2 currently requires using a custom Linux kernel. We would not recommend using ICOc 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 ICOc 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.04
already 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 Support
Device Drivers
→USB Support
→USB announce new devices
Device Drivers
→USB Support
→USB Modem (CDC ACM) support
Device Drivers
→USB Support
→USB/IP
Device Drivers
→USB Support
→USB/IP
→VHCI HCD
Device Drivers
→USB Support
→USB Serial Converter Support
Device Drivers
→USB Support
→USB Serial Converter Support
→USB FTDI Single port Serial Driver
Enable the following features:
Networking support
→CAN bus subsystem support
Networking support
→CAN bus subsystem support
→Raw CAN Protocol
Networking support
→CAN bus subsystem support
→CAN device drivers
→Virtual Local CAN Interface
Networking 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
.wslconfig
in (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
8
-
Install
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 ICOc (Linux Shell)
cd ~ mkdir Documents cd Documents git clone https://github.com/MyTooliT/ICOc.git cd ICOc python3 -m pip install --prefix=$(python3 -m site --user-base) -e .
-
Run a script to test that everything works as expected (Linux Shell)
icon list
If 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 list
again.
Notes:
- You only need to repeat steps
12
: attach the CAN adapter to the VM in Windows and14
: 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
-
Download and unpack Simplicity Commander (Linux Shell)
sudo apt install -y unzip mkdir -p ~/Downloads cd ~/Downloads wget https://www.silabs.com/documents/public/software/SimplicityCommander-Linux.zip unzip SimplicityCommander-Linux.zip cd SimplicityCommander-Linux tar xf Commander-cli_linux_x86_64*.tar.bz mkdir -p ~/Applications mv commander-cli ~/Applications/commander ln -s ~/Applications/commander/commander-cli ~/Applications/commander/commander # Fix J-Link connection # https://wiki.segger.com/J-Link_cannot_connect_to_the_CPU sudo cp ~/Applications/commander/99-jlink.rules /etc/udev/rules.d/
-
Add
commander
binary to path (Linux Shell)-
Open
~/.profile
innano
:nano ~/.profile
-
Add the following text at the bottom:
if [ -d "$HOME/Applications/commander" ] ; then PATH="$HOME/Applications/commander:$PATH" fi
-
Save your changes
-
-
Restart WSL
-
Connect programming adapter to Linux (Windows Shell)
usbipd wsl list # … # 5-4 1366:0105 JLink CDC UART Port (COM3), J-Link driver Not attached # … usbipd wsl attach --busid 5-4
-
Check if
commander
JLink connection works without usingsudo
(Linux Shell)commander adapter dbgmode OUT --serialno <serialnumber> # Setting debug mode to OUT... # DONE
Notes:
-
Please replace
<serialnumber>
with the serial number of your programming board (e.g.440069950
):commander adapter dbgmode OUT --serialno 440069950
-
If the command above fails with the error message:
error while loading shared libraries: libGL.so.1: cannot open shared object file…
then you need to install
libgl1
:sudo apt install -y libgl1
-
Note: The tests use the command-line xdg-open
. For the tests also work on Linux, then you need to install the Python package xdg-open-wsl
:
pip3 install --user git+https://github.com/cpbotha/xdg-open-wsl.git
-
Start WSL (Windows Shell)
wsl -d CANbuntu --cd "~/Documents/ICOc"
-
Connect programming/CAN adapter to Linux (Windows Shell):
$jlink_id = usbipd wsl list | Select-String JLink | %{$_ -replace '(\d-\d).*','$1'} $can_id = usbipd wsl list | Select-String PCAN-USB | %{$_ -replace '(\d-\d).*','$1'} usbipd wsl attach -d CANbuntu --busid $jlink_id usbipd wsl attach -d CANbuntu --busid $can_id
-
Configure CAN interface (Linux Shell):
sudo ip link set can0 type can bitrate 1000000 sudo ip link set can0 up
-
Run tests (Linux Shell):
make run