]> git.ipfire.org Git - thirdparty/u-boot.git/blame - tools/netconsole
riscv: qemu: imply GOLDFISH_RTC
[thirdparty/u-boot.git] / tools / netconsole
CommitLineData
bcb6dd91
MF
1#!/bin/sh
2
3usage() {
4 (
7f51898c 5 echo "Usage: $0 <board-IP> [board-port [board-in-port]]"
bcb6dd91
MF
6 echo ""
7 echo "If port is not specified, '6666' will be used"
8 [ -z "$*" ] && exit 0
9 echo ""
10 echo "ERROR: $*"
11 exit 1
12 ) 1>&2
13 exit $?
14}
15
16while [ -n "$1" ] ; do
17 case $1 in
18 -h|--help) usage;;
19 --) break;;
20 -*) usage "Invalid option $1";;
21 *) break;;
22 esac
23 shift
24done
25
26ip=$1
7f51898c
JH
27board_out_port=${2:-6666}
28board_in_port=${3:-${board_out_port}}
bcb6dd91 29
7f51898c
JH
30echo Board out port: ${board_out_port}
31echo Board in port: ${board_in_port}
32
33if [ -z "${ip}" ] || [ -n "$4" ] ; then
bcb6dd91
MF
34 usage "Invalid number of arguments"
35fi
36
f0d4607d 37for nc in socat netcat nc ; do
77093180 38 type ${nc} >/dev/null 2>&1 && break
bcb6dd91
MF
39done
40
41trap "stty icanon echo intr ^C" 0 2 3 5 10 13 15
42echo "NOTE: the interrupt signal (normally ^C) has been remapped to ^T"
43
44stty -icanon -echo intr ^T
77093180 45(
1c20e4a9
MF
46if type ncb 2>/dev/null ; then
47 # see if ncb is in $PATH
7f51898c 48 exec ncb ${board_out_port}
1c20e4a9 49
f0d4607d
AS
50elif [ "${nc}" = "socat" ] ; then
51 # socat does support broadcast
52 while ${nc} STDIO "UDP4-LISTEN:${board_out_port}"; do :; done
53
1c20e4a9
MF
54elif [ -x ${0%/*}/ncb ] ; then
55 # maybe it's in the same dir as the netconsole script
7f51898c 56 exec ${0%/*}/ncb ${board_out_port}
1c20e4a9
MF
57
58else
59 # blah, just use regular netcat
7f51898c 60 while ${nc} -u -l -p ${board_out_port} < /dev/null ; do
1c20e4a9
MF
61 :
62 done
63fi
77093180
MF
64) &
65pid=$!
f0d4607d
AS
66if [ "${nc}" = "socat" ] ; then
67 ${nc} - "UDP4:${ip}:${board_in_port}"
68else
69 ${nc} -u ${ip} ${board_in_port}
70fi
77093180 71kill ${pid} 2>/dev/null