blob: 87ee2541c1dde2415918563be047c2dbba704edb [file] [log] [blame]
# 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/"
# 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
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
info "Using BIOS image: ${FLAGS_bios}"
if [ ! -e "${FLAGS_bios}" ]; then
error "No BIOS image found at: ${FLAGS_bios}"
# 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
# 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}"
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"
# bootloader.bin is a special program used to burn things into flash
# 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.
# this file describes the flash layout - it pulls in the boot loader file
# 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.
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}" \
if [ $? != 0 ]; then
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."
info "$header written"
info "Press reset to start your new U-Boot"