From 43ada927bd9cb3ba103bee38c458521e40e2c7a5 Mon Sep 17 00:00:00 2001 From: Aleksander Mistewicz Date: Thu, 17 Dec 2015 11:40:01 +0100 Subject: [PATCH] Add sd-mux-ctrl functions to tct/flash/flash.sh Syntax is: switch2device $SDMUX switch2testserver $SDMUX restart_device $SDMUX change_id $SDMUX $NEWID sdmux_init $SDMUX Change-Id: I57f9d94ac81fb4b6eca00c257c308d84c0a6940b Signed-off-by: Aleksander Mistewicz --- tct/flash/flash.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tct/flash/flash.sh b/tct/flash/flash.sh index 3d4b367..7138294 100755 --- a/tct/flash/flash.sh +++ b/tct/flash/flash.sh @@ -18,6 +18,11 @@ # Syntax is: # * uuid2dev $FILE # * change_uuid $FILE $DEV_SDCARD +# * switch2device $SDMUX +# * switch2testserver $SDMUX +# * restart_device $SDMUX [$DELAY] +# * sdmux_init $SDMUX +# * change_id $SDMUX $NEWID # # Author: Aleksander Mistewicz @@ -67,3 +72,43 @@ change_uuid() { echo "${NEW_UUID}" > "${FILE}" } + +switch2device() { + SDMUX="$1" + test -n "${SDMUX}" || die "Missing argument: sdmux!" + sudo sd-mux-ctrl -e "${SDMUX}" -d || die "Error returned by sd-mux-ctrl: switch2device failed!" +} + +switch2testserver() { + SDMUX="$1" + test -n "${SDMUX}" || die "Missing argument: sdmux!" + sudo sd-mux-ctrl -e "${SDMUX}" -s || + die "Error returned by sd-mux-ctrl: switch2testserver failed!" +} + +restart_device() { + SDMUX="$1" + DELAY="$2" + test -n "${SDMUX}" || die "Missing argument: sdmux!" + test -n "${DELAY}" || DELAY="2000" + sudo sd-mux-ctrl -e "${SDMUX}" -m "${DELAY}" -c || + die "Error returned by sd-mux-ctrl: restart_device failed!" +} + +sdmux_init() { + SDMUX="$1" + test -n "${SDMUX}" || die "Missing argument: sdmux!" + sudo sd-mux-ctrl -e "${SDMUX}" -t || + die "Error returned by sd-mux-ctrl: sdmux_init failed!" +} + +change_id() { + SDMUX="$1" + NEWID="$2" + test -n "${SDMUX}" || die "Missing argument: sdmux!" + test -n "${NEWID}" || die "Missing argument: newid!" + if [ "${SDMUX}" != "${NEWID}" ]; then + sudo sd-mux-ctrl -e "${SDMUX}" -r "${NEWID}" || + die "Error returned by sd-mux-ctrl: change_id failed!" + fi +} -- 2.7.4