1#!/bin/bash 2############################################################################ 3# Copyright (c) 2019 ETH Zurich. 4# All rights reserved. 5# 6# This file is distributed under the terms in the attached LICENSE file. 7# If you do not find this file, copies can be found by writing to: 8# ETH Zurich D-INFK, CAB F.78, Universitaetstr. 6, CH-8092 Zurich, 9# Attn: Systems Group. 10# 11# Shell script for booting Barrelfish on SoCs with U-Boot using SDP and UUU 12# 13############################################################################ 14 15set -e 16 17SCRIPT_DIR=$(dirname $0) 18 19usage() { 20 echo "Usage: $0 <options>" 21 echo " --bf: Barrelfish image (required)" 22 echo " --board: Select board" 23 echo " --no-reset: Don't reset the board" 24 echo "" 25 echo "The script assumes that uuu is either on your" 26 echo "search path or the UUU environment variables is set." 27 exit 1; 28} 29 30while [ $# -ne 0 ]; do 31 case $1 in 32 "--bf") 33 BF_IMAGE=$2 34 shift 35 ;; 36 "--board") 37 BOARD=$2 38 shift 39 ;; 40 "--no-reset") 41 NO_RESET=1 42 ;; 43 "-h"|"--help") 44 usage 45 ;; 46 *) 47 usage 48 ;; 49 esac 50 shift 51done 52 53UUU=${UUU:-"uuu"} 54if !(which $UUU > /dev/null); then 55 echo "\`${UUU}\` not found or not executable. Add to PATH or set UUU variable." >&2 56 exit 1 57fi 58 59if [ -z "$BF_IMAGE" ]; then 60 echo "No Barrelfish image specified." >&2 61 exit 1; 62fi 63 64source "${SCRIPT_DIR}/board-tools.sh" 65BOARD_CTRL="${SCRIPT_DIR}/board_ctrl.py" 66 67if [ ! -z "$BOARD" ]; then 68 BOARD_SERIAL=$(get_uart_serial_number $BOARD) 69 if [ $? -ne 0 ]; then 70 exit 1 71 fi 72 BOARD_CTRL="${BOARD_CTRL} --board ${BOARD_SERIAL}" 73fi 74 75if [ ${NO_RESET:-0} -eq 0 ]; then 76 echo "" 77 echo "Resetting board" 78 $BOARD_CTRL reset 79fi 80 81echo "" 82echo "Creating temp dir" 83TEMPDIR=$(mktemp -d) 84 85echo "" 86echo "Copying auxiliary files to ${TEMPDIR}" 87cp "${SCRIPT_DIR}/aux-bf-boot/boot.scr" "${TEMPDIR}/" 88cp "${SCRIPT_DIR}/aux-bf-boot/uuu.auto" "${TEMPDIR}/" 89 90echo "" 91echo "Copying Barrelfish image to ${TEMPDIR}" 92cp $BF_IMAGE "${TEMPDIR}/image.efi" 93 94# Wait for fastboot to be started, and udev rules have been applied... 95sleep 1 96if [ ! -z "$BOARD" ]; then 97 DEVPATH=$(get_otg_path_uuu $BOARD) 98 if [ $? -ne 0 ]; then 99 exit 1 100 fi 101 UUU="${UUU} -m ${DEVPATH}" 102fi 103 104echo "" 105echo "Flashing board" 106$UUU ${TEMPDIR} 107 108#Clean up 109rm -rf $TEMPDIR 110