xref: /OK3568_Linux_fs/u-boot/doc/README.NetConsole (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun
2*4882a593SmuzhiyunIn U-Boot, we implemented the networked console via the standard
3*4882a593Smuzhiyun"devices" mechanism, which means that you can switch between the
4*4882a593Smuzhiyunserial and network input/output devices by adjusting the 'stdin' and
5*4882a593Smuzhiyun'stdout' environment variables. To switch to the networked console,
6*4882a593Smuzhiyunset either of these variables to "nc". Input and output can be
7*4882a593Smuzhiyunswitched independently.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunCONFIG_NETCONSOLE_BUFFER_SIZE - Override the default buffer size
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunWe use an environment variable 'ncip' to set the IP address and the
12*4882a593Smuzhiyunport of the destination. The format is <ip_addr>:<port>. If <port> is
13*4882a593Smuzhiyunomitted, the value of 6666 is used. If the env var doesn't exist, the
14*4882a593Smuzhiyunbroadcast address and port 6666 are used. If it is set to an IP
15*4882a593Smuzhiyunaddress of 0 (or 0.0.0.0) then no messages are sent to the network.
16*4882a593SmuzhiyunThe source / listening port can be configured separately by setting
17*4882a593Smuzhiyunthe 'ncinport' environment variable and the destination port can be
18*4882a593Smuzhiyunconfigured by setting the 'ncoutport' environment variable.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunFor example, if your server IP is 192.168.1.1, you could use:
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun	=> setenv nc 'setenv stdout nc;setenv stdin nc'
23*4882a593Smuzhiyun	=> setenv ncip 192.168.1.1
24*4882a593Smuzhiyun	=> saveenv
25*4882a593Smuzhiyun	=> run nc
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunOn the host side, please use this script to access the console:
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun	tools/netconsole <ip> [port]
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunThe script uses netcat to talk to the board over UDP.  It requires you to
33*4882a593Smuzhiyunspecify the target IP address (or host name, assuming DNS is working). The
34*4882a593Smuzhiyunscript can be interrupted by pressing ^T (CTRL-T).
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunBe aware that in some distributives (Fedora Core 5 at least)
37*4882a593Smuzhiyunusage of nc has been changed and -l and -p options are considered
38*4882a593Smuzhiyunas mutually exclusive. If nc complains about options provided,
39*4882a593Smuzhiyunyou can just remove the -p option from the script.
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunIt turns out that 'netcat' cannot be used to listen to broadcast
42*4882a593Smuzhiyunpackets. We developed our own tool 'ncb' (see tools directory) that
43*4882a593Smuzhiyunlistens to broadcast packets on a given port and dumps them to the
44*4882a593Smuzhiyunstandard output.  It will be built when compiling for a board which
45*4882a593Smuzhiyunhas CONFIG_NETCONSOLE defined.  If the netconsole script can find it
46*4882a593Smuzhiyunin PATH or in the same directory, it will be used instead.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunFor Linux, the network-based console needs special configuration.
49*4882a593SmuzhiyunMinimally, the host IP address needs to be specified. This can be
50*4882a593Smuzhiyundone either via the kernel command line, or by passing parameters
51*4882a593Smuzhiyunwhile loading the netconsole.o module (when used in a loadable module
52*4882a593Smuzhiyunconfiguration). Please refer to Documentation/networking/logging.txt
53*4882a593Smuzhiyunfile for the original Ingo Molnar's documentation on how to pass
54*4882a593Smuzhiyunparameters to the loadable module.
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunThe format of the kernel command line parameter (for the static
57*4882a593Smuzhiyunconfiguration) is as follows:
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun  netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
60*4882a593Smuzhiyun
61*4882a593Smuzhiyunwhere
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun  src-port	source for UDP packets
64*4882a593Smuzhiyun		(defaults to 6665)
65*4882a593Smuzhiyun  src-ip	source IP to use
66*4882a593Smuzhiyun		(defaults to the interface's address)
67*4882a593Smuzhiyun  dev		network interface
68*4882a593Smuzhiyun		(defaults to eth0)
69*4882a593Smuzhiyun  tgt-port	port for logging agent
70*4882a593Smuzhiyun		(defaults to 6666)
71*4882a593Smuzhiyun  tgt-ip	IP address for logging agent
72*4882a593Smuzhiyun		(this is the required parameter)
73*4882a593Smuzhiyun  tgt-macaddr	ethernet MAC address for logging agent
74*4882a593Smuzhiyun		(defaults to broadcast)
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunExamples:
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun  netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
79*4882a593Smuzhiyun
80*4882a593Smuzhiyunor
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun  netconsole=@/,@192.168.3.1/
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunPlease note that for the Linux networked console to work, the
85*4882a593Smuzhiyunethernet interface has to be up by the time the netconsole driver is
86*4882a593Smuzhiyuninitialized. This means that in case of static kernel configuration,
87*4882a593Smuzhiyunthe respective Ethernet interface has to be brought up using the "IP
88*4882a593SmuzhiyunAutoconfiguration" kernel feature, which is usually done by defaults
89*4882a593Smuzhiyunin the ELDK-NFS-based environment.
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunTo browse the Linux network console output, use the 'netcat' tool invoked
92*4882a593Smuzhiyunas follows:
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun	nc -u -l -p 6666
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunNote that unlike the U-Boot implementation the Linux netconsole is
97*4882a593Smuzhiyununidirectional, i. e. you have console output only in Linux.
98