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

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

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.

  1. Install WSL 2 (Windows Shell):

    wsl --install
    
  2. Install Ubuntu 22.04 VM (Windows Shell):

    1. Install Ubuntu 22.04 from the Microsoft Store

    2. Open the Ubuntu 22.04 application

      1. Choose a user name

      2. Choose a password

    3. 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.

  3. Create Custom Kernel

    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 DriversUSB Support

    • Device DriversUSB SupportUSB announce new devices

    • Device DriversUSB SupportUSB Modem (CDC ACM) support

    • Device DriversUSB SupportUSB/IP

    • Device DriversUSB SupportUSB/IPVHCI HCD

    • Device DriversUSB SupportUSB Serial Converter Support

    • Device DriversUSB SupportUSB Serial Converter SupportUSB FTDI Single port Serial Driver

    Enable the following features:

    • Networking supportCAN bus subsystem support

    • Networking supportCAN bus subsystem supportRaw CAN Protocol

    • Networking supportCAN bus subsystem supportCAN device driversVirtual Local CAN Interface

    • Networking supportCAN bus subsystem supportCAN device driversSerial / USB serial CAN Adaptors (slcan)

    • Networking supportCAN bus subsystem supportCAN device driversCAN USB InterfacesPEAK 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
    
  4. 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
    
  5. 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
    
  6. 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)

  7. Set default distribution (Windows Shell)

    wsl --setdefault CANbuntu
    
  8. Shutdown and restart WSL (Windows Shell):

    wsl --shutdown
    wsl -d CANbuntu --cd "~"
    
  9. 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:

    1. Ctrl + O

    2. Ctrl + X)

  10. Restart WSL: See step 8

  11. Install usbipd (Windows Shell):

    winget install usbipd
    
  12. 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
    # …
    
  13. 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
    # …
    
  14. 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).

  15. Install pip (Linux Shell):

    sudo apt install -y python3-pip
    
  16. 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 .
    
  17. 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 and

  • 14: create the link for the CAN device in Linux

after you set up everything properly once.