blob: cb9a42d918aff38acdcbd1e30d918dad999883f3 [file] [log] [blame]
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +01001Network console
2===============
wdenkb8fb6192004-08-02 21:11:11 +00003
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' and
7'stdout' environment variables. To switch to the networked console,
8set either of these variables to "nc". Input and output can be
9switched independently.
10
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010011The default buffer size can be overridden by setting
Tom Rini364d0022023-01-10 11:19:45 -050012CFG_NETCONSOLE_BUFFER_SIZE.
Joe Hershberger45f4a232012-07-31 06:09:17 +000013
wdenka0ebde52004-09-08 22:03:11 +000014We 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.
Joe Hershbergerd0f53962012-07-31 06:06:41 +000019The source / listening port can be configured separately by setting
20the 'ncinport' environment variable and the destination port can be
Fiona Klute4a4161f2024-05-18 12:47:05 +020021configured 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.
wdenka0ebde52004-09-08 22:03:11 +000024
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010025For example, if your server IP is 192.168.1.1, you could use::
wdenkfa66e932005-04-03 14:52:59 +000026
27 => setenv nc 'setenv stdout nc;setenv stdin nc'
28 => setenv ncip 192.168.1.1
29 => saveenv
30 => run nc
31
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010032On the host side, please use this script to access the console
wdenkfa66e932005-04-03 14:52:59 +000033
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010034.. code-block:: bash
wdenkb8fb6192004-08-02 21:11:11 +000035
Mike Frysinger9649d112008-12-09 23:20:31 -050036 tools/netconsole <ip> [port]
wdenka0ebde52004-09-08 22:03:11 +000037
Mike Frysinger9649d112008-12-09 23:20:31 -050038The script uses netcat to talk to the board over UDP. It requires you to
39specify the target IP address (or host name, assuming DNS is working). The
40script can be interrupted by pressing ^T (CTRL-T).
wdenkfa66e932005-04-03 14:52:59 +000041
Igor Marnat6df66902007-03-21 09:55:01 +030042Be aware that in some distributives (Fedora Core 5 at least)
43usage of nc has been changed and -l and -p options are considered
44as mutually exclusive. If nc complains about options provided,
45you can just remove the -p option from the script.
46
wdenkb3a4a702004-12-10 11:40:40 +000047It turns out that 'netcat' cannot be used to listen to broadcast
wdenka0ebde52004-09-08 22:03:11 +000048packets. We developed our own tool 'ncb' (see tools directory) that
49listens to broadcast packets on a given port and dumps them to the
Mike Frysingercb976402009-09-09 12:20:21 -040050standard output. It will be built when compiling for a board which
51has CONFIG_NETCONSOLE defined. If the netconsole script can find it
52in PATH or in the same directory, it will be used instead.
wdenkfa66e932005-04-03 14:52:59 +000053
wdenkb8fb6192004-08-02 21:11:11 +000054For Linux, the network-based console needs special configuration.
55Minimally, the host IP address needs to be specified. This can be
56done either via the kernel command line, or by passing parameters
57while loading the netconsole.o module (when used in a loadable module
58configuration). Please refer to Documentation/networking/logging.txt
59file for the original Ingo Molnar's documentation on how to pass
60parameters to the loadable module.
61
62The format of the kernel command line parameter (for the static
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010063configuration) is as follows
wdenkb8fb6192004-08-02 21:11:11 +000064
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010065.. code-block:: bash
66
67 netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
wdenkb8fb6192004-08-02 21:11:11 +000068
69where
70
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010071src-port
72 source for UDP packets (defaults to 6665)
wdenkb8fb6192004-08-02 21:11:11 +000073
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010074src-ip
75 source IP to use (defaults to the interface's address)
wdenkb8fb6192004-08-02 21:11:11 +000076
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010077dev
78 network interface (defaults to eth0)
79
80tgt-port
81 port for logging agent (defaults to 6666)
82
83tgt-ip
84 IP address for logging agent (this is the required parameter)
wdenkb8fb6192004-08-02 21:11:11 +000085
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010086tgt-macaddr
87 ethernet MAC address for logging agent (defaults to broadcast)
wdenkb8fb6192004-08-02 21:11:11 +000088
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +010089Examples
90
91.. code-block:: bash
92
93 netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
wdenkb8fb6192004-08-02 21:11:11 +000094 netconsole=@/,@192.168.3.1/
95
96Please note that for the Linux networked console to work, the
97ethernet interface has to be up by the time the netconsole driver is
98initialized. This means that in case of static kernel configuration,
99the respective Ethernet interface has to be brought up using the "IP
100Autoconfiguration" kernel feature, which is usually done by defaults
101in the ELDK-NFS-based environment.
102
103To browse the Linux network console output, use the 'netcat' tool invoked
104as follows:
105
Heinrich Schuchardt1cab1c82020-12-12 09:37:47 +0100106.. code-block:: bash
107
wdenkb8fb6192004-08-02 21:11:11 +0000108 nc -u -l -p 6666
wdenkb3a4a702004-12-10 11:40:40 +0000109
110Note that unlike the U-Boot implementation the Linux netconsole is
111unidirectional, i. e. you have console output only in Linux.
Fiona Klute4a4161f2024-05-18 12:47:05 +0200112
113Setup via environment
114---------------------
115
116If persistent environment is enabled in your U-Boot configuration, you
117can configure the network console using the environment. For example:
118
119.. prompt:: bash =>
120
121 env set autoload no
122 env set hostname "u-boot"
123 env set bootdelay 5
124 env set nc 'dhcp; env set stdout nc; env set stderr nc; env set stdin nc'
125 env set ncip '192.168.1.1'
126 env set preboot "${preboot}; run nc;"
127 env save
128 reset
129
130``autoload no`` tells the ``dhcp`` command to configure the network
131interface without trying to load an image. ``hostname "u-boot"`` sets
132the hostname to be sent in DHCP requests, so they are easy to
133recognize in the DHCP server log. The command in ``nc`` calls ``dhcp``
134to make sure the network interface is set up before enabling
135netconsole.
136
137Adding ``nc`` to ``preboot`` tells U-Boot to activate netconsole
138before trying to find any boot options, so you can interact with it if
139desired.
140
141``env save`` stores the settings persistently, and ``reset`` then
142triggers a fresh start that will use the changed settings.