Hi:
I use the cmds as follows to mount SSD as USB device,so i can transfer documentions from PC to my board.
However,when they are transfering files,if I pull out the USB cable,the USB module will die on my board.
I can't use 'rmmod' to remove the 'g_mass_storage' module,and the rmmod will also die in exiting.
How can i solve this probelm without rebooting?
Configure Tree View Options Description
USB Gadget support --->
<M> USB Gadget functions configurable through configfs
[*] Mass storage
<M> USB Gadget precomposed configurations
<M> Mass Storage Gadget
dts configuration
usb0: usb3@2f00000 {
compatible = "snps,dwc3";
reg = <0x0 0x2f00000 0x0 0x10000>;
interrupts = <0 60 0x4>;
dr_mode = "peripheral";
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
maximum-speed = “super-speed”;
};
# dd if=/dev/zero of=./test bs=1M count=500
# insmod libcomposite.ko
# insmod usb_f_mass_storage.ko
# insmod g_mass_storage.ko file=test
Attach the USB cable between target board and Linux host machine
A new external hard drive appears on the host. You may now use the host's tools to initialize and format the drive, and write data to it. To avoid data loss or corruption, make sure to unmount the drive from the host to safely remove it when finished. You can then unload the mass storage driver:
E.g;
root@xiao:~#fdisk /dev/sdc
root@xiao:~# mkfs.ext2 /dev/sdc1
root@xiao:~# mount /dev/sdc1 /mnt
root@xiao:~# dd if=/dev/zero of=src_img bs=1M count=10
root@xiao:~# cp src_img /mnt