> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 安装 Visual Studio Code

> 在安装 Qualcomm 扩展之前，在 Ubuntu 或带 WSL 的 Windows 上设置 VS Code。

<Tabs>
  <Tab title="Windows (WSL)">
    <iframe src="https://players.brightcove.net/1414329538001/4JiZQnWhg_default/index.html?videoId=6396305824112" title="在 Windows 上开始使用 Qualcomm® VS Code 扩展" width="100%" height="420" allowFullScreen />

    ## 使用 WSL 的 Windows 设置

    扩展运行在带 Ubuntu 22.04 的 \*\*WSL（Windows Subsystem for Linux）\*\*中。Windows 是主机操作系统；编译和设备通信在 Ubuntu 中进行。

    <Warning>
      您的计算机必须支持虚拟化。这可能需要在 BIOS/UEFI 设置中进行调整。
    </Warning>

    ### 1 — 安装 WSL 和 usbipd

    打开 Windows **管理员**终端并运行：

    ```batch theme={null}
    wsl --install -d ubuntu-22.04
    winget install usbipd-win
    ```

    <Info>
      WSL 安装程序会提示您创建 Linux 用户名和密码。**请勿使用 `root`** — 扩展需要普通用户账户。
    </Info>

    ### 2 — 重启并进入 WSL

    重启计算机。然后在任意终端中：

    ```batch theme={null}
    wsl -d ubuntu-22.04
    ```

    ### 3 — 准备 Ubuntu 环境

    在 WSL Ubuntu shell 中：

    ```bash theme={null}
    sudo apt update && sudo apt upgrade
    sudo locale-gen en_US.UTF-8
    sudo update-locale
    sudo apt-get install gcc bzip2 diffstat g++
    ```

    ### 4 — 从 WSL 启动 VS Code

    ```bash theme={null}
    code .
    ```

    ### 5 — 安装 WSL 扩展

    在 VS Code 中，从 Marketplace 安装 **WSL** 扩展（由 Microsoft 提供）。请参阅[官方说明](https://code.visualstudio.com/docs/remote/wsl#_installation)。

    验证 VS Code 状态栏显示 **WSL: Ubuntu-22.04** — 参阅 [From VS Code](https://code.visualstudio.com/docs/remote/wsl#_from-vs-code)。

    ### 6 — 将 USB 设备连接到 WSL

    插入设备后，按照 [USB 转发指南](./wsl-usb)使用 `usbipd` 将其从 Windows 转发到 WSL。
  </Tab>

  <Tab title="Ubuntu">
    ## Ubuntu 设置

    按照 [VS Code Linux 安装指南](https://code.visualstudio.com/docs/setup/linux)操作。

    <Warning>
      从 VS Code 网站安装 `.deb` 包。扩展**不支持 Snap Store 版本**。
    </Warning>

    验证安装：

    ```bash theme={null}
    code -v
    ```

    预期输出 — 版本、提交 SHA 和架构：

    ```text theme={null}
    1.78.1
    a4e8254e63e4b7a72896e74e12cc2098fcda1d6e
    x64
    ```

    ### 配置 udev 规则

    **配置 udev USB 规则（一次性前提条件）**

    Linux 内核使用 `udev` 控制对 USB 设备的访问。运行以下命令以允许 Qualcomm 厂商 ID `05c6`，从而无需每次操作都使用 `sudo`：

    ```bash theme={null}
    echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9008", MODE="0666", GROUP="plugdev"' \
      | sudo tee /etc/udev/rules.d/51-qcom-usb.rules
    ```

    重启 `udev` 以使更改生效：

    ```bash theme={null}
    sudo systemctl restart udev
    ```

    如果设备已连接，请**拔下并重新插入**。

    <Note>
      请确保您的用户账户是 `plugdev` 组的成员。
    </Note>
  </Tab>
</Tabs>
