Use eMMC as a USB Storage Device on IMX8ULP EVK9

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Use eMMC as a USB Storage Device on IMX8ULP EVK9

ソリューションへジャンプ
2,388件の閲覧回数
YashParekh
Contributor III

Hello,

I am using the IMX8ULP EVK9 board and have created a partition (mmcblk0p3) mounted at /mnt/data/.
Here is the current output of lsblk:

root@imx8ulp-9x9-lpddr4-evk:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 83.2M 0 part
|-mmcblk0p2 179:2 0 1.5G 0 part /
`-mmcblk0p3 179:3 0 19M 0 part /mnt/data
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk

 

Now, I would like to connect the board to my PC via USB and expose the mmcblk0p3 partition as a storage device so that I can copy files to and from it.

Could you please guide me on the steps needed to achieve this?

Thanks,
Yash Parekh

ラベル(1)
0 件の賞賛
返信
1 解決策
2,267件の閲覧回数
YashParekh
Contributor III

Hi,

On the IMX8ULP EVK9, I’m able to use eMMC as a USB mass storage device using the following steps:

modprobe libcomposite
cd /sys/kernel/config/usb_gadget/

mkdir g1
cd g1

# Basic device descriptor info
echo 0x1d6b > idVendor  # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB

mkdir strings/0x409
echo "1234567890" > strings/0x409/serialnumber
echo "NXP" > strings/0x409/manufacturer
echo "i.MX8ULP Mass Storage" > strings/0x409/product

# Create configuration
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "Mass Storage Config" > configs/c.1/strings/0x409/configuration

# Add mass storage function
mkdir functions/mass_storage.0
echo 1 > functions/mass_storage.0/stall
echo 0 > functions/mass_storage.0/lun.0/ro
echo 0 > functions/mass_storage.0/lun.0/nofua
echo /dev/mmcblk0p3 > functions/mass_storage.0/lun.0/file

# Bind the function to the config
ln -s functions/mass_storage.0 configs/c.1/

# Bind USB device to UDC
ls /sys/class/udc  # This gives you the UDC name, like 49000000.usb
echo ci_hdrc.0 > UDC

 

This works fine on the EVK and my PC detects the USB storage.

However, on my custom board, I follow the exact same steps but USB storage is not detected on the PC.

My custom board only connects USB D+, D-, and USB_ID lines. I have set USB_ID with a pull-up. On the EVK, they also have USB_VBUS_DETECT and USB_OC pins, but in my custom board those pins are floating and not used.

Do I need to modify the Yocto Device Tree (DTS) to ignore or disable the USB_VBUS_DETECT and USB_OC pins?

Here is my current USB node in the DTS:

&usbotg1 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&pinctrl_otgid1>;
    pinctrl-1 = <&pinctrl_otgid1>;
    dr_mode = "otg";
    hnp-disable;
    srp-disable;
    adp-disable;
    over-current-active-low;
    status = "okay";
};

 

Do I need to update anything else in the DTS or kernel to make this work on my custom board?

Thanks in advance!

Regards
Yash Parekh

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
2,355件の閲覧回数
Harvey021
NXP TechSupport
NXP TechSupport

Hi,

Hope the one can help - Solved: g_mass_storage windows seeing something different - NXP Community

 

Regards

Harvey

0 件の賞賛
返信
2,268件の閲覧回数
YashParekh
Contributor III

Hi,

On the IMX8ULP EVK9, I’m able to use eMMC as a USB mass storage device using the following steps:

modprobe libcomposite
cd /sys/kernel/config/usb_gadget/

mkdir g1
cd g1

# Basic device descriptor info
echo 0x1d6b > idVendor  # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB

mkdir strings/0x409
echo "1234567890" > strings/0x409/serialnumber
echo "NXP" > strings/0x409/manufacturer
echo "i.MX8ULP Mass Storage" > strings/0x409/product

# Create configuration
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "Mass Storage Config" > configs/c.1/strings/0x409/configuration

# Add mass storage function
mkdir functions/mass_storage.0
echo 1 > functions/mass_storage.0/stall
echo 0 > functions/mass_storage.0/lun.0/ro
echo 0 > functions/mass_storage.0/lun.0/nofua
echo /dev/mmcblk0p3 > functions/mass_storage.0/lun.0/file

# Bind the function to the config
ln -s functions/mass_storage.0 configs/c.1/

# Bind USB device to UDC
ls /sys/class/udc  # This gives you the UDC name, like 49000000.usb
echo ci_hdrc.0 > UDC

 

This works fine on the EVK and my PC detects the USB storage.

However, on my custom board, I follow the exact same steps but USB storage is not detected on the PC.

My custom board only connects USB D+, D-, and USB_ID lines. I have set USB_ID with a pull-up. On the EVK, they also have USB_VBUS_DETECT and USB_OC pins, but in my custom board those pins are floating and not used.

Do I need to modify the Yocto Device Tree (DTS) to ignore or disable the USB_VBUS_DETECT and USB_OC pins?

Here is my current USB node in the DTS:

&usbotg1 {
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&pinctrl_otgid1>;
    pinctrl-1 = <&pinctrl_otgid1>;
    dr_mode = "otg";
    hnp-disable;
    srp-disable;
    adp-disable;
    over-current-active-low;
    status = "okay";
};

 

Do I need to update anything else in the DTS or kernel to make this work on my custom board?

Thanks in advance!

Regards
Yash Parekh

0 件の賞賛
返信
2,246件の閲覧回数
Harvey021
NXP TechSupport
NXP TechSupport

Hi,

This will be another issue, please raise a new ticket for further support.

 

Regards

Harvey

0 件の賞賛
返信
2,234件の閲覧回数
YashParekh
Contributor III

Hi,

 

Okay, i will raise new ticket for this issue.

 

Thanks,

Yash Parekh

0 件の賞賛
返信