Chromium Code Reviews| Index: host/write_tegra_bios |
| diff --git a/host/write_tegra_bios b/host/write_tegra_bios |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..01bb8847b0b796c132efceb1c65e6f21344133d6 |
| --- /dev/null |
| +++ b/host/write_tegra_bios |
| @@ -0,0 +1,119 @@ |
| +#!/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. |
|
vb
2011/01/27 21:43:15
you might want to
set -e
to be on the safe side
robotboy
2011/01/27 22:30:41
Done, but I put it below the command line parsing
|
| +. "/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}" |
| + |
| +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 |
|
vb
2011/01/27 21:43:15
can this check be done before further processing,
robotboy
2011/01/27 22:30:41
It could,, I moved it here because of your previou
vb
2011/01/27 22:36:44
I meant moving it before any actual processing sta
|
| + 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) |
| + |
| +sed "s#^filename=.*\$#filename=${FLAGS_bios}#" $cfg > $temp |
| + |
| +trap "rm -f ${temp}" EXIT |
|
vb
2011/01/27 21:43:15
could this be moved to the point before the file c
robotboy
2011/01/27 22:30:41
Done.
|
| + |
| +# 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 |