如何搭建Ubuntu WSL2 VSCode ESP-IDF OpenCode跨系统开发环境?

摘要:1. 引言 在 WSL2 下配置 ESP-IDF 环境与在 VMware 下差不多,就只有配置 USB 串口设备不同。 2. WSL + ESP-IDF 环境搭建 2.1 WSL 基本环境 基本的环境搭建可参考此篇文章:
1. 引言 在 WSL2 下配置 ESP-IDF 环境与在 VMware 下差不多,就只有配置 USB 串口设备不同。 2. WSL + ESP-IDF 环境搭建 2.1 WSL 基本环境 基本的环境搭建可参考此篇文章: 【Ubuntu】Ubuntu+VScode+ESP-IDF 的环境搭建 2.2 配置 USB 串口设备 具体可以访问 ESP-IDF 官网: 在 Windows 系统中使用 WSL 具体在“在 WSL 中添加所需的 Linux 软件包”处配置 USB 串口设备 注意:绑定设备后,每次在重新连接设备的时候都需要的操作: 在 powershell 中执行 usbipd list 以查看 USB 设备列表 找到并记住 ESP32 的 USB 串口设备的 BUSID 在 powershell 中执行 usbipd attach --wsl --busid <BUSID>,将设备挂载在 Ubuntu 中 在 WSL 下执行 dmesg | tail 验证连接是否成功 2.3 将用户添加进 USB 串口设备组 WSL 下执行:sudo usermod -aG dialout 用户名,即可不需要每次连接上设备的时候都需要给设备文件权限。 2.4 自动配置 ESP-IDF 环境 2.4.1 登录 shell 执行配置环境 在用户目录下,在 .profile 文件中加入: source ~/esp/esp-idf/export.sh 2.4.1 非登录 shell 执行配置环境 在用户目录下,在 .bashrc 文件中加入: source ~/esp/esp-idf/export.sh 3. VSCode 配置 3.1 使用 SSH 连接 WSL 下载 WSL 插件,直接连接即可: 3.2 下载 ESP-IDF 下载 ESP-IDF 插件: 有一点需要注意的是,最新版插件可能会出现如下问题,这时候只需要回退一个版本,配置好 ESP-IDF 插件环境后再更新到最新版本即可。 4. OpenCode 配置 推荐文章: OpenCode 中文站 OpenCode + Oh My OpenCode 安装配置完全指南 4.1 Oh My OpenCode 插件安装 4.1.1 安装 bun 首先安装 unzip: sudo apt-get update && sudo apt-get install -y unzip 然后安装 bun: // 官方安装教程 curl -fsSL https://bun.sh/install | bash // 连接不上可以用 bun 安装脚本 chmod +x bun-install.sh && ./bun-install.sh 安装脚本获取: https://github.com/skyrim-dev/bun-install-sh 4.1.2 安装 omo 插件 点击链接查看 ->请求 OpenCode 帮你安装<- 比用别的方式简单很多。 4.2 跨系统使用 OpenCode 使用 WSL2 后,我们可以很方便的将 OpenCode 安装在 Ubuntu 的同时,在 Windows 的开发中使用 OpenCode 进行辅助,OpenCode 可以通过 /mnt/c/ 或 /mnt/f/ 等访问 Windows 上的文件夹。 4.2.1 使用教程 直接输入 wsl 打开 Ubuntu 系统,再输入 OpenCode 进行启动。 可以看到,可以正常读取到 Windows 上的项目。 5. 大量域名 DNS 解析本地回环问题 在 Windows 中的 hosts,C:\Windows\System32\drivers\etc\hosts有大量的域名被指向 127.0.0.1: 其实是 steam++ 在搞鬼,关闭即可。 点击查看代码 # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost # Steam++ Start 127.0.0.1 steamcdn-a.akamaihd.net 127.0.0.1 steamuserimages-a.akamaihd.net 127.0.0.1 cdn.akamai.steamstatic.com 127.0.0.1 community.akamai.steamstatic.com 127.0.0.1 avatars.akamai.steamstatic.com 127.0.0.1 store.akamai.steamstatic.com 127.0.0.1 community.steamstatic.com 127.0.0.1 media.steampowered.com 127.0.0.1 steamcommunity.com 127.0.0.1 www.steamcommunity.com 127.0.0.1 store.steampowered.com 127.0.0.1 api.steampowered.com 127.0.0.1 help.steampowered.com 127.0.0.1 login.steampowered.com 127.0.0.1 checkout.steampowered.com 127.0.0.1 img.youtube.com 127.0.0.1 translate.google.cn 127.0.0.1 translate.googleapis.com 127.0.0.1 translate-pa.googleapis.com 127.0.0.1 translate.google.com 127.0.0.1 google.com 127.0.0.1 www.google.com 127.0.0.1 hcaptcha.com 127.0.0.1 assets.hcaptcha.com 127.0.0.1 imgs.hcaptcha.com 127.0.0.1 www.hcaptcha.com 127.0.0.1 docs.hcaptcha.com 127.0.0.1 js.hcaptcha.com 127.0.0.1 newassets.hcaptcha.com 127.0.0.1 imgs3.hcaptcha.com 127.0.0.1 client-api.arkoselabs.com 127.0.0.1 epic-games-api.arkoselabs.com 127.0.0.1 cdn.arkoselabs.com 127.0.0.1 prod-ireland.arkoselabs.com 127.0.0.1 huggingface.co 127.0.0.1 github.dev 127.0.0.1 api.github.com 127.0.0.1 github.githubassets.com 127.0.0.1 support-assets.githubassets.com 127.0.0.1 education.github.com 127.0.0.1 resources.github.com 127.0.0.1 uploads.github.com 127.0.0.1 archiveprogram.github.com 127.0.0.1 raw.github.com 127.0.0.1 githubusercontent.com 127.0.0.1 raw.githubusercontent.com 127.0.0.1 camo.githubusercontent.com 127.0.0.1 cloud.githubusercontent.com 127.0.0.1 avatars.githubusercontent.com 127.0.0.1 avatars0.githubusercontent.com 127.0.0.1 avatars1.githubusercontent.com 127.0.0.1 avatars2.githubusercontent.com 127.0.0.1 avatars3.githubusercontent.com 127.0.0.1 user-images.githubusercontent.com 127.0.0.1 objects.githubusercontent.com 127.0.0.1 private-user-images.githubusercontent.com 127.0.0.1 github.com 127.0.0.1 pages.github.com 127.0.0.1 gist.github.com 127.0.0.1 githubapp.com 127.0.0.1 hub.docker.com 127.0.0.1 greasyfork.org 127.0.0.1 update.greasyfork.org 127.0.0.1 github.io 127.0.0.1 www.github.io 127.0.0.1 fandom.com 127.0.0.1 www.fandom.com 127.0.0.1 nexusmods.com 127.0.0.1 www.nexusmods.com 127.0.0.1 staticdelivery.nexusmods.com 127.0.0.1 cf-files.nexusmods.com 127.0.0.1 staticstats.nexusmods.com 127.0.0.1 users.nexusmods.com 127.0.0.1 files.nexus-cdn.com 127.0.0.1 premium-files.nexus-cdn.com 127.0.0.1 supporter-files.nexus-cdn.com 127.0.0.1 local.steampp.net # Steam++ End 那应该如何修改呢?,你说说 博客导航 博客导航