"Das U-Boot" Source Tree
at master 144 lines 5.1 kB view raw
1Network console 2=============== 3 4In U-Boot, we implemented the networked console via the standard 5"devices" mechanism, which means that you can switch between the 6serial and network input/output devices by adjusting the 'stdin', 7'stdout', and 'stderr' environment variables. To switch to the 8networked console, set either of these variables to "nc". Input and 9output can be switched independently. 10 11The default buffer size can be overridden by setting 12CFG_NETCONSOLE_BUFFER_SIZE. 13 14We use an environment variable 'ncip' to set the IP address and the 15port of the destination. The format is <ip_addr>:<port>. If <port> is 16omitted, the value of 6666 is used. If the env var doesn't exist, the 17broadcast address and port 6666 are used. If it is set to an IP 18address of 0 (or 0.0.0.0) then no messages are sent to the network. 19The source / listening port can be configured separately by setting 20the 'ncinport' environment variable and the destination port can be 21configured by setting the 'ncoutport' environment variable. Note that 22you need to set up the network interface (e.g. using DHCP) before it 23can be used for network console. 24 25For example, if your server IP is 192.168.1.1, you could use: 26 27.. prompt:: bash => 28 29 env set nc 'env set stdout nc; env set stderr nc; env set stdin nc' 30 env set ncip '192.168.1.1' 31 env save 32 run nc 33 34On the host side, please use this script to access the console 35 36.. code-block:: bash 37 38 tools/netconsole <ip> [port] 39 40The script uses netcat to talk to the board over UDP. It requires you to 41specify the target IP address (or host name, assuming DNS is working). The 42script can be interrupted by pressing ^T (CTRL-T). 43 44Be aware that in some distributives (Fedora Core 5 at least) 45usage of nc has been changed and -l and -p options are considered 46as mutually exclusive. If nc complains about options provided, 47you can just remove the -p option from the script. 48 49It turns out that 'netcat' cannot be used to listen to broadcast 50packets. We developed our own tool 'ncb' (see tools directory) that 51listens to broadcast packets on a given port and dumps them to the 52standard output. It will be built when compiling for a board which 53has CONFIG_NETCONSOLE defined. If the netconsole script can find it 54in PATH or in the same directory, it will be used instead. 55 56For Linux, the network-based console needs special configuration. 57Minimally, the host IP address needs to be specified. This can be 58done either via the kernel command line, or by passing parameters 59while loading the netconsole.o module (when used in a loadable module 60configuration). Please refer to Documentation/networking/logging.txt 61file for the original Ingo Molnar's documentation on how to pass 62parameters to the loadable module. 63 64The format of the kernel command line parameter (for the static 65configuration) is as follows 66 67.. code-block:: bash 68 69 netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr] 70 71where 72 73src-port 74 source for UDP packets (defaults to 6665) 75 76src-ip 77 source IP to use (defaults to the interface's address) 78 79dev 80 network interface (defaults to eth0) 81 82tgt-port 83 port for logging agent (defaults to 6666) 84 85tgt-ip 86 IP address for logging agent (this is the required parameter) 87 88tgt-macaddr 89 ethernet MAC address for logging agent (defaults to broadcast) 90 91Examples 92 93.. code-block:: bash 94 95 netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc 96 netconsole=@/,@192.168.3.1/ 97 98Please note that for the Linux networked console to work, the 99ethernet interface has to be up by the time the netconsole driver is 100initialized. This means that in case of static kernel configuration, 101the respective Ethernet interface has to be brought up using the "IP 102Autoconfiguration" kernel feature, which is usually done by defaults 103in the ELDK-NFS-based environment. 104 105To browse the Linux network console output, use the 'netcat' tool invoked 106as follows: 107 108.. code-block:: bash 109 110 nc -u -l -p 6666 111 112Note that unlike the U-Boot implementation the Linux netconsole is 113unidirectional, i. e. you have console output only in Linux. 114 115Setup via environment 116--------------------- 117 118If persistent environment is enabled in your U-Boot configuration, you 119can configure the network console using the environment. For example: 120 121.. prompt:: bash => 122 123 env set autoload no 124 env set hostname "u-boot" 125 env set bootdelay 5 126 env set nc 'dhcp; env set stdout nc; env set stderr nc; env set stdin nc' 127 env set ncip '192.168.1.1' 128 env set preboot "${preboot}; run nc;" 129 env save 130 reset 131 132``autoload no`` tells the ``dhcp`` command to configure the network 133interface without trying to load an image. ``hostname "u-boot"`` sets 134the hostname to be sent in DHCP requests, so they are easy to 135recognize in the DHCP server log. The command in ``nc`` calls ``dhcp`` 136to make sure the network interface is set up before enabling 137netconsole. 138 139Adding ``nc`` to ``preboot`` tells U-Boot to activate netconsole 140before trying to find any boot options, so you can interact with it if 141desired. 142 143``env save`` stores the settings persistently, and ``reset`` then 144triggers a fresh start that will use the changed settings.