blob: 6e46345cab839ef23aca7d1c14a08546946f197e [file] [log] [blame]
wdenke2211742002-11-02 23:30:20 +00001/*
2 * (C) Copyright 2001
3 * Denis Peter, MPL AG Switzerland
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenke2211742002-11-02 23:30:20 +00006 */
7
Heiko Schocher20280122017-06-27 16:49:14 +02008USB Support
9===========
wdenke2211742002-11-02 23:30:20 +000010
11The USB support is implemented on the base of the UHCI Host
12controller.
13
Simon Glass1e9961d2011-02-16 11:14:33 -080014Currently supported are USB Hubs, USB Keyboards, USB Floppys, USB
15flash sticks and USB network adaptors.
wdenke2211742002-11-02 23:30:20 +000016Tested with a TEAC Floppy TEAC FD-05PUB and Chicony KU-8933 Keyboard.
17
18How it works:
19-------------
20
21The USB (at least the USB UHCI) needs a frame list (4k), transfer
22descripor and queue headers which are all located in the main memory.
23The UHCI allocates every milisecond the PCI bus and reads the current
24frame pointer. This may cause to crash the OS during boot. So the USB
25_MUST_ be stopped during OS boot. This is the reason, why the USB is
26NOT automatically started during start-up. If someone needs the USB
27he has to start it and should therefore be aware that he had to stop
28it before booting the OS.
29
30For USB keyboards this can be done by a script which is automatically
31started after the U-Boot is up and running. To boot an OS with a an
32USB keyboard another script is necessary, which first disables the
33USB and then executes the boot command. If the boot command fails,
34the script can reenable the USB kbd.
35
36Common USB Commands:
37- usb start:
38- usb reset: (re)starts the USB. All USB devices will be
39 initialized and a device tree is build for them.
40- usb tree: shows all USB devices in a tree like display
41- usb info [dev]: shows all USB infos of the device dev, or of all
42 the devices
43- usb stop [f]: stops the USB. If f==1 the USB will also stop if
44 an USB keyboard is assigned as stdin. The stdin
45 is then switched to serial input.
46Storage USB Commands:
47- usb scan: scans the USB for storage devices.The USB must be
48 running for this command (usb start)
Richard Genoud95be8a32012-11-29 23:18:31 +000049- usb device [dev]: show or set current USB storage device
wdenke2211742002-11-02 23:30:20 +000050- usb part [dev]: print partition table of one or all USB storage
51 devices
52- usb read addr blk# cnt:
53 read `cnt' blocks starting at block `blk#'to
54 memory address `addr'
55- usbboot addr dev:part:
56 boot from USB device
57
58Config Switches:
59----------------
Jon Loeliger1670a5b2007-07-10 11:19:50 -050060CONFIG_CMD_USB enables basic USB support and the usb command
61CONFIG_USB_UHCI defines the lowlevel part.A lowlevel part must be defined
62 if using CONFIG_CMD_USB
wdenke2211742002-11-02 23:30:20 +000063CONFIG_USB_KEYBOARD enables the USB Keyboard
64CONFIG_USB_STORAGE enables the USB storage devices
Simon Glass2dd9bbe2011-06-13 16:13:11 -070065CONFIG_USB_HOST_ETHER enables USB ethernet adapter support
66
67
68USB Host Networking
69===================
70
71If you have a supported USB Ethernet adapter you can use it in U-Boot
72to obtain an IP address and load a kernel from a network server.
73
74Note: USB Host Networking is not the same as making your board act as a USB
75client. In that case your board is pretending to be an Ethernet adapter
76and will appear as a network interface to an attached computer. In that
77case the connection is via a USB cable with the computer acting as the host.
78
79With USB Host Networking, your board is the USB host. It controls the
80Ethernet adapter to which it is directly connected and the connection to
81the outside world is your adapter's Ethernet cable. Your board becomes an
82independent network device, able to connect and perform network operations
83independently of your computer.
84
85
86Device support
87--------------
88
89Currently supported devices are listed in the drivers according to
90their vendor and product IDs. You can check your device by connecting it
91to a Linux machine and typing 'lsusb'. The drivers are in
92drivers/usb/eth.
93
94For example this lsusb output line shows a device with Vendor ID 0x0x95
95and product ID 0x7720:
96
97Bus 002 Device 010: ID 0b95:7720 ASIX Electronics Corp. AX88772
98
99If you look at drivers/usb/eth/asix.c you will see this line within the
100supported device list, so we know this adapter is supported.
101
Wolfgang Denk825223d2011-09-11 21:24:09 +0200102 { 0x0b95, 0x7720 }, /* Trendnet TU2-ET100 V3.0R */
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700103
104If your adapter is not listed there is a still a chance that it will
105work. Try looking up the manufacturer of the chip inside your adapter.
106or take the adapter apart and look for chip markings. Then add a line
107for your vendor/product ID into the table of the appropriate driver,
108build U-Boot and see if it works. If not then there might be differences
109between the chip in your adapter and the driver. You could try to get a
110datasheet for your device and add support for it to U-Boot. This is not
111particularly difficult - you only need to provide support for four basic
112functions: init, halt, send and recv.
113
114
115Enabling USB Host Networking
116----------------------------
117
118The normal U-Boot commands are used with USB networking, but you must
119start USB first. For example:
120
121usb start
122setenv bootfile /tftpboot/uImage
123bootp
124
125
126To enable USB Host Ethernet in U-Boot, your platform must of course
127support USB with CONFIG_CMD_USB enabled and working. You will need to
Chris Packhamf2fe81f2017-08-28 20:50:47 +1200128add some config settings to your board config:
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700129
Chris Packhamf2fe81f2017-08-28 20:50:47 +1200130CONFIG_CMD_USB=y /* the 'usb' interactive command */
131CONFIG_USB_HOST_ETHER=y /* Enable USB Ethernet adapters */
Gerhard Sittig9dc55732014-03-08 19:46:18 +0100132
133and one or more of the following for individual adapter hardware:
134
Chris Packhamf2fe81f2017-08-28 20:50:47 +1200135CONFIG_USB_ETHER_ASIX=y
136CONFIG_USB_ETHER_ASIX88179=y
137CONFIG_USB_ETHER_LAN75XX=y
138CONFIG_USB_ETHER_LAN78XX=y
139CONFIG_USB_ETHER_MCS7830=y
140CONFIG_USB_ETHER_RTL8152=y
141CONFIG_USB_ETHER_SMSC95XX=y
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700142
143As with built-in networking, you will also want to enable some network
144commands, for example:
145
Chris Packhamf2fe81f2017-08-28 20:50:47 +1200146CONFIG_CMD_NET=y
147CONFIG_CMD_PING=y
148CONFIG_CMD_DHCP=y
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700149
150and some bootp options, which tell your board to obtain its subnet,
151gateway IP, host name and boot path from the bootp/dhcp server. These
152settings should start you off:
153
154#define CONFIG_BOOTP_SUBNETMASK
155#define CONFIG_BOOTP_GATEWAY
156#define CONFIG_BOOTP_HOSTNAME
157#define CONFIG_BOOTP_BOOTPATH
158
159You can also set the default IP address of your board and the server
160as well as the default file to load when a 'bootp' command is issued.
Gerhard Sittig9dc55732014-03-08 19:46:18 +0100161However note that encoding these individual network settings into a
162common exectuable is discouraged, as it leads to potential conflicts,
163and all the parameters can either get stored in the board's external
164environment, or get obtained from the bootp server if not set.
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700165
Wolfgang Denk825223d2011-09-11 21:24:09 +0200166#define CONFIG_IPADDR 10.0.0.2 (replace with your value)
167#define CONFIG_SERVERIP 10.0.0.1 (replace with your value)
Joe Hershbergere4da2482011-10-13 13:03:48 +0000168#define CONFIG_BOOTFILE "uImage"
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700169
170
171The 'usb start' command should identify the adapter something like this:
172
173CrOS> usb start
174(Re)start USB...
175USB EHCI 1.00
176scanning bus for devices... 3 USB Device(s) found
177 scanning bus for storage devices... 0 Storage Device(s) found
178 scanning bus for ethernet devices... 1 Ethernet Device(s) found
179CrOS> print ethact
180ethact=asx0
181
182You can see that it found an ethernet device and we can print out the
183device name (asx0 in this case).
184
185Then 'bootp' or 'dhcp' should use it to obtain an IP address from DHCP,
186perhaps something like this:
187
188CrOS> bootp
189Waiting for Ethernet connection... done.
190BOOTP broadcast 1
191BOOTP broadcast 2
192DHCP client bound to address 172.22.73.81
193Using asx0 device
194TFTP from server 172.22.72.144; our IP address is 172.22.73.81
195Filename '/tftpboot/uImage-sjg-seaboard-261347'.
196Load address: 0x40c000
197Loading: #################################################################
Wolfgang Denk825223d2011-09-11 21:24:09 +0200198 #################################################################
199 #################################################################
200 ################################################
Simon Glass2dd9bbe2011-06-13 16:13:11 -0700201done
202Bytes transferred = 3557464 (364858 hex)
203CrOS>
204
205
206Another way of doing this is to issue a tftp command, which will cause the
207bootp to happen automatically.
208
209
210MAC Addresses
211-------------
212
213Most Ethernet dongles have a built-in MAC address which is unique in the
214world. This is important so that devices on the network can be
215distinguised from each other. MAC address conflicts are evil and
216generally result in strange and eratic behaviour.
217
218Some boards have USB Ethernet chips on-board, and these sometimes do not
219have an assigned MAC address. In this case it is up to you to assign
220one which is unique. You should obtain a valid MAC address from a range
221assigned to you before you ship the product.
222
223Built-in Ethernet adapters support setting the MAC address by means of
224an ethaddr environment variable for each interface (ethaddr, eth1addr,
225eth2addr). There is similar support on the USB network side, using the
226names usbethaddr, usbeth1addr, etc. They are kept separate since we
227don't want a USB device taking the MAC address of a built-in device or
228vice versa.
229
230So if your USB Ethernet chip doesn't have a MAC address available then
231you must set usbethaddr to a suitable MAC address. At the time of
232writing this functionality is only supported by the SMSC driver.