#!/bin/sh # Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Script used to flash, prepare and configure Minnowboard MAX. # Compatibile with both (32-bit and 64-bit) versions. # Configuration file in $TL_IP_CONF is required; format is: # # # Synatx is: minnow_prepare_conf_flash.sh $SDMUX $IMAGE # # Author: Aleksander Mistewicz export TESTLAB_SCRIPTS="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" . "${TESTLAB_SCRIPTS}/common.sh" . "${TESTLAB_SCRIPTS}/flash/flash.sh" . "${TESTLAB_SCRIPTS}/conf/conf.sh" . "${TESTLAB_SCRIPTS}/run/run.sh" SDMUX="$1" IMAGE="$2" test -n "${SDMUX}" || die "Missing argument: sdmux!" test -n "${IMAGE}" || die "Missing argument: image!" test -f "${IMAGE}" || die "Image file does not exist or is not a regular file: ${IMAGE}!" IP="$(get_ip "${SDMUX}")" || die "Error: get_ip failed!" echo "### prepare ###" switch2testserver "${SDMUX}" echo "### flash ###" UUID_FILE="/var/tmp/uuid-${SDMUX}" DEV_SDCARD=$(uuid2dev "${UUID_FILE}" "${SDMUX}") echo "Bmaptool: start" test -b "${DEV_SDCARD}" || die "File does not exist or is not block special" sudo bmaptool -q copy "${IMAGE}" "${DEV_SDCARD}" RET=$? echo "Bmaptool: finish" change_uuid "${UUID_FILE}" "${DEV_SDCARD}" if [ $RET -ne 0 ]; then die "Bmaptool exited with an error" "$RET" fi switch2device "${SDMUX}" restart_device "${SDMUX}" echo "### conf ###" CONNECT_CNT=0 SLEEP=${INIT_SLEEP} sleep "${SLEEP}" while ! ping -c 1 "${IP}" -W 1 | grep -q icmp_seq do printf "," if [ ${SLEEP} -ge ${MAX_SLEEP} ] then die "Timeout: host not found in the network!" fi if [ ${SLEEP} -ge ${RESTART_SLEEP} ] then echo "Restarting MINNOW" >&2 restart_device "${SDMUX}" fi sleep "${SLEEP}" SLEEP=$((SLEEP+INC_SLEEP)) CONNECT_CNT=$((CONNECT_CNT+1)) done printf "\n" SLEEP=10 while ! nc -q 1 "${IP}" 22 > sysctl.result cat sysctl.result echo "### run ###" if [ -f "common_test.yaml" ] then run_avocado_ssh "${IP}" "avocado-results" "common_test.yaml" else echo "Missing file: common_test.yaml; skipping avocado tests" fi echo "### cleanup ###" switch2testserver "${SDMUX}"