Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 1 | Network console |
| 2 | =============== |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 3 | |
| 4 | In U-Boot, we implemented the networked console via the standard |
| 5 | "devices" mechanism, which means that you can switch between the |
| 6 | serial and network input/output devices by adjusting the 'stdin' and |
| 7 | 'stdout' environment variables. To switch to the networked console, |
| 8 | set either of these variables to "nc". Input and output can be |
| 9 | switched independently. |
| 10 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 11 | The default buffer size can be overridden by setting |
| 12 | CONFIG_NETCONSOLE_BUFFER_SIZE. |
Joe Hershberger | 2c8fe51 | 2012-07-31 06:09:17 +0000 | [diff] [blame] | 13 | |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 14 | We use an environment variable 'ncip' to set the IP address and the |
| 15 | port of the destination. The format is <ip_addr>:<port>. If <port> is |
| 16 | omitted, the value of 6666 is used. If the env var doesn't exist, the |
| 17 | broadcast address and port 6666 are used. If it is set to an IP |
| 18 | address of 0 (or 0.0.0.0) then no messages are sent to the network. |
Joe Hershberger | 7f51898 | 2012-07-31 06:06:41 +0000 | [diff] [blame] | 19 | The source / listening port can be configured separately by setting |
| 20 | the 'ncinport' environment variable and the destination port can be |
| 21 | configured by setting the 'ncoutport' environment variable. |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 22 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 23 | For example, if your server IP is 192.168.1.1, you could use:: |
wdenk | b1bf6f2 | 2005-04-03 14:52:59 +0000 | [diff] [blame] | 24 | |
| 25 | => setenv nc 'setenv stdout nc;setenv stdin nc' |
| 26 | => setenv ncip 192.168.1.1 |
| 27 | => saveenv |
| 28 | => run nc |
| 29 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 30 | On the host side, please use this script to access the console |
wdenk | b1bf6f2 | 2005-04-03 14:52:59 +0000 | [diff] [blame] | 31 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 32 | .. code-block:: bash |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 33 | |
Mike Frysinger | bcb6dd9 | 2008-12-09 23:20:31 -0500 | [diff] [blame] | 34 | tools/netconsole <ip> [port] |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 35 | |
Mike Frysinger | bcb6dd9 | 2008-12-09 23:20:31 -0500 | [diff] [blame] | 36 | The script uses netcat to talk to the board over UDP. It requires you to |
| 37 | specify the target IP address (or host name, assuming DNS is working). The |
| 38 | script can be interrupted by pressing ^T (CTRL-T). |
wdenk | b1bf6f2 | 2005-04-03 14:52:59 +0000 | [diff] [blame] | 39 | |
Igor Marnat | 443feb7 | 2007-03-21 09:55:01 +0300 | [diff] [blame] | 40 | Be aware that in some distributives (Fedora Core 5 at least) |
| 41 | usage of nc has been changed and -l and -p options are considered |
| 42 | as mutually exclusive. If nc complains about options provided, |
| 43 | you can just remove the -p option from the script. |
| 44 | |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 45 | It turns out that 'netcat' cannot be used to listen to broadcast |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 46 | packets. We developed our own tool 'ncb' (see tools directory) that |
| 47 | listens to broadcast packets on a given port and dumps them to the |
Mike Frysinger | 1c20e4a | 2009-09-09 12:20:21 -0400 | [diff] [blame] | 48 | standard output. It will be built when compiling for a board which |
| 49 | has CONFIG_NETCONSOLE defined. If the netconsole script can find it |
| 50 | in PATH or in the same directory, it will be used instead. |
wdenk | b1bf6f2 | 2005-04-03 14:52:59 +0000 | [diff] [blame] | 51 | |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 52 | For Linux, the network-based console needs special configuration. |
| 53 | Minimally, the host IP address needs to be specified. This can be |
| 54 | done either via the kernel command line, or by passing parameters |
| 55 | while loading the netconsole.o module (when used in a loadable module |
| 56 | configuration). Please refer to Documentation/networking/logging.txt |
| 57 | file for the original Ingo Molnar's documentation on how to pass |
| 58 | parameters to the loadable module. |
| 59 | |
| 60 | The format of the kernel command line parameter (for the static |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 61 | configuration) is as follows |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 62 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 63 | .. code-block:: bash |
| 64 | |
| 65 | netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr] |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 66 | |
| 67 | where |
| 68 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 69 | src-port |
| 70 | source for UDP packets (defaults to 6665) |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 71 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 72 | src-ip |
| 73 | source IP to use (defaults to the interface's address) |
| 74 | |
| 75 | dev |
| 76 | network interface (defaults to eth0) |
| 77 | |
| 78 | tgt-port |
| 79 | port for logging agent (defaults to 6666) |
| 80 | |
| 81 | tgt-ip |
| 82 | IP address for logging agent (this is the required parameter) |
| 83 | |
| 84 | tgt-macaddr |
| 85 | ethernet MAC address for logging agent (defaults to broadcast) |
| 86 | |
| 87 | Examples |
| 88 | |
| 89 | .. code-block:: bash |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 90 | |
| 91 | netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 92 | netconsole=@/,@192.168.3.1/ |
| 93 | |
| 94 | Please note that for the Linux networked console to work, the |
| 95 | ethernet interface has to be up by the time the netconsole driver is |
| 96 | initialized. This means that in case of static kernel configuration, |
| 97 | the respective Ethernet interface has to be brought up using the "IP |
| 98 | Autoconfiguration" kernel feature, which is usually done by defaults |
| 99 | in the ELDK-NFS-based environment. |
| 100 | |
| 101 | To browse the Linux network console output, use the 'netcat' tool invoked |
| 102 | as follows: |
| 103 | |
Heinrich Schuchardt | d0253f7 | 2020-12-12 09:37:47 +0100 | [diff] [blame^] | 104 | .. code-block:: bash |
| 105 | |
wdenk | 68ceb29 | 2004-08-02 21:11:11 +0000 | [diff] [blame] | 106 | nc -u -l -p 6666 |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 107 | |
| 108 | Note that unlike the U-Boot implementation the Linux netconsole is |
| 109 | unidirectional, i. e. you have console output only in Linux. |