How to use g_mass_storage module


New here and I would like to use my VIM2 as USB flash disk for my Tesla,
current EMMC image is ubuntu server with kernel 4.9.29

I have built a kernel with USB gadget mass storage and was able to load using modprobe g_mass_storage file=/usb.bin stall=0 ro=1 remoable=y but nothing showed in my windows laptop.

Can anyone direct me on how to do it, please?


@majedalanni hello, maybe @hyphop can help you .

  1. make proper kernel and modules config with USB_GADGET support, rebuild kernel and install
  2. change dtb/dts for change usb mode from HOST to DEVICE

NOTE: vendor kernel 4.9.29 dts

&dwc2_a {
	status = "okay";
	/** 0: normal, 1: otg+dwc3 host only, 2: otg+dwc3 device only*/
	controller-type = <3>;

NOTE: mainline kernel need some patches u can get workable kernel and dts with USB_GADGET there

NOTE: dont forget change kbi portmode from PCIE to USB !!!


as I’m already have kernel complied, I have edit the dtb file
Convert dtb to dts

cd /boot/dtb
sudo dtc -I dtb -O dts -o kvim2_linux.dts kvim2_linux.dtb

sudo vi kvim2_linux.dts (change controller to type 2)

recompile dts to dtb

sudo mv kvim2_linux.dtb kvim2_linux.dtb.bak
sudo dtc -O dtb -o kvim2_linux.dtb kvim2_linux.dts

sudo reboot

now sudo modproge g_mass_storage parameters is working... 

BTW first time doing these stuff :slight_smile: 
Thanks a lot