From 539e5212abba3e1df37e1f59b10963e7bbf1ec1d Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Tue, 8 Sep 2015 08:31:37 +0200 Subject: [PATCH] run: rename powerplug to netio The run plugin is not generic and works for NETIO4/NETIO230 powerplugs only. Further, this opens the path for other vendor-specific powerplug plugins. Note, the plugin parameter for the addressed powerplug was renamed to --power-on-netio-host resp. --power-off-netio-host --- tool/run/README | 20 ++++---- tool/run/log/amt | 2 +- tool/run/{powerplug.inc => power_netio.inc} | 4 +- tool/run/power_off/netio | 45 +++++++++++++++++ tool/run/power_off/powerplug | 45 ----------------- tool/run/power_on/amt | 2 +- tool/run/power_on/netio | 54 +++++++++++++++++++++ tool/run/power_on/powerplug | 54 --------------------- 8 files changed, 113 insertions(+), 113 deletions(-) rename tool/run/{powerplug.inc => power_netio.inc} (67%) create mode 100644 tool/run/power_off/netio delete mode 100644 tool/run/power_off/powerplug create mode 100644 tool/run/power_on/netio delete mode 100644 tool/run/power_on/powerplug diff --git a/tool/run/README b/tool/run/README index 4609975f3c..3875ac37ba 100644 --- a/tool/run/README +++ b/tool/run/README @@ -92,18 +92,18 @@ for output while loading the files via TFTP: ! --tftp-offset-dir /x86 \ ! --include log/serial --log-serial-cmd 'picocom -b 115200 /dev/ttyUSB0' -Executing hw on a rpi using powerplug to reset the hardware, JTAG to load the -image and USB serial to capture the output: +Executing hw on a rpi using NETIO powerplug to reset the hardware, JTAG to load +the image and USB serial to capture the output: !RUN_OPT = --include boot_dir/hw \ -! --include power_on/powerplug --power-on-powerplug-ip 10.23.42.5 \ -! --power-on-powerplug-user admin \ -! --power-on-powerplug-password secret \ -! --power-on-powerplug-port 1 -! --include power_off/powerplug --power-off-powerplug-ip 10.23.42.5 \ -! --power-off-powerplug-user admin \ -! --power-off-powerplug-password secret \ -! --power-off-powerplug-port 1 +! --include power_on/netio --power-on-netio-host 10.23.42.5 \ +! --power-on-netio-user admin \ +! --power-on-netio-password secret \ +! --power-on-netio-port 1 +! --include power_off/netio --power-off-netio-host 10.23.42.5 \ +! --power-off-netio-user admin \ +! --power-off-netio-password secret \ +! --power-off-netio-port 1 ! --include load/jtag \ ! --load-jtag-debugger /usr/share/openocd/scripts/interface/flyswatter2.cfg \ ! --load-jtag-board /usr/share/openocd/scripts/interface/raspberrypi.cfg \ diff --git a/tool/run/log/amt b/tool/run/log/amt index 0efe79b638..601e6bff4b 100644 --- a/tool/run/log/amt +++ b/tool/run/log/amt @@ -1,7 +1,7 @@ ## # Get output of the target machine via Intel AMT's SoL feature # -# \param --amt-host IP address of target machine +# \param --amt-host network address of target machine # \param --amt-password AMT password for target machine # diff --git a/tool/run/powerplug.inc b/tool/run/power_netio.inc similarity index 67% rename from tool/run/powerplug.inc rename to tool/run/power_netio.inc index b648c5471b..aacb2c80c4 100644 --- a/tool/run/powerplug.inc +++ b/tool/run/power_netio.inc @@ -1,5 +1,5 @@ -proc power_plug_connect { server_ip user_name password } { - spawn telnet $server_ip 1234 +proc power_netio_connect { host user_name password } { + spawn telnet $host 1234 set connection_id $spawn_id expect -i $connection_id "KSHELL V1.*" send -i $connection_id "login $user_name $password\n" diff --git a/tool/run/power_off/netio b/tool/run/power_off/netio new file mode 100644 index 0000000000..0be3af70ef --- /dev/null +++ b/tool/run/power_off/netio @@ -0,0 +1,45 @@ +## +# Reset the target machine via NETIO4/NETIO230 powerplug by Koukaam +# +# \param --power-off-netio-host network address of device +# \param --power-off-netio-user user for device +# \param --power-off-netio-password password for device +# \param --power-off-netio-port target port of device +# + + +source [genode_dir]/tool/run/power_netio.inc + + +proc power_off_netio_host { } { + return [get_cmd_arg_first --power-off-netio-host 1] +} + + +proc power_off_netio_user { } { + return [get_cmd_arg_first --power-off-netio-user 1] +} + + +proc power_off_netio_password { } { + return [get_cmd_arg_first --power-off-netio-password 1] +} + + +proc power_off_netio_port { } { + return [get_cmd_arg_first --power-off-netio-port 1] +} + + +proc run_power_off { } { + set host [power_off_netio_host] + set user_name [power_off_netio_user] + set password [power_off_netio_password] + set power_port [power_off_netio_port] + + set connection_id [power_netio_connect $host $user_name $password] + + puts "switch port $power_port off" + send -i $connection_id "port $power_port 0\n" + expect -i $connection_id "250 OK" +} diff --git a/tool/run/power_off/powerplug b/tool/run/power_off/powerplug deleted file mode 100644 index b28d3b97f4..0000000000 --- a/tool/run/power_off/powerplug +++ /dev/null @@ -1,45 +0,0 @@ -## -# Reset the target machine via powerplug -# -# \param --power-off-powerplug-ip IP address of powerplug device -# \param --power-off-powerplug-user user for powerplug device -# \param --power-off-powerplug-password password for powerplug device -# \param --power-off-powerplug-port target port of powerplug device -# - - -source [genode_dir]/tool/run/powerplug.inc - - -proc power_off_powerplug_ip { } { - return [get_cmd_arg_first --power-off-powerplug-ip 1] -} - - -proc power_off_powerplug_user { } { - return [get_cmd_arg_first --power-off-powerplug-user 1] -} - - -proc power_off_powerplug_password { } { - return [get_cmd_arg_first --power-off-powerplug-password 1] -} - - -proc power_off_powerplug_port { } { - return [get_cmd_arg_first --power-off-powerplug-port 1] -} - - -proc run_power_off { } { - set server_ip [power_off_powerplug_ip] - set user_name [power_off_powerplug_user] - set password [power_off_powerplug_password] - set power_port [power_off_powerplug_port] - - set connection_id [power_plug_connect $server_ip $user_name $password] - - puts "switch port $power_port off" - send -i $connection_id "port $power_port 0\n" - expect -i $connection_id "250 OK" -} diff --git a/tool/run/power_on/amt b/tool/run/power_on/amt index 2dea5494b4..4c0066603e 100644 --- a/tool/run/power_on/amt +++ b/tool/run/power_on/amt @@ -1,7 +1,7 @@ ## # Reset the target machine via Intel AMT # -# \param --power-on-amt-host IP address of target machine +# \param --power-on-amt-host network address of target machine # \param --power-on-amt-password AMT password for target machine # diff --git a/tool/run/power_on/netio b/tool/run/power_on/netio new file mode 100644 index 0000000000..ff150ab049 --- /dev/null +++ b/tool/run/power_on/netio @@ -0,0 +1,54 @@ +## +# Reset the target machine via NETIO4/NETIO230 powerplug by Koukaam +# +# \param --power-on-netio-host network address of device +# \param --power-on-netio-user user for device +# \param --power-on-netio-password password for device +# \param --power-on-netio-port target port of device +# + +source [genode_dir]/tool/run/power_netio.inc + + +proc power_on_netio_host { } { + return [get_cmd_arg_first --power-on-netio-host 1] +} + + +proc power_on_netio_user { } { + return [get_cmd_arg_first --power-on-netio-user 1] +} + + +proc power_on_netio_password { } { + return [get_cmd_arg_first --power-on-netio-password 1] +} + + +proc power_on_netio_port { } { + return [get_cmd_arg_first --power-on-netio-port 1] +} + + + +proc run_power_on { } { + set host [power_on_netio_host] + set user_name [power_on_netio_user] + set password [power_on_netio_password] + set power_port [power_on_netio_port] + + set connection_id [power_netio_connect $host $user_name $password] + + send -i $connection_id "port $power_port\n" + expect -i $connection_id -re {250 [0-9]+.*\n} + regexp -all {[0-9]+} $expect_out(0,string) power_status + if {!$power_status} { + puts "port $power_port is off - switching it on" + send -i $connection_id "port $power_port 1\n" + expect -i $connection_id "250 OK" + } else { + puts "port $power_port is on - reset port" + send -i $connection_id "port $power_port int\n" + expect -i $connection_id "250 OK" + } +} diff --git a/tool/run/power_on/powerplug b/tool/run/power_on/powerplug deleted file mode 100644 index 88caaebe0e..0000000000 --- a/tool/run/power_on/powerplug +++ /dev/null @@ -1,54 +0,0 @@ -## -# Reset the target machine via powerplug -# -# \param --power-on-powerplug-ip IP address of powerplug device -# \param --power-on-powerplug-user user for powerplug device -# \param --power-on-powerplug-password password for powerplug device -# \param --power-on-powerplug-port target port of powerplug device -# - -source [genode_dir]/tool/run/powerplug.inc - - -proc power_on_powerplug_ip { } { - return [get_cmd_arg_first --power-on-powerplug-ip 1] -} - - -proc power_on_powerplug_user { } { - return [get_cmd_arg_first --power-on-powerplug-user 1] -} - - -proc power_on_powerplug_password { } { - return [get_cmd_arg_first --power-on-powerplug-password 1] -} - - -proc power_on_powerplug_port { } { - return [get_cmd_arg_first --power-on-powerplug-port 1] -} - - - -proc run_power_on { } { - set server_ip [power_on_powerplug_ip] - set user_name [power_on_powerplug_user] - set password [power_on_powerplug_password] - set power_port [power_on_powerplug_port] - - set connection_id [power_plug_connect $server_ip $user_name $password] - - send -i $connection_id "port $power_port\n" - expect -i $connection_id -re {250 [0-9]+.*\n} - regexp -all {[0-9]+} $expect_out(0,string) power_status - if {!$power_status} { - puts "port $power_port is off - switching it on" - send -i $connection_id "port $power_port 1\n" - expect -i $connection_id "250 OK" - } else { - puts "port $power_port is on - reset port" - send -i $connection_id "port $power_port int\n" - expect -i $connection_id "250 OK" - } -}