| Index: host/write_tegra_bios
|
| diff --git a/host/write_tegra_bios b/host/write_tegra_bios
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..87ee2541c1dde2415918563be047c2dbba704edb
|
| --- /dev/null
|
| +++ b/host/write_tegra_bios
|
| @@ -0,0 +1,122 @@
|
| +#!/bin/bash
|
| +
|
| +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +#
|
| +# This utility writes a BIOS image to a tegra based board.
|
| +#
|
| +
|
| +# Include common CrOS utilities.
|
| +. "/usr/lib/crosutils/common.sh"
|
| +
|
| +get_default_board
|
| +
|
| +# Command line options
|
| +DEFINE_string board "$DEFAULT_BOARD" "The name of the board to flash."
|
| +DEFINE_string variant "" "Board variant."
|
| +DEFINE_string bios "" "Path to bios image to write."
|
| +
|
| +# Parse command line.
|
| +FLAGS "$@" || exit 1
|
| +eval set -- "${FLAGS_ARGV}"
|
| +
|
| +# Die on errors.
|
| +set -e
|
| +
|
| +if [ -z "${FLAGS_board}" ]; then
|
| + error "--board required."
|
| + exit 1
|
| +fi
|
| +
|
| +get_board_and_variant $FLAGS_board $FLAGS_variant
|
| +
|
| +# If the user didn't specify a BIOS image to load then build the path from
|
| +# the chroot directory and the board/variant information provided. This works
|
| +# both inside and outside the chroot.
|
| +if [ -z "${FLAGS_bios}" ]; then
|
| + FLAGS_bios="/build/${BOARD_VARIANT}/u-boot/u-boot.bin"
|
| +
|
| + info "Using BIOS image: ${FLAGS_bios}"
|
| +fi
|
| +
|
| +if [ ! -e "${FLAGS_bios}" ]; then
|
| + error "No BIOS image found at: ${FLAGS_bios}"
|
| + exit
|
| +fi
|
| +
|
| +# Search for the burn-u-boot directory in our overlay list. The first directory
|
| +# found should be sufficient because there should only be burn-u-boot
|
| +# directories at the board level.
|
| +OVERLAY_LIST=$(cros_overlay_list --board "${BOARD}" --variant "${VARIANT}")
|
| +
|
| +for overlay in ${OVERLAY_LIST} ; do
|
| + if [ -d "${overlay}/burn-u-boot" ]; then
|
| + burn_u_boot="${overlay}/burn-u-boot"
|
| + break
|
| + fi
|
| +done
|
| +
|
| +# Make sure that we have found a burn-u-boot directory and that the nvflash
|
| +# tool has been installed.
|
| +if [ ! -d "${burn_u_boot}" ]; then
|
| + error "No burn-u-boot directory found in the overlay list for this board:"
|
| + error "${OVERLAY_LIST}"
|
| +fi
|
| +
|
| +if ! which nvflash >/dev/null ; then
|
| + error "The nvflash utility was not found. Run the following command in your"
|
| + error "chroot: sudo -E emerge nvflash"
|
| + exit
|
| +fi
|
| +
|
| +# bootloader.bin is a special program used to burn things into flash
|
| +bin="${burn_u_boot}/bin/bootloader.bin"
|
| +
|
| +# The BCT file contains memory timings, firmware offset and length and a
|
| +# checksum of the firmware image. The BCT file is the first data read out
|
| +# of reset by the masked ROM.
|
| +bct="${burn_u_boot}/bct/default.bct"
|
| +
|
| +# this file describes the flash layout - it pulls in the boot loader file
|
| +cfg="${burn_u_boot}/flash.cfg"
|
| +
|
| +# extract the ODM data from the <overlay>/burn-u-boot/data.odm file
|
| +odm=$(cat "${burn_u_boot}/data.odm")
|
| +
|
| +# try to print a helpful name - the U-Boot version string
|
| +header=$(strings $FLAGS_bios | grep "U-Boot" | head -1 )
|
| +info "Using: $header"
|
| +
|
| +# insert the correct file to flash into the nvflash configuration file.
|
| +temp=$(mktemp)
|
| +
|
| +trap "rm -f ${temp}" EXIT
|
| +
|
| +sed "s#^filename=.*\$#filename=${FLAGS_bios}#" $cfg > $temp
|
| +
|
| +# Write the BCT + U-Boot + FDT Blob image to the boot device specified in the
|
| +# flash.cfg from the burn-u-boot directory.
|
| +sudo nvflash \
|
| + --bct "${bct}" \
|
| + --setbct \
|
| + --odmdata "${odm}" \
|
| + --configfile "${temp}" \
|
| + --create \
|
| + --bl "${bin}" \
|
| + --go
|
| +
|
| +if [ $? != 0 ]; then
|
| + echo
|
| + error "Burn failed"
|
| + error "Please check that your board is connected via the A-to-A USB cable"
|
| + error "correctly. Also ensure that your board is in the NVIDIA force"
|
| + error "recovery mode. This is accomplished by holding down the 'recovery'"
|
| + error "button while resetting the board (either by power cycling or pressing"
|
| + error "'reset'. More information for your specific board can be found in"
|
| + error "the README.txt file in your boards overlay."
|
| +else
|
| + info "$header written"
|
| + info "Press reset to start your new U-Boot"
|
| +fi
|
|
|