Please refer to the section "Device mode (Gadget driver)" in page 460 in LSDK 20.12 user manual.
Please configure Linux Kernel as the following.
USB Gadget support --->
<M> USB Gadget functions configurable through
configfs
[*] Mass storage
<M> USB Gadget precomposed configurations
<M> Mass Storage Gadget
Device Tree update, change property dr_mode’s data from “host” to “peripheral”, add property maximum-speed = “super-speed”;
as below:
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”;
};
On the target board, insert Kernel modules.
root@ls1043a:/run/media/mmcblk0p1/ # dd if=/dev/zero of=./test bs=1M count=500
root@ls1043a:/run/media/mmcblk0p1/ # insmod libcomposite.ko
root@ls1043a:/run/media/mmcblk0p1/ # insmod usb_f_mass_storage.ko
root@ls1043a:/run/media/mmcblk0p1/ # insmod g_mass_storage.ko file=/run/media/mmcblk0p1/test
Connect USB cable with PC and RDB board, you can see Windows Device Manager as Linux File-Stor Gadget USB Drive.