README.usb 8.4 KB

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