#!/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 and prepare ARTIK # Syntax is: artik_prepare_conf.sh $SDMUX $USR_IMAGE $BOOT_IMAGE # # Author: Aleksander Mistewicz export TESTLAB_SCRIPTS="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" . "${TESTLAB_SCRIPTS}/common.sh" SDMUX="$1" USR_IMAGE="$2" BOOT_IMAGE="$3" test -n "${SDMUX}" || die "Missing argument: sdmux!" test -n "${USR_IMAGE}" || die "Missing argument: userspace image!" test -n "${BOOT_IMAGE}" || die "Missing argument: boot image!" case "$BOOT_IMAGE" in *artik10*) MODEL="artik10" ;; *artik530*) MODEL="artik530" ;; *artik710*) MODEL="artik710" ;; *artik5*) MODEL="artik5" ;; *) die "Unknown model" esac . "${TESTLAB_SCRIPTS}/prepare/prepare.sh" . "${TESTLAB_SCRIPTS}/flash/flash.sh" echo "### prepare ###" T_DIR="/tmp/${SDMUX}" mkdir -p "${T_DIR}" IMAGE_UNPACKED="${T_DIR}/unpacked" IMAGE_MOUNTPOINT="${T_DIR}/mounted" TMP_TAR="${T_DIR}/tizen-${SDMUX}.tar" switch2testserver "${SDMUX}" unpack_image "${USR_IMAGE}" "${IMAGE_UNPACKED}" mount_image "${IMAGE_UNPACKED}/rootfs.img" "${IMAGE_MOUNTPOINT}" mount_image "${IMAGE_UNPACKED}/system-data.img" "${IMAGE_MOUNTPOINT}/opt" mount_image "${IMAGE_UNPACKED}/user.img" "${IMAGE_MOUNTPOINT}/opt/usr" install_iserial_artik "${SDMUX}" "${IMAGE_MOUNTPOINT}" set_usb_mode "${IMAGE_MOUNTPOINT}" install_hdmi_force "${IMAGE_MOUNTPOINT}" unmount_image "${IMAGE_MOUNTPOINT}/opt/usr" unmount_image "${IMAGE_MOUNTPOINT}/opt" unmount_image "${IMAGE_MOUNTPOINT}" tar cvf "${TMP_TAR}" -C "${IMAGE_UNPACKED}" $(tar tf "${USR_IMAGE}") || die "tar: failed" echo "### flash ###" UUID_FILE="/var/tmp/uuid-${SDMUX}" DEV_SDCARD=$(uuid2dev "${UUID_FILE}" "${SDMUX}") || die "sdcard not found!" "${ARTIK_FLASH_SCRIPT}" -d "${DEV_SDCARD}" -m "${MODEL}" -p "${TMP_TAR}" RET=$? change_uuid "${UUID_FILE}" "${DEV_SDCARD}" if [ $RET -ne 0 ]; then die "${ARTIK_FLASH_SCRIPT} exited with an error" "$RET" fi switch2device "${SDMUX}" restart_device "${SDMUX}" dyper_restart "${SDMUX}" "dyper1" echo "### cleanup ###" rm -rf "${T_DIR}"