USB host

USB Host refers to a system or hardware capable of controlling and managing USB devices. It provides power, data transfer, and management functions for connected USB devices such as flash drives, keyboards, and mice.

The Quectel Pi H1 single-board computer comes with two standard USB 2.0 Type-A ports and one USB 3.1 Type-C port, compatible with USB 2.0. The maximum data transfer rate of the USB 2.0 ports is 480 Mbps, while the USB 3.1 port can reach up to 5 Gbps.

Hardware Connection

To test the HOST mode functionality of the USB ports, we can check the basic functionality of devices connected to the USB ports and the read/write speed of flash drives.

Basic Functionality

View All Input Devices

cat /proc/bus/input/devices

This will list all input devices currently recognized by the system.

Example output:

I: Bus=0000 Vendor=0000 Product=0000 Version=0001
N: Name="pm8xxx_vib_ffmemless"
P: Phys=
S: Sysfs=/devices/platform/soc@0/c440000.spmi/spmi-0/0-09/c440000.spmi:pmic@9:pm7250b-vib@5300/input/input0
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=200001
B: FF=107030000 0

Name:Device name (e.g., mouse or keyboard)

Handlers:The event interface corresponding to the device

Use lsusb to View USB Devices

Connect devices such as card readers, mice, or keyboards to the USB ports and test whether the devices are recognized and functional by plugging and unplugging them.

No external devices connected

Use the lsusb command to check the devices currently recognized by the system.

Example terminal output:

Example output:

Bus 001 Device 002: ID 1a86:8091 QinHeng Electronics USB HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

With External Devices Connected

Connect devices such as a keyboard or mouse to the USB ports, and use the lsusb command to check if new devices appear.

Example terminal output: USB ports recognize the connected keyboard and mouse.

Bus 001 Device 005: ID 17ef:6099 Lenovo Lenovo Traditional USB Keyboard
Bus 001 Device 004: ID 17ef:608d Lenovo Optical Mouse
Bus 001 Device 002: ID 1a86:8091 QinHeng Electronics USB HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Use dmesg to view the system log for inserted devices.

sudo dmesg | tail -n 20

Check the most recent 20 kernel log entries to observe device insertion/removal or driver loading.

USB Flash Drive Read/Write

Connect a USB flash drive to the USB port and use the dd command to test its read/write speed.

Confirm the Storage Device

Use the lsblk command to identify the device name of the USB flash drive.

lsblk

Example terminal output:


sda       8:0    0 116.1G  0 disk
|-sda1    8:1    0   512M  0 part /efi
|-sda2    8:2    0    30M  0 part /var/persist
`-sda3    8:3    0 115.6G  0 part /
sdb       8:16   0     8M  0 disk
|-sdb1    8:17   0   3.5M  0 part
|-sdb2    8:18   0   512K  0 part
`-sdb3    8:19   0   3.5M  0 part
sdc       8:32   0     8M  0 disk
|-sdc1    8:33   0   3.5M  0 part
|-sdc2    8:34   0   512K  0 part
`-sdc3    8:35   0   3.5M  0 part
sdd       8:48   0    32M  0 disk
|-sdd1    8:49   0   104K  0 part
|-sdd2    8:50   0   128K  0 part
|-sdd3    8:51   0     1M  0 part
|-sdd4    8:52   0     1M  0 part
`-sdd5    8:53   0     1M  0 part
sde       8:64   0     3G  0 disk
|-sde1    8:65   0   512K  0 part
|-sde2    8:66   0    64M  0 part
|-sde3    8:67   0   256K  0 part
|-sde4    8:68   0     2M  0 part
|-sde5    8:69   0     5M  0 part
|-sde6    8:70   0     4M  0 part
|-sde7    8:71   0     8M  0 part
|-sde8    8:72   0     4M  0 part
|-sde9    8:73   0    32M  0 part
|-sde10   8:74   0   128K  0 part
|-sde11   8:75   0    80K  0 part
|-sde12   8:76   0     2M  0 part
|-sde13   8:77   0     2M  0 part
|-sde14   8:78   0   128K  0 part
|-sde15   8:79   0    32K  0 part
|-sde16 259:0    0     1M  0 part
|-sde17 259:1    0   256K  0 part
|-sde18 259:2    0   512K  0 part
|-sde19 259:3    0   256K  0 part
|-sde20 259:4    0    64M  0 part
|-sde21 259:5    0     2M  0 part
|-sde22 259:6    0     5M  0 part
|-sde23 259:7    0     4M  0 part
|-sde24 259:8    0     8M  0 part
|-sde25 259:9    0     4M  0 part
|-sde26 259:10   0    32M  0 part
|-sde27 259:11   0   128K  0 part
|-sde28 259:12   0    80K  0 part
|-sde29 259:13   0     2M  0 part
|-sde30 259:14   0     2M  0 part
|-sde31 259:15   0   128K  0 part
|-sde32 259:16   0    32K  0 part
|-sde33 259:17   0     1M  0 part
|-sde34 259:18   0   256K  0 part
|-sde35 259:19   0     4K  0 part
|-sde36 259:20   0     4K  0 part
|-sde37 259:21   0     4K  0 part
|-sde38 259:22   0    16M  0 part
|-sde39 259:23   0    30M  0 part
|-sde40 259:24   0     1M  0 part
|-sde41 259:25   0  32.6M  0 part
|-sde42 259:26   0     4K  0 part
|-sde43 259:27   0     4K  0 part
|-sde44 259:28   0     1M  0 part
|-sde45 259:29   0     8M  0 part
|-sde46 259:30   0    40M  0 part
|-sde47 259:31   0   512M  0 part
|-sde48 259:32   0    28K  0 part
|-sde49 259:33   0   512K  0 part
|-sde50 259:34   0     1M  0 part
`-sde51 259:35   0  32.6M  0 part
sdf       8:80   0    32M  0 disk
|-sdf1    8:81   0     3M  0 part
|-sdf2    8:82   0     3M  0 part
|-sdf3    8:83   0     3M  0 part
`-sdf4    8:84   0   128K  0 part
sdg       8:96   1   7.5G  0 disk
`-sdg1    8:97   1   7.5G  0 part /mnt/sdcard1
zram0   253:0    0   3.8G  0 disk [SWAP]

Here, sdg is the current USB flash drive device name; replace it with the actual device name as appropriate.

Test Write Performance

sudo dd if=/dev/zero of=/dev/sdg bs=1M count=100
  • dd : A command-line tool in Linux used to copy and convert files.

  • if=/dev/zero : Specifies the input file as /dev/zero, a special file that provides an infinite stream of zero bytes.

  • of=/dev/sdg : Specifies the output file as /dev/sdg, i.e., the USB flash drive device.

  • bs=1M : Sets the block size to 1 MB.

  • count=100 : Specifies copying 100 blocks.

This command writes 100 MB of zero-byte data to the USB flash drive and displays the write speed.

Example terminal output:

100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.0367901 s, 2.9 GB/s

Test Read Performance

sudo dd if=/dev/sdg of=/dev/null bs=1M count=100
  • dd : A command-line tool in Linux used to copy and convert files.

  • if=/dev/sda : Specifies the input file as /dev/sda, i.e., the USB flash drive device.

  • of=/dev/null : Specifies the output file as /dev/null, a special file that discards all written data.

  • bs=1M : Sets the block size to 1 MB.

  • count=100 : Specifies copying 100 blocks.

This command reads 100 MB of data from the USB flash drive to /dev/null and displays the read speed.

Example terminal output:

100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 4.97715 s, 21.1 MB/s