郑州市惠济区建设局网站,怎么做网站结构图,做爰全过程免费狐狸网站,大连旅游众做周知在嵌入式开发中经常需要制作SD卡系统来启动开发板#xff0c;最近从虚拟机转到WSL发现不能像以前那样对SD卡进行操作了#xff0c;记录下解决方法#xff08;我的系统环境是Win10WSL2#xff09;
编译WSL2内核
由于WSL2的内核默认没有添加USB存储设备的驱动的支持…众做周知在嵌入式开发中经常需要制作SD卡系统来启动开发板最近从虚拟机转到WSL发现不能像以前那样对SD卡进行操作了记录下解决方法我的系统环境是Win10WSL2
编译WSL2内核
由于WSL2的内核默认没有添加USB存储设备的驱动的支持所以无法进行烧录操作需要对内核进行重新配置。在微软官方的WSL2内核仓库中下载内核源码到WSL2中解压后进行配置和编译我这里下载的是WSL2-Linux-Kernel-linux-msft-wsl-5.15.150.1.tar.gz.
#安装必要的软件
sudo apt update sudo apt upgrade -y
sudo apt install libncurses-dev build-essential flex bison libssl-dev libelf-dev dwarves
#解压内核源码
tar xf WSL2-Linux-Kernel-linux-msft-wsl-5.15.150.1.tar.gz
#进入内核源码目录
cd WSL2-Linux-Kernel-linux-msft-wsl-5.15.150.1/
#配置内核
make menuconfig KCONFIG_CONFIGMicrosoft/config-wsl选中 Device Drivers USB support USB Mass Storage support 以及下面的一系列子选项然后 Save Exit
* USB Mass Storage support
[ ] USB Mass Storage verbose debug
* Realtek Card Reader support
* Datafab Compact Flash Reader support
* Freecom USB/ATAPI Bridge support
* ISD-200 USB/ATA Bridge support
* USBAT/USBAT02-based storage support
* SanDisk SDDR-09 (and other SmartMedia, including DPCM) support
* SanDisk SDDR-55 SmartMedia support
* Lexar Jumpshot Compact Flash Reader
* Olympus MAUSB-10/Fuji DPC-R1 support
* Support OneTouch Button on Maxtor Hard Drives
* Support for Rio Karma music player
* SAT emulation on Cypress USB/ATA Bridge with ATACB
* USB ENE card reader support
* USB Attached SCSI 配置完成后对内核进行编译
make bzImage KCONFIG_CONFIGMicrosoft/config-wsl编译完成后bzImage文件在内核源码的arch/x86/boot/目录下。
将bzImage文件拷贝出来放到Windows系统的用户目录下(例如我的是C:\Users\admin)然后在用户目录创建一个.wslconfig文件把内核路径添加到文件中关于该配置文件可以参考微软官方文档示例如下
[wsl2]
kernelc:\\Users\\admin\\bzImage上面的操作完成后重新启动WSL2使用的就是新编译的内核了。
安装usbipd-win软件 首先参考微软官方文档连接 USB 设备安装usbipd-win软件 使用PowerShell 运行usbipd命令共享USB设备到WSL2 列出设备usbipd list示例如下 PS C:\Users\admin usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-3 062a:8572 USB 输入设备 Not shared
1-5 14cd:1212 USB 大容量存储设备 Not shared
1-6 2717:5016 USB 输入设备 Not shared共享设备usbipd bind示例如下 PS C:\Users\admin usbipd bind --busid 1-5
PS C:\Users\admin usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-3 062a:8572 USB 输入设备 Not shared
1-5 14cd:1212 USB 大容量存储设备 Shared
1-6 2717:5016 USB 输入设备 Not shared添加USB设备到WSL2 usbipd attach示例如下 PS C:\Users\admin usbipd attach --wsl --busid 1-5
usbipd: info: Using WSL distribution Ubuntu-20.04 to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 192.168.69.1 to reach the host.
PS C:\Users\admin usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-3 062a:8572 USB 输入设备 Not shared
1-5 14cd:1212 USB 大容量存储设备 Attached
1-6 2717:5016 USB 输入设备 Not shared在WSL下查看usb设备的命令 lsusb 在 WSL中完成设备使用后断开 USB 设备在PowerShell中运行 usbipd detach 命令示例 PS C:\Users\admin usbipd detach --busid 1-5
usbipd: info: Device with busid 1-5 was already not attached.若要取消USB设备共享在PowerShell中运行 usbipd unbind 命令示例 usbipd unbind --busid 1-5验证
使用 lsblk 命令查看设备是否挂载例如我的是sdd
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 388.5M 1 disk
sdb 8:16 0 2G 0 disk [SWAP]
sdc 8:32 0 1T 0 disk /mnt/wslg/distro
sdd 8:48 1 29.2G 0 disk
├─sdd1 8:49 1 500M 0 part
└─sdd2 8:50 1 28.7G 0 part