OLD | NEW |
---|---|
(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. | |
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
| |
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 if [ -z "${FLAGS_board}" ]; then | |
26 error "--board required." | |
27 exit 1 | |
28 fi | |
29 | |
30 get_board_and_variant $FLAGS_board $FLAGS_variant | |
31 | |
32 # If the user didn't specify a BIOS image to load then build the path from | |
33 # the chroot directory and the board/variant information provided. This works | |
34 # both inside and outside the chroot. | |
35 if [ -z "${FLAGS_bios}" ]; then | |
36 FLAGS_bios="/build/${BOARD_VARIANT}/u-boot/u-boot.bin" | |
37 | |
38 info "Using BIOS image: ${FLAGS_bios}" | |
39 fi | |
40 | |
41 if [ ! -e "${FLAGS_bios}" ]; then | |
42 error "No BIOS image found at: ${FLAGS_bios}" | |
43 exit | |
44 fi | |
45 | |
46 # Search for the burn-u-boot directory in our overlay list. The first directory | |
47 # found should be sufficient because there should only be burn-u-boot | |
48 # directories at the board level. | |
49 OVERLAY_LIST=$(cros_overlay_list --board "${BOARD}" --variant "${VARIANT}") | |
50 | |
51 for overlay in ${OVERLAY_LIST} ; do | |
52 if [ -d "${overlay}/burn-u-boot" ]; then | |
53 burn_u_boot="${overlay}/burn-u-boot" | |
54 break | |
55 fi | |
56 done | |
57 | |
58 # Make sure that we have found a burn-u-boot directory and that the nvflash | |
59 # tool has been installed. | |
60 if [ ! -d "${burn_u_boot}" ]; then | |
61 error "No burn-u-boot directory found in the overlay list for this board:" | |
62 error "${OVERLAY_LIST}" | |
63 fi | |
64 | |
65 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
| |
66 error "The nvflash utility was not found. Run the following command in your" | |
67 error "chroot: sudo -E emerge nvflash" | |
68 exit | |
69 fi | |
70 | |
71 # bootloader.bin is a special program used to burn things into flash | |
72 bin="${burn_u_boot}/bin/bootloader.bin" | |
73 | |
74 # The BCT file contains memory timings, firmware offset and length and a | |
75 # checksum of the firmware image. The BCT file is the first data read out | |
76 # of reset by the masked ROM. | |
77 bct="${burn_u_boot}/bct/default.bct" | |
78 | |
79 # this file describes the flash layout - it pulls in the boot loader file | |
80 cfg="${burn_u_boot}/flash.cfg" | |
81 | |
82 # extract the ODM data from the <overlay>/burn-u-boot/data.odm file | |
83 odm=$(cat "${burn_u_boot}/data.odm") | |
84 | |
85 # try to print a helpful name - the U-Boot version string | |
86 header=$(strings $FLAGS_bios | grep "U-Boot" | head -1 ) | |
87 info "Using: $header" | |
88 | |
89 # insert the correct file to flash into the nvflash configuration file. | |
90 temp=$(mktemp) | |
91 | |
92 sed "s#^filename=.*\$#filename=${FLAGS_bios}#" $cfg > $temp | |
93 | |
94 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.
| |
95 | |
96 # Write the BCT + U-Boot + FDT Blob image to the boot device specified in the | |
97 # flash.cfg from the burn-u-boot directory. | |
98 sudo nvflash \ | |
99 --bct "${bct}" \ | |
100 --setbct \ | |
101 --odmdata "${odm}" \ | |
102 --configfile "${temp}" \ | |
103 --create \ | |
104 --bl "${bin}" \ | |
105 --go | |
106 | |
107 if [ $? != 0 ]; then | |
108 echo | |
109 error "Burn failed" | |
110 error "Please check that your board is connected via the A-to-A USB cable" | |
111 error "correctly. Also ensure that your board is in the NVIDIA force" | |
112 error "recovery mode. This is accomplished by holding down the 'recovery'" | |
113 error "button while resetting the board (either by power cycling or pressing" | |
114 error "'reset'. More information for your specific board can be found in" | |
115 error "the README.txt file in your boards overlay." | |
116 else | |
117 info "$header written" | |
118 info "Press reset to start your new U-Boot" | |
119 fi | |
OLD | NEW |