The usblauncher service enumerates USB devices, launches drivers for communicating with USB devices,
and publishes device information through PPS.
This utility depends on the following services:
- io-usb
-
The USB host stack, which monitors the USB hardware and notifies usblauncher of device
attachments and detachments. The usblauncher service runs io-usb
to act as the USB host, which means it controls communication on the bus.
- Drivers for USB host mode
-
When running the USB host stack (io-usb), usblauncher
can start different drivers to communicate with different types of devices.
The simplest use case is when a user plugs in a mass-storage device, in which case usblauncher
starts a devb-umass driver to communicate with it;
if a device has multiple partitions, one such driver manages all of the device's filesystems.
Other drivers that may be used in host mode include mm-ipod, io-pkt with
a USB Ethernet driver, devc-serusb, and others.
- io-usb-dcd
-
The USB device stack, which notifies usblauncher of state changes such as a device configuration
update or a cable removal. The usblauncher service runs io-usb-dcd
to act as the USB device, which means it services requests from the USB host.
- Drivers for USB device mode
-
After starting the USB device stack (io-usb-dcd),
usblauncher immediately starts the appropriate driver based on the device properties
provided by the stack. For instance,
the devc-serusb_dcd driver enables serial data transfer
(see "USB descriptors", which explains the USB-to-serial communication configured in
usbser.lua).
The devu-umass_client-block driver supports mass storage devices when the stack runs in
device mode. Other drivers that may be used in device mode include mm-ipod,
io-pkt with usbdnet, and others.
Benefits of usblauncher
The multipurpose usblauncher utility allows for a simple system setup and provides these benefits:
- Drivers can be started immediately
- Because usblauncher launches the USB drivers, it knows immediately whether a newly attached
device is supported (i.e., if the system has a suitable driver for the device's type).
Thus, when creating a PPS device object, usblauncher can publish the number of drivers
it will start for the device; this lets applications subscribed to this PPS object know right away whether
the device is supported.
- Automatic filesystem mounting
- The usblauncher utility can mount the filesystems of USB devices based on the rules
in the mcd mountpoint file (/etc/mcd.mnt by default).
Also, usblauncher can publish the statuses of mount operations to inform
applications whether individual filesystems were successfully mounted.
Note:
If your system setup requires it, you can still use
mcd to mount USB filesystems while
running
usblauncher. For information on how to do this, see
"Disabling usblauncher auto-mounter".
- Support for MirrorLink
- A smartphone must have a Network Configuration Management (NCM) interface to make its applications accessible
through a car infotainment system with MirrorLink.
The usblauncher utility can request that a smartphone re-enumerate itself as an NCM device.
This way, the user doesn't have to manually configure their smartphone for MirrorLink mode.
- Support for Apple CarPlay
- The usblauncher utility can request a device to become the USB host, to support
Apple CarPlay (formerly known as iOS in the Car). When this role-swapping request succeeds,
usblauncher can stop the USB host stack and start the USB device stack (and do its own
role-swapping). The usblauncher utility can also probe a device to test whether it
supports iAP2, allowing you to choose a driver to launch based on the test's outcome.
Architecture
Figure 1. Architecture of usblauncher
The arrows between components in Figure 1 show information flow.
When USB devices are attached or detached, they trigger hardware interrupts that controllers within the USB stack
(either io-usb or io-usb-dcd) detect. These controllers then react to the
device event by notifying usblauncher.
Note:
By default,
usblauncher starts the USB stack in host mode, assuming you've defined the
host and device stack rules in the configuration file.
You can prevent the host stack from starting by using the
-h command option, which is useful when your setup allows you to run the first stack instance
in device mode.
The usblauncher service queries the stack to retrieve the descriptors (i.e., properties) of
any newly attached devices and then publishes this information to device objects. Next, usblauncher
compares these descriptors against the USB device-matching rules in its configuration file. When it finds a match,
usblauncher launches the appropriate driver (e.g., devb-umass,
devc-serusb) and publishes the driver's information to a driver object.
To mount filesystems, usblauncher sends mount requests to the drivers that manage the paths in
/dev for USB devices. The mountpoints requested by usblauncher are based on
the rules in the specified mountpoint file (for details, see the -M option for usblauncher).
Finally, usblauncher communicates with the drivers to obtain mount information, which it writes into
mount objects. Subscribed applications receive updates through PPS when device information changes.