- Linux
- NVIDIA Tegra based Modules
The USB (Universal Serial Bus) standard specifies two roles USB host and USB peripheral (also known as USB function, USB peripheral device or sometimes just USB device). The bus can only have one USB host connected all other devices need to be in USB peripheral mode. Most PCs support USB host mode exclusively. However, embedded systems often have multiple USB controller supporting host or peripheral roles or supporting both roles on a single controller (dual-role controller). The dual-role controllers often also support the OTG (On-The-Go) specification which defines a host negotiation protocol allowing two devices to negotiate for the role of the host.
On Colibri modules the client port (USBC) is usually connected to a dual-role capable controller. By default the port is in peripheral mode. If a USB Micro-B OTG cable is used (which connects the ID pin to ground) the circuit on the carrier board automatically enables driving +5V onto VBUS in order to provide power to USB devices as required by a host. On the other hand VBUS is also connected to the Colibri USBC_DET signal (usually via a diode) allowing driver software to monitor and subsequently change the role. On Apalis modules a full OTG port (USBO1) is provided which makes use of the OTG ID pin using the USBO1_ID signal to determine its role and additionally the VBUS pin using the USBO1_VBUS signal to determine the actual connection status thereof allowing suspending the USB complex if not connected.
On Linux USB peripheral mode is supported through the Gadget API. This API abstracts the USB peripheral controller hardware as well as offers hardware neutral routines which allow to implement USB functions (e.g. USB CDC ACM or RNDIS). Traditionally the USB function had to be chosen at Kernel compile time (e.g. g_ether). The Linux USB gadget drivers received increasingly more attention and have evolved over time, especially since Android appeared. The Android variant of the Linux kernel added functionality allowing easy switching between USB functions using sysfs. Later in Linux 3.10 a similar functionality also landed in the upstream kernel which now allows configuring USB gadgets through configfs (the USB Gadget ConfigFS). Depending on the Linux kernel version provided by our BSP a different level of USB peripheral functionality and API is available.
Well, HP LaserJet M1120n Multifunction software and Drivers play an important role in regards to functioning the gadget. With Drivers for HP LaserJet M1120n Multifunction mounted on the windows or mac computer, individuals have complete access as well as the alternative for making use of HP LaserJet M1120n Multifunction functions. Added an Install Mode to the Multifunction Composite Gadget. This mode makes the gadget appear as a mass storage device with first logical unit simulating CD-ROM until an eject on that logical unit is requested because then gadget switches to the 'full flagged' gadget. The intend is that in Install Mode the gadget will provide only. Installing the Drivers 2. Select Canon MX920 series with Canon IJ Network listed in the Kind column.CAUTION If you will be installing the Canon printer driver on Mac OS X and using the printer through a network connection, you can select Bonjour or Canon IJ Network in the Add Printer dialog. This patch FunctionFS, Mass Storage and Multifunction gadgets use the new features of composite framework. Because it handles default strings there is no longer the need for the gadgets drivers to handle many of the strings. This also adds the 'needsserial' to Mass Storage Gadget and Multifunction Composite Gadget which makes composite issue.
USB peripheral devices need a vendor and product identification. Toradex has its own vendor ID (0x1b67) and assigns a product ID for each Colibri and Apalis product which you as a customer can use too. The USB Product ID is the sum of an offset of 0x4000 and the hexadecimal representation of the product identifier, e.g. 0x4000 + 12 = 0x400c (the product identifier is the first 4 digits of the Toradex Product Number, e.g. 0012 for Colibri VF61 256MB IT V1.1B).
Some platforms need device dependent and certified drivers (e.g. CDC ACM for Microsoft Windows) even for standard USB classes. While it is possible to use the driver delivered with Windows a custom inf file still needs to be provided. For better out-of-the-box experience the standard images typically use the default Linux USB product/vendor ID (e.g. 1d6b:0104 Linux Foundation Multifunction Composite Gadget).
U-Boot's CONFIG_USB_DEVICE config symbol allows for U-Boot to provide USB peripheral mode support. With recent versions we successfully tested ums (User Mode Storage) and dfu (Device Firmware Upgrade). Both USB functions conform to standardized USB classes.
Since BSP V2.4 all modules use the same U-Boot version 2015.04. This common U-Boot version configures the USB peripheral device identification using the Toradex vendor ID and product ID.
The following exports the eMMC on SoMs with an eMMC or the SD card on the SoMs with raw NAND. Note that with CTRL+C you can abort the operation and regain control over U-Boot.
On the host connected to the SoM you will now see the following USB device. Assuming you have our regular BSP installed on an eMMC based SoM the following block devices will also appear and possibly mounted:
Note that ums currently can only export the user area of an eMMC but not its boot areas. This prevents you from updating the bootloader over this mechanism.
NXP/Freescale Vybrid/i.MX7/i.MX6ULL/i.MX6/i.MX8/i.MX8X based Modules
The NXP/Freescale Vybrid BSP (since V2.4 Beta 1) and the i.MX BSP (since V2.5 Beta 2) use the USB Gadget ConfigFS to configure the USB peripheral port.
The USB Gadget ConfigFS is a file system which allows to configure USB functions by using file system commands such as mkdir and creating/writing files. Typically the file system is mounted under /sys/kernel/config/. The official Linux kernel documentation has more information in Documentation/usb/gadget_configfs.txt on how to use the file system to enable USB functions. Matt Porter held a talk at ELC 2014 titled Kernel USB Gadget Configfs Interface cover the Gadget ConfigFS a bit more in depth.
The library libusbgx (or its predecessor libusbg) allows to use the USB Gadget ConfigFS through a C API. This can be useful if embedded software needs to dynamically control USB functions provided by a device. The library also provides two utilities called gadget-import and gadget-export. This utilities allow to export a hand-crafted USB Gadget to a schema file and reimport it.
The BSP provides a default schema specifying an RNDIS configurations (USB functions) under /etc/usbg/g1.schema. A systemd service called usbg.service uses gadget-import to import this schema on startup (see this commit libusbg: add updated version of USB gadget library which initially added the functionality, then providing an RNDIS and CDC ACM composite device).
To alter the schema, one can either create a completely new gadget schema, alter the existing gadget and reexport it, or alter the schema directly (for simple changes).
This example shows how to create a completely new configuration., to create a Gadget configuration for the a single USB CDC (Communications Device Class) Ethernet (ECM).
First a new gadget needs to be created
Attention: If /sys/kernel/config/usb_gadget/ does not exist you need to load the libcomposite module: modprobe libcomposite
Then, one or multiple configurations can be assigned. A Gadget supporting multiple configurations (USB functions) is also known as a composite gadget. Note that depending on the operating system used on the USB host device, it might be problematic to use such configurations (see also Documentation/usb/gadget_multi.txt)
Functions can be created by creating a directory like functions/ Another example how to create a mass storage device: The Gadget testing documentation located at Documentation/usb/gadget-testing.txt of the Linux kernel also contains some valuable information how to use the USB Gadget functions. To enable this configuration write the name of the USB controller to the UDC file (see /sys/class/udc/ for available USB Device Controllers). You need to disable the old configuration first before enabling the new one: Don't forget to store the configuration using gadget-export: To make sure the g2 Gadget configuration gets loaded automatically, alter the systemd service located at /lib/systemd/system/usbg.service or name the schema g1.schema. Starting with our V2.x BSPs based on NVIDIA's L4T kernel we are using the Android multi gadget driver which allows various functionality to be exposed via a single USB device cable connection. USB Mass Storage allows exporting any block device from the target module to a PC and use it just in the same way as any regular USB memory stick. Note: Whatever block device you export by using this method, it can not be in use on the target module side (e.g. by a file system driver). Otherwise the simultaneously accessing file system drivers would corrupt the file system on the block device! The example below shows how a regular SD card inside one of the Apalis Evaluation board's slots can be shared: The Vibrante kernel in our V1.x BSPs contained the g_ether driver which acts as an Ethernet over USB controller (CDC Ethernet) by default. The later L4T kernel in our V2.x BSPs comes with the Android RNDIS Ethernet gadget driver. Most nowadays operating system (including Linux, Windows 7) include respective host drivers (plug and play). Our latest BSPs now run a DHCP server on the module to automatically assign your PC an IP address upon USB device connection. Configure IP address on device usb0 and test performance using iperf. RNDIS support allows a PC to talk to a Linux-based embedded system over USB by making the embedded system look like a USB attached Ethernet adapter. In order to enable this feature, you must first enable RNDIS in your Linux kernel. This involves compiling the kernel, which is described elsewhere in this wiki. Start the Linux Kernel Configuration tool: $ make CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm menuconfig Select Device Drivers from the main menu. Select USB support as shown here Go to USB Gadget Support as shown here Select Inventra HDRC USB Peripheral as shown here Select Ethernet Gadget as shown here Once this is done, save the configuration and compile the kernel and modules. RNDIS gadget driver module can be inserted using $ insmod g_ether.ko You can, alternatively, change the <M> for USB Gadget Drivers to <*> and this will compile the drivers into the kernel, so you won't have to load the module. You will need to first de-select all child modules under USB Gadget Drivers, then press space bar over USB Gadget Drivers to change the <M> to a <*>. The RNDIS Gadget driver will create an Ethernet device by the name usb0. You need to assign an IP address to the device and bring up the device. The typical command for that would be: This command will start up the Ethernet link with the listed IP_ADDR IP address. Unfortunately, the PC will try to get a DHCP address and when it fails it will use a default IP address that will likely not be on the same subnet as the one you choose for IP_ADDR. One way to solve this is to set up a DHCP server on the ARM. Busybox includes udhcpd, which is a DHCP server. To set this up you need to do a few things... First, create a udhcpd.conf file in /etc. This file sets the IP address and range which will be used to give addresses to clients (the PC). As a minimum, you will need a start address. Here is an example of this file: start 10.199.199.100 You will then need to tell Linux to start up the DHCP server on bootup. systemd makes starting up dhcp very difficult -- I have not figured out how to do that... Here is the approach I used: Create /etc/network/if-up.d/start_udhcpd with the following contents: #!/bin/sh Next create /etc/network/if-down.d/stop_dhcp with the following contents: #!/bin/sh Now, in your application start script (where you typically load drivers and the FPGA), add the following: ifdown usb0 Now, when you run your start script, dhcp will run.ecm Ethernet Control Model (CDC ECM) Ethernet Control Model eem Ethernet Emulation Model (EEM) Newer USB Ethernet standard that is somewhat simpler than CDC ECM ncm Network Control Model (CDC NCM) Advanced protocol for Ethernet ffs Function filesystem (FunctionFS) Allows to implement USB functions from user-space (e.g. for MTP) Documentation/usb/functionfs.txt mass_storage Mass storage Exports a regular file or block device as USB Mass Storage disk drive Documentation/usb/mass-storage.txt hid HID function Generic emulation of USB Human Interface Devices (HID) Documentation/usb/gadget_hid.txt NVIDIA Tegra based Modules
Mass Storage
Target
Host
RNDIS
USB Device Connection
Target (USB Device)
Host (USB Device)
USB Device Disconnect
$ ifconfig usb0 <IP_ADDR> netmask 255.255.255.0 up
end 10.199.199.102
option subnet 255.255.255.0
interface usb0
lease_file /tmp/udhcpd.leasesDrivers Multifunction Gadget With Multiple Configurations Pdf
if [ $IFACE usb0 ] && [ $MODE start ]
then
touch /tmp/udhcpd.leases
/usr/sbin/udhcpd /etc/udhcpd.conf
fiDrivers Multifunction Gadget With Multiple Configurations For A
if [ $IFACE usb0 ] && [ $MODE stop ]
then
pkill udhcpd
fi
exit 0Drivers Multifunction Gadget With Multiple Configurations List
ifup usb0Drivers Multifunction Gadget With Multiple Configurations Using