主要内容

Set Up Virtual Linux Target Device

R2026b

After completing Configure Development Computer for Real-Time Linux, set up a Debian® 11 or Debian 13 virtual machine as a Linux target device to use with Simulink® Real-Time™.

Note

Running Simulink Real-Time models on a virtual machine cannot match the performance of running them natively on hardware.

Windows Hyper-V Linux Target Device

Use the Hyper-V Manager or other virtual machine tool to configure a virtual Linux target device.

  1. Install Hyper-V by using the instructions from Install Hyper-V in Windows and Windows Server | Microsoft Learn.

  2. Download the Debian 11 (Bullseye) or Debian 13 (Trixie) CD/DVD image from:

  3. On the Hyper-V Manager click New > Virtual Machine.

  4. Name your virtual machine.

    New Virtual Machine Wizard, Specify Name and Location

  5. Use the Generation 2 setting in the next step.

    New Virtual Machine Wizard, Specify Generation

  6. Clear Use Dynamic Memory for this virtual machine.

    New Virtual Machine Wizard, Assign Memory

  7. Use the designated virtual switch (set up separately) for the Connection setting. For information about switch setup, see Create and configure a virtual switch with Hyper-V at https://learn.microsoft.com.

    New Virtual Machine Wizard, Configure Networking

  8. Select the boot-up image according to your choice. This configuration uses a bootable image file for Debian 11 or Debian 13.

    New Virtual Machine Wizard, Installation Options

  9. Finish the setup in the wizard.

    New Virtual Machine Wizard, Completing the Wizard

  10. Make sure to clear Enable Secure Boot before launching the VM target.

    Secure boot selection

  11. Launch and set up your virtual machine target by following the on-screen instructions.

  12. Install the SSH server by running:

    sudo apt update
    sudo apt install openssh-server
  13. You can SSH into the virtual machine by using its IP address. Obtain the IP address by running:

    hostname -I

To set up support package software on the Linux target device, see Target Device Configuration for Real-Time Linux.

Set Up Window WSL Target Device

You can use Windows Subsystem for Linux (WSL) as a soft real-time target for deploying Simulink Real-Time models. A WSL target lets you rapidly prototype and test models in a virtualized Linux environment directly on your Windows PC, without requiring dedicated target computer hardware.

WSL targets use Debian 13 running inside WSL2. While less performant than dedicated hardware or full virtual machines, WSL provides an easier setup experience.

Requirements

  • Windows 10 or later

  • Simulink Real-Time

  • Simulink Real-Time Linux Target Support Package

  • Internet connection (for initial setup)

Set Up WSL Target Device in Simulink Real-Time Explorer

  1. Open the Simulink Real-Time Explorer.

  2. Navigate to the Support Package tab.

  3. Click Setup WSL Target.

  4. In the WSL Target Settings dialog, enter a name for your target.

  5. Click OK. The setup process automatically:

    • Verifies your Windows version is compatible

    • Installs WSL2 if not already present (may trigger a UAC elevation prompt)

    • Ensures WSL2 is set as the default version

    • Installs the Debian 13 distribution under the name "SLRT"

    • Configures SSH access and creates the slrt user account

    • Launches the WSL instance and retrieves its IP address

    • Creates the target with the specified name

  6. When setup completes, the new target appears in the Explorer target tree.

Set Up a WSL Target from Command Window

In the MATLAB Command window, type:

tg = slrtlinux.wsl.setupTarget('myWSLTarget');

This command performs the same setup as the Setup WSL Target button in Simulink Real-Time Explorer and returns a target object. Progress messages are printed to the MATLAB Command window during setup.

To verify that a WSL target has been configured, in the MATLAB Command window, type:

slrtlinux.wsl.isTargetSetup()

This command returns true if WSL has been properly configured for Simulink Real-Time, and it returns false if setup is still needed.

What the Setup Process Does

The slrtlinux.wsl.setupTarget function orchestrates the full configuration workflow:

  1. Checks that a target with the given name does not already exist.

  2. Calls slrtlinux.wsl.configure to install and configure WSL if needed.

  3. Launches the WSL instance with slrtlinux.wsl.launch.

  4. Retrieves the WSL IP address with slrtlinux.wsl.getIPAddress.

  5. Creates the Simulink Real-Time target with the WSL network settings.

The WSL distribution is created with these default credentials:

AccountUsernamePassword
Rootrootroot
SLRT userslrtslrt

Isolation from Existing WSL Installations

The Simulink Real-Time WSL setup creates a distribution named SLRT that is separate from any other WSL distributions on your machine. It does not modify or interfere with pre-existing WSL installations or configurations.

Manage and Connect to Windows WSL Target Device

You can manage and connect to a WSL target by using Simulink Real-Time Explorer or by using functions in the MATLAB Command window.

Launch a WSL Target Using Simulink Real-Time Explorer

  1. In the Simulink Real-Time Explorer, navigate to the Support Package tab.

  2. Click Launch WSL Instance.

    • If WSL has not been set up, you are prompted to run setup first.

  3. A command window opens with a shell session connected to the SLRT WSL distribution, logged in as the slrt user in /home/slrt.

Launch and Connect Using MATLAB Commands

Launch the WSL instance: This command opens a new command window with a shell session connected to the SLRT distribution. The WSL target must have been previously set up with slrtlinux.wsl.setupTarget.

slrtlinux.wsl.launch()

Check if the WSL instance is running: This command returns true if the SLRT WSL distribution is currently running, false otherwise.

slrtlinux.wsl.isRunning()

Get the WSL target IP address: This command returns the IPv4 address of the running SLRT WSL instance. The instance must be running.

ipaddr = slrtlinux.wsl.getIPAddress()

Update the target status: This command refreshes the target object with the current state of the running instance.

tg.update()

Connect to the target: This command establishes a connection to the running WSL target for model deployment and execution.

tg.connect()

Shut Down a WSL Target

Shut down the entire WSL VM (all distributions): This command stops all running WSL distributions on the machine.

slrtlinux.wsl.shutdown()

Terminate only the SLRT distribution: This command stops only the specified distribution, leaving other WSL distributions running.

slrtlinux.wsl.shutdown('SLRT')

Typical Command-Line Workflow

% One-time setup
tg = slrtlinux.wsl.setupTarget('myWSLTarget');

% Subsequent sessions
slrtlinux.wsl.launch();
tg.update();
tg.connect();

% Check target status
slrtlinux.wsl.isRunning()   % returns true

% Get target IP if needed
ipaddr = slrtlinux.wsl.getIPAddress();

% ... deploy and run models ...

% When finished
slrtlinux.wsl.shutdown('SLRT');

Verifying Target State

You can query the WSL target state at any time:

QueryFunctionReturns
Is WSL configured for SLRT?slrtlinux.wsl.isTargetSetup()true / false
Is the SLRT instance running?slrtlinux.wsl.isRunning()true / false
What is the target IP address?slrtlinux.wsl.getIPAddress()IP address string

See Also

| | | | | | | | |

Topics