Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: host/write_tegra_bios

Issue 6374016: write_tegra_bios replaces the numerous burn-u-boot scripts. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/dev-util.git@master
Patch Set: Address review comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 #
8 # This utility writes a BIOS image to a tegra based board.
9 #
10
11 # Include common CrOS utilities.
12 . "/usr/lib/crosutils/common.sh"
13
14 get_default_board
15
16 # Command line options
17 DEFINE_string board "$DEFAULT_BOARD" "The name of the board to flash."
18 DEFINE_string variant "" "Board variant."
19 DEFINE_string bios "" "Path to bios image to write."
20
21 # Parse command line.
22 FLAGS "$@" || exit 1
23 eval set -- "${FLAGS_ARGV}"
24
25 # Die on errors.
26 set -e
27
28 if [ -z "${FLAGS_board}" ]; then
29 error "--board required."
30 exit 1
31 fi
32
33 get_board_and_variant $FLAGS_board $FLAGS_variant
34
35 # If the user didn't specify a BIOS image to load then build the path from
36 # the chroot directory and the board/variant information provided. This works
37 # both inside and outside the chroot.
38 if [ -z "${FLAGS_bios}" ]; then
39 FLAGS_bios="/build/${BOARD_VARIANT}/u-boot/u-boot.bin"
40
41 info "Using BIOS image: ${FLAGS_bios}"
42 fi
43
44 if [ ! -e "${FLAGS_bios}" ]; then
45 error "No BIOS image found at: ${FLAGS_bios}"
46 exit
47 fi
48
49 # Search for the burn-u-boot directory in our overlay list. The first directory
50 # found should be sufficient because there should only be burn-u-boot
51 # directories at the board level.
52 OVERLAY_LIST=$(cros_overlay_list --board "${BOARD}" --variant "${VARIANT}")
53
54 for overlay in ${OVERLAY_LIST} ; do
55 if [ -d "${overlay}/burn-u-boot" ]; then
56 burn_u_boot="${overlay}/burn-u-boot"
57 break
58 fi
59 done
60
61 # Make sure that we have found a burn-u-boot directory and that the nvflash
62 # tool has been installed.
63 if [ ! -d "${burn_u_boot}" ]; then
64 error "No burn-u-boot directory found in the overlay list for this board:"
65 error "${OVERLAY_LIST}"
66 fi
67
68 if ! which nvflash >/dev/null ; then
69 error "The nvflash utility was not found. Run the following command in your"
70 error "chroot: sudo -E emerge nvflash"
71 exit
72 fi
73
74 # bootloader.bin is a special program used to burn things into flash
75 bin="${burn_u_boot}/bin/bootloader.bin"
76
77 # The BCT file contains memory timings, firmware offset and length and a
78 # checksum of the firmware image. The BCT file is the first data read out
79 # of reset by the masked ROM.
80 bct="${burn_u_boot}/bct/default.bct"
81
82 # this file describes the flash layout - it pulls in the boot loader file
83 cfg="${burn_u_boot}/flash.cfg"
84
85 # extract the ODM data from the <overlay>/burn-u-boot/data.odm file
86 odm=$(cat "${burn_u_boot}/data.odm")
87
88 # try to print a helpful name - the U-Boot version string
89 header=$(strings $FLAGS_bios | grep "U-Boot" | head -1 )
90 info "Using: $header"
91
92 # insert the correct file to flash into the nvflash configuration file.
93 temp=$(mktemp)
94
95 trap "rm -f ${temp}" EXIT
96
97 sed "s#^filename=.*\$#filename=${FLAGS_bios}#" $cfg > $temp
98
99 # Write the BCT + U-Boot + FDT Blob image to the boot device specified in the
100 # flash.cfg from the burn-u-boot directory.
101 sudo nvflash \
102 --bct "${bct}" \
103 --setbct \
104 --odmdata "${odm}" \
105 --configfile "${temp}" \
106 --create \
107 --bl "${bin}" \
108 --go
109
110 if [ $? != 0 ]; then
111 echo
112 error "Burn failed"
113 error "Please check that your board is connected via the A-to-A USB cable"
114 error "correctly. Also ensure that your board is in the NVIDIA force"
115 error "recovery mode. This is accomplished by holding down the 'recovery'"
116 error "button while resetting the board (either by power cycling or pressing"
117 error "'reset'. More information for your specific board can be found in"
118 error "the README.txt file in your boards overlay."
119 else
120 info "$header written"
121 info "Press reset to start your new U-Boot"
122 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698