Contenuto principale

Install Ubuntu Distribution for Windows Subsystem for Linux (WSL)

This section helps you complete the Install Ubuntu Distribution for WSL step of the Hardware Setup process (using the Hardware Setup screens).

The Ubuntu 22.04 distribution is essential for developing and compiling ArduPilot code for an ArduPilot configuration using WSL. This section provides instructions to install Ubuntu 22.04.

Note

Enable your computer’s virtualization feature in the BIOS settings before installing Ubuntu. This feature might appear as Virtualization Technology, Intel VT-x, or AMD-V, depending on the processor. Enabling virtualization allows your PC to run virtual environments, which is necessary for compiling and running ArduPilot code on Ubuntu within Windows.

Connect your PC to an active internet connection before starting the installation.

Before setting up your development environment for the UAV Toolbox Support Package for ArduPilot Autopilots, it is important to ensure that your Windows Subsystem for Linux (WSL) installation includes the correct version of Ubuntu 22.04. These are two possible scenarios you might encounter:

  • WSL is installed, but Ubuntu 22.04 is not present.

  • WSL is installed with Ubuntu 22.04, but this is not a fresh distribution, and might have been used for other projects. Creating a separate Ubuntu instance in WSL 2 allows you to set up an isolated development environment for ArduPilot, ensuring that your work does not conflict with other WSL environments.

    For an isolated development environment, it is recommended to install a fresh Ubuntu instance in WSL 2 using the ArduPilot watermarked distribution used by Simulink. This helps prevent conflicts with other WSL environments and avoids potential issues from ArduPilot upgrades or downgrades.

To determine which scenario applies to your system, check for Ubuntu 22.04 distribution in WSL. Open a Windows Command Prompt and execute the following command:

wsl -l -v

This command lists all installed WSL distributions and their versions.

WSL Installed without Ubuntu 22.04

The Ubuntu 22.04 distribution is essential for developing and compiling ArduPilot code for Autopilot configuration using WSL. If you already have WSL installed on your system, but Ubuntu 22.04 is not installed, you can install Ubuntu 22.04 by performing these steps.

  1. Open the Windows Command Prompt as a regular user (not as an administrator).

    Press the Windows Start key, type cmd, and press Enter.

  2. List available distributions.

    • Run this command in the command prompt.

      wsl --list --online
  3. Locate Ubuntu 22.04

    • Look for Ubuntu-22.04 in the list. This is the common name for Ubuntu 22.04.

    • If the name differs, use the exact name shown in your list.

  4. Install Ubuntu 22.04

    • Run this command.

      wsl --install -d Ubuntu-22.04

      If the distribution name is different, replace Ubuntu-22.04 with the correct name from your list:

      wsl --install -d <DistributionName>
  5. Set up Ubuntu.

    • Installed Ubuntu distribution will prompt you to configure a new username and password for your Ubuntu environment.

WSL Installed Without ArduPilot-Specific Ubuntu 22.04 Distribution

If you have already installed Windows Subsystem for Linux (WSL) but do not have Ubuntu 22.04 installed, or if you are running the ArduPilot setup screens for the first time after previously setting up PX4 Autopilots, you need to ensure your environment is properly configured for the UAV Toolbox Support Package for ArduPilot Autopilots.

In the Install Ubuntu Distribution for WSL screen, select Install a fresh distribution and click Next.

Perform these steps to install Ubuntu 22.04 distribution for WSL.

  1. Download the Ubuntu RootFS for WSL.

    1. Go to Ubuntu Cloud Images for WSL.

    2. Download the file: ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz

    3. Save it to a local directory in Windows file system (not wsl2). For example, ~\WebUbuntu

  2. Navigate to working directory.

    1. Open command prompt.

    2. Navigate to your working directory to import the WSL instance. For example:

      cd ~\WebUbuntu
  3. Create a directory for the new distribution instance by running this command.

    mkdir ArduPilotSimulink
  4. Import the WSL instance.

    wsl --import ArduPilotSimulink .\ArduPilotSimulink\ 
    .\WebUbuntu\ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz

    This command will import an Ubuntu 22.04 distribution into WSL, naming the instance ArduPilotSimulink.

  5. Start the newly created WSL distribution.

    • Start your WSL instance again by running this command in Windows command prompt

      wsl -d ArduPilotSimulink

  6. Create a new user in WSL by executing this command from Inside WSL.

    sudo adduser <username>

    Replace <username> with your username.

  7. Add the user to the sudo group by executing this command from Inside WSL.

    sudo usermod -aG sudo <username>

    Replace <username> with your username.

  8. Set the default user in WSL, by modifying the WSL configuration file. Execute this command from Inside WSL.

    sudo tee -a /etc/wsl.conf <<EOF
    [user]
    default=<username>
    EOF

    Replace <username> with your username.

  9. Restart WSL by executing the following command from inside WSL.

    exit

  10. Shutdown the WSL from Windows command prompt by executing this command.

    wsl --shutdown

  11. Reopen the distribution from Windows command prompt by executing this command.

    wsl -d ArduPilotSimulink

If you have already installed Ubuntu 22.04, select I have already installed Ubuntu 22.04 and click Next. In the next screen, if the installed Ubuntu distribution is not shown in the drop-down list, restart the hardware setup and try again.

Next Steps

  • Install Python 3.7 or later version.