USB Host功能
3506支持两个USB2.0接口,用户可以在任何一个板载USB HOST接口上连接USB鼠标、USB键盘、U盘等设备,并支持以上设备的热插拔。这里用挂载U盘为例进行演示,目前U盘测试支持到32G,32G以上并未测试。
终端会打印关于U盘的信息,由于存在很多种U盘,显示的信息可能会有差别:
1、开发板启动后,连接USB接口u盘到开发板的USB host接口,默认log打印信息较低,不会有打印信息。可以使用dmesg命令查看,找到u盘相关信息
[ 1524.297550] usb 2-1.3: new high-speed USB device number 4 using dwc2
[ 1524.493923] usb-storage 2-1.3:1.0: USB Mass Storage device detected
[ 1524.496615] scsi host0: usb-storage 2-1.3:1.0
[ 1525.522210] scsi 0:0:0:0: Direct-Access SanDisk Cruzer Blade 1.00 PQ: 0 ANSI: 6
[ 1525.535539] sd 0:0:0:0: [sda] 60125184 512-byte logical blocks: (30.8 GB/28.7 GiB)
[ 1525.536834] sd 0:0:0:0: [sda] Write Protect is off
[ 1525.538522] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1525.546982] sda: sda1
[ 1525.547581] sd 0:0:0:0: [sda] Attached SCSI removable disk
[ 1525.893709] EXT4-fs (sda): VFS: Can't find ext4 filesystem
[ 1525.895579] EXT4-fs (sda): VFS: Can't find ext4 filesystem
[ 1525.897325] EXT2-fs (sda): error: can't find an ext2 filesystem on dev sda.
[ 1525.901082] FAT-fs (sda): bogus number of reserved sectors
[ 1525.901131] FAT-fs (sda): Can't find a valid FAT filesystem
[ 1525.901873] FAT-fs (sda): bogus number of reserved sectors
[ 1525.901912] FAT-fs (sda): Can't find a valid FAT filesystem
[ 1526.517667] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
查看挂载目录
root@3506-buildroot:/# ls /run/media/
mmcblk0p5 sda1
可以看到/run/media/sda1为USB存储设备的挂载路径
查看U盘内容(这里的sda1以实际U盘分区名称为准)
root@3506-buildroot:/# ls -l /run/media/sda1/
total 512000
-rwxrwx--- 1 root disk 524288000 Dec 12 20:25 test
写入测试,写入速度受限于具体的存储设备:
root@3506-buildroot:/# dd if=/dev/zero of=/run/media/sda1/test bs=1M count=500 conv=fsync
500+0 records in
500+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 45.6879 s, 11.5 MB/s
读取测试:
root@3506-buildroot:/# dd if=/run/media/sda1/test of=/dev/null bs=1M iflag=direct
500+0 records in
500+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 18.8926 s, 27.8 MB/s
U盘使用完成后,在拔出U盘前,需要使用umount卸载
root@3506-buildroot:/# umount /run/media/sda1
注意:退出U盘挂载路径后再插拔U盘。
作者:SteveChen 创建时间:2025-04-11 20:10
最后编辑:SteveChen 更新时间:2025-04-11 20:12
最后编辑:SteveChen 更新时间:2025-04-11 20:12