xref: /openbmc/u-boot/doc/README.NetConsole (revision b1bf6f2c9b4aa17c6ccb7a631c99fae7f4b5744b)
168ceb29eSwdenk
268ceb29eSwdenkIn U-Boot, we implemented the networked console via the standard
368ceb29eSwdenk"devices" mechanism, which means that you can switch between the
468ceb29eSwdenkserial and network input/output devices by adjusting the 'stdin' and
568ceb29eSwdenk'stdout' environment variables. To switch to the networked console,
668ceb29eSwdenkset either of these variables to "nc". Input and output can be
768ceb29eSwdenkswitched independently.
868ceb29eSwdenk
9eedcd078SwdenkWe use an environment variable 'ncip' to set the IP address and the
10eedcd078Swdenkport of the destination. The format is <ip_addr>:<port>. If <port> is
11eedcd078Swdenkomitted, the value of 6666 is used. If the env var doesn't exist, the
12eedcd078Swdenkbroadcast address and port 6666 are used. If it is set to an IP
13eedcd078Swdenkaddress of 0 (or 0.0.0.0) then no messages are sent to the network.
14eedcd078Swdenk
15*b1bf6f2cSwdenkFor example, if your server IP is 192.168.1.1, you could use:
16*b1bf6f2cSwdenk
17*b1bf6f2cSwdenk	=> setenv nc 'setenv stdout nc;setenv stdin nc'
18*b1bf6f2cSwdenk	=> setenv ncip 192.168.1.1
19*b1bf6f2cSwdenk	=> saveenv
20*b1bf6f2cSwdenk	=> run nc
21*b1bf6f2cSwdenk
22*b1bf6f2cSwdenk
2368ceb29eSwdenkOn the host side, please use this script to access the console:
2468ceb29eSwdenk
2568ceb29eSwdenk+++++++++++++++++++++++++++++++++++++++++++
2668ceb29eSwdenk#! /bin/bash
2768ceb29eSwdenk
28*b1bf6f2cSwdenk[ $# = 1 ] || { echo "Usage: $0 target_ip" >&2 ; exit 1 ; }
2968ceb29eSwdenkTARGET_IP=$1
3068ceb29eSwdenk
3168ceb29eSwdenkstty -icanon -echo intr ^T
3268ceb29eSwdenknc -u -l -p 6666 < /dev/null &
3368ceb29eSwdenknc -u ${TARGET_IP} 6666
3468ceb29eSwdenkstty icanon echo intr ^C
3568ceb29eSwdenk+++++++++++++++++++++++++++++++++++++++++++
3668ceb29eSwdenk
37*b1bf6f2cSwdenkThe script expects exactly one argument, which is interpreted as  the
38*b1bf6f2cSwdenktarget IP address (or host name, assuming DNS is working). The script
39*b1bf6f2cSwdenkcan be interrupted by pressing ^T (CTRL-T).
40*b1bf6f2cSwdenk
4125d6712aSwdenkIt turns out that 'netcat' cannot be used to listen to broadcast
42eedcd078Swdenkpackets. We developed our own tool 'ncb' (see tools directory) that
43eedcd078Swdenklistens to broadcast packets on a given port and dumps them to the
44eedcd078Swdenkstandard output. use it as follows:
45eedcd078Swdenk
46eedcd078Swdenk+++++++++++++++++++++++++++++++++++++++++++
47eedcd078Swdenk#! /bin/bash
48eedcd078Swdenk
49*b1bf6f2cSwdenk[ $# = 1 ] || { echo "Usage: $0 target_ip" >&2 ; exit 1 ; }
50*b1bf6f2cSwdenkTARGET_IP=$1
51*b1bf6f2cSwdenk
52eedcd078Swdenkstty icanon echo intr ^T
53eedcd078Swdenk./ncb &
54*b1bf6f2cSwdenknc -u ${TARGET_IP} 6666
55eedcd078Swdenkstty icanon echo intr ^C
56eedcd078Swdenkkill 0
57eedcd078Swdenk+++++++++++++++++++++++++++++++++++++++++++
58eedcd078Swdenk
59*b1bf6f2cSwdenkAgain, this script takes exactly one argument, which is interpreted
60*b1bf6f2cSwdenkas the target IP address (or host name, assuming DNS is working). The
61*b1bf6f2cSwdenkscript can be interrupted by pressing ^T (CTRL-T).
62*b1bf6f2cSwdenk
63*b1bf6f2cSwdenkThe 'ncb' tool can be found in the tools directory; it will not be
64*b1bf6f2cSwdenkbuilt by default so you will ither have to adjust the Makefile or
65*b1bf6f2cSwdenkbuild it manually.
66*b1bf6f2cSwdenk
67*b1bf6f2cSwdenk
6868ceb29eSwdenkFor Linux, the network-based console needs special configuration.
6968ceb29eSwdenkMinimally, the host IP address needs to be specified. This can be
7068ceb29eSwdenkdone either via the kernel command line, or by passing parameters
7168ceb29eSwdenkwhile loading the netconsole.o module (when used in a loadable module
7268ceb29eSwdenkconfiguration). Please refer to Documentation/networking/logging.txt
7368ceb29eSwdenkfile for the original Ingo Molnar's documentation on how to pass
7468ceb29eSwdenkparameters to the loadable module.
7568ceb29eSwdenk
7668ceb29eSwdenkThe format of the kernel command line parameter (for the static
7768ceb29eSwdenkconfiguration) is as follows:
7868ceb29eSwdenk
7968ceb29eSwdenk  netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
8068ceb29eSwdenk
8168ceb29eSwdenkwhere
8268ceb29eSwdenk
8368ceb29eSwdenk  src-port	source for UDP packets
8468ceb29eSwdenk		(defaults to 6665)
8568ceb29eSwdenk  src-ip	source IP to use
8668ceb29eSwdenk		(defaults to the interface's address)
8768ceb29eSwdenk  dev		network interface
8868ceb29eSwdenk		(defaults to eth0)
8968ceb29eSwdenk  tgt-port	port for logging agent
9068ceb29eSwdenk		(defaults to 6666)
9168ceb29eSwdenk  tgt-ip	IP address for logging agent
9268ceb29eSwdenk		(this is the required parameter)
9368ceb29eSwdenk  tgt-macaddr	ethernet MAC address for logging agent
9468ceb29eSwdenk		(defaults to broadcast)
9568ceb29eSwdenk
9668ceb29eSwdenkExamples:
9768ceb29eSwdenk
9868ceb29eSwdenk  netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
9968ceb29eSwdenk
10068ceb29eSwdenkor
10168ceb29eSwdenk
10268ceb29eSwdenk  netconsole=@/,@192.168.3.1/
10368ceb29eSwdenk
10468ceb29eSwdenkPlease note that for the Linux networked console to work, the
10568ceb29eSwdenkethernet interface has to be up by the time the netconsole driver is
10668ceb29eSwdenkinitialized. This means that in case of static kernel configuration,
10768ceb29eSwdenkthe respective Ethernet interface has to be brought up using the "IP
10868ceb29eSwdenkAutoconfiguration" kernel feature, which is usually done by defaults
10968ceb29eSwdenkin the ELDK-NFS-based environment.
11068ceb29eSwdenk
11168ceb29eSwdenkTo browse the Linux network console output, use the 'netcat' tool invoked
11268ceb29eSwdenkas follows:
11368ceb29eSwdenk
11468ceb29eSwdenk	nc -u -l -p 6666
11525d6712aSwdenk
11625d6712aSwdenkNote that unlike the U-Boot implementation the Linux netconsole is
11725d6712aSwdenkunidirectional, i. e. you have console output only in Linux.
118