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 # This utility uses cbootimage to signs a bootstub so that the Tegra boot ROM | |
8 # will load and run it. | |
9 | |
10 # Include common CrOS utilities. | |
11 . "/usr/lib/crosutils/common.sh" | |
12 | |
13 # Command line options | |
14 DEFINE_string bct "" "DDR memory timing BCT file." | |
15 DEFINE_string flash "" "Boot flash parameter file." | |
16 DEFINE_string bootstub "" "Bootstub firmware image to sign." | |
17 DEFINE_string output "bootstub.bin" "Signed bootstub + BCT output file." | |
18 DEFINE_string text_base "0xe08000" "Load address and entry point for bootstub." | |
19 DEFINE_string config "" "Directory for temporary configuration files." | |
20 | |
21 # Parse command line. | |
22 FLAGS "$@" || exit 1 | |
23 eval set -- "${FLAGS_ARGV}" | |
24 | |
25 # Die on errors. | |
26 set -e | |
27 | |
28 CROS_LOG_PREFIX="cros_sign_bootstub" | |
29 | |
30 function construct_config() { | |
31 local flash_file="$1" | |
32 local bct_file="$2" | |
33 local bootstub="$3" | |
34 local text_base="$4" | |
35 | |
36 # | |
37 # First we output the boot flash configuration file. | |
38 # | |
39 cat ${flash_file} | |
40 | |
41 # | |
42 # The cbootimage config file format is not yet documented. Below is | |
43 # a minimal config file that merges a BCT file and bootloader; in | |
44 # this case our stub U-Boot image. We do not use the Version, but it | |
45 # needs to be set. | |
46 # | |
47 # Currently a bug in cbootimage prevents us from setting Redundancy to | |
48 # 0. Redundancy controls how many instances of the BCT should be | |
49 # written to the signed image. A value of 1 causes two instances to | |
50 # be written. | |
51 # | |
52 # The BootLoader parameter specifies the bootloader image to use. It | |
53 # also specifies the load address for the bootloader in RAM and the | |
54 # entry point of the resulting image. For U-Boot these are the same | |
55 # value (TEXT_BASE). | |
56 # | |
57 echo "" | |
58 echo "Bctfile=${bct_file};" | |
59 echo "Version=1;" | |
60 echo "Redundancy=1;" | |
61 echo "BootLoader=${bootstub},${text_base},${text_base},Complete;" | |
62 } | |
63 | |
64 ############################################################################### | |
65 | |
66 check_for_file "boot flash device config" "..." "${FLAGS_flash}" | |
67 check_for_file "BCT" "........................" "${FLAGS_bct}" | |
68 check_for_file "bootstub image" "............." "${FLAGS_bootstub}" | |
69 | |
70 check_for_tool "cbootimage" "cbootimage" | |
71 | |
72 if [ -z "${FLAGS_config}" ]; then | |
73 config=$(mktemp -d) | |
74 | |
75 trap "rm -rf ${config}" EXIT | |
76 else | |
77 mkdir -p "${FLAGS_config}" | |
vb
2011/02/28 23:54:44
It would be cleaner to remove the directory on exi
robotboy
2011/03/01 00:03:40
Yup, the intent here is that if you don't specify
| |
78 | |
79 config=${FLAGS_config} | |
80 fi | |
81 | |
82 construct_config \ | |
83 "${FLAGS_flash}" \ | |
84 "${FLAGS_bct}" \ | |
85 "${FLAGS_bootstub}" \ | |
86 "${FLAGS_text_base}" > "${config}/boot.cfg" | |
87 | |
88 cbootimage "${config}/boot.cfg" "${FLAGS_output}" | |
OLD | NEW |