FSL-UT-USB-045-USB-Device-Host-Only-Test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[cols=">s,6a",frame="topbot",options="header"]
|====================================================================
|Name | Description

| Summary |
Test peripheral-only and host-only mode by building out other driver

| Automated |
No

| Kernel Config Option |

| Software Dependency |
N/A

| Non-default Hardware Configuration |
N/A

| Test Procedure |
Build out other driver through make menuconfig

1. Test host-only driver
1.1 Rebuild kernel
# modprobe -r ci_hdrc_imx; modprobe -r phy_mxs_usb; modprobe phy_mxs_usb && modprobe ci_hdrc_imx
try if peripheral function is ok, the g_serial should not be inserted.

1.2 Hotplug test in low power status without host wakeup support
# echo mem > /sys/power/state
Plugin u-disk into Host/OTG port
Resume system by POWER switch and the u-disk should be found
For ARD, use console wakeup
# echo mem > /sys/power/state
Plugout u-disk from Host/OTG port
Resume system by POWER switch and the u-disk detach disconnet should be noticed
Repeat this step 3 times
1.3 USB mouse remote wakeup test
Connect USB mouse to Host/OTG port
# low_power_usb.sh; echo mem > /sys/power/state
Click USB mouse to wakeup system
Repeat this step to verify system can suspend/resume again
1.4 Connect/disconnect wakeup
# low_power_usb.sh; echo mem > /sys/power/state
Plugin or plug out USB device from Host/OTG,
System should be wakeup
1.5 Special for OTG port
# echo mem > /sys/power/state
Then only plugin a microAB to female A cable(without device) to OTG port
The system should NOT be wakeup
Resume board by POWER switch and
# echo mem > /sys/power/state
Connect OTG port to PC
The system should NOT be wakeup

2 Test peripheral-only driver
2.1 boot from rebuilt kernel and connect usb mouse at the board
# modprobe -r ci_hdrc_imx; modprobe -r phy_mxs_usb; modprobe phy_mxs_usb && modprobe ci_hdrc_imx
The mouse should not be recognized.

2.2 Test g_mass_storage module
In board
# dd if=/dev/zero of=/var/storage.img bs=1M count=64
# mkfs.vfat /var/storage.img
# modprobe g_mass_storage file=/var/storage.img removable=1
In Host PC:
# mkdir -p /mnt/flash
# umount /mnt/flash
# mount -t vfat /dev/sdxx /mnt/flash (sdxx is the partition exported by g_file_storage in target board whose size is near 64M)
# bonnie++ -d /mnt/flash -u 0:0 -s 32 -r 16
# dt of=/mnt/flash/test_file bs=4k limit=63m passes=20
Above commands should pass
In board:
# modprobe -r g_mass_storage
# modprobe -r ci_hdrc_imx; modprobe -r phy_mxs_usb
Remove the USB cable from OTG port
2.3 Repeat above steps

2.4 Wakeup test
the ID change should not wake up system
2.4.1 dd if=/dev/zero of=/var/storage.img bs=1M count=64
2.4.2 mkfs.vfat /var/storage.img
2.4.3 modprobe g_mass_storage file=/var/storage.img removable=1
2.4.4 Enable wakeup setting: usb_wakeup.sh

#/bin/sh
	for i in $(find /sys -name wakeup | grep usb)
	do
		echo enabled > $i
		echo "echo enabled > $i"
	done
2.4.5 suspend system, echo mem > /sys/power/suspend
2.4.6 plug in Micro-AB cable should not wakeup system
2.4.7 wakeup system through serial port, nothing should be happened
for usb otg port.

| Expected Result |
There should be no error during the test

|====================================================================

<<<
