挂载 U 盘
Read time: 2 minute(s)
Luban-Lite 可以实现挂载 U 盘 (FAT32 格式),本节介绍配置挂载 U 盘的详细步骤。
- 进入 SDK 的 menuconfig 菜单,选择对应的 USB 接口,例如 Usb0,并将其配置为 HOST。以 D211BBV-DEMO-V2.0 为例,进入 SDK 的 menuconfig 菜单做如下配置:
Board options ---> [*] Using Usb0 Select Usb0 mode (Host) --->
- 在 menuconfig 中,按如下选择,配置 Cherry USB
协议栈:
Local packages options ---> Third-party packages options ---> [*] CherryUSB: tiny and portable USB host/device stack for embedded system with USB IP [] Enable usb device mode [*] Enable usb host mode ---> [*] Enable usb msc driver [*] Enable usb example
- 设置自动挂载
在
target/<cpu>/<board>/board.c
中,找到mount_table
数组,添加以下代码以自动挂载 U 盘:const struct dfs_mount_tbl mount_table[] = { ... {"udisk", "/udisk", "elm", 0, 0, 0}, ... };
U 盘拔插事件的监控和自动挂载在 packages/third-party/cherryusb/demo/usbh_msc_template.c 中完成:void usbh_msc_run(struct usbh_msc *msc_class) { active_msc_class = msc_class; /* Mount fatfs usb massstorage */ udisk_init(); } void usbh_msc_stop(struct usbh_msc *msc_class) { udisk_exit(); }
-
保存配置并编译、烧录程序。注:
烧写前务必确保 USB-SW 跳线帽没有短接,否则无法进入烧录模式。
- 断开电源,接入 U 盘,短接 USB-SW(如有),上电后检查 U 盘识别状态。注:
对于没有 USB-SW 排针的开发板,无需再做处理。
-
执行下列命令:
注:若使用手动挂载,则在此时执行 mount udick /udick elm 命令。
list_device
如出现以下设备信息,表明系统已识别 U 盘:
device type ref count -------- -------------------- ---------- ... udisk Block Device 1 ...
- 进入 U
盘目录,查看文件:
cd udisk
ls
Directory /udisk: System Volume Inform<DIR> D21x <DIR> ARTINCHIP.PPT 4814660
完成以上步骤后,U 盘已经挂载完成。