OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 | |
8 # Load common constants. This should be the first executable line. | 7 # Load common constants. This should be the first executable line. |
9 # The path to common.sh should be relative to your script's location. | 8 # The path to common.sh should be relative to your script's location. |
10 . "$(dirname "$0")/common.sh" | 9 . "$(dirname "$0")/common.sh" |
11 | 10 |
12 # Load functions and constants for chromeos-install | 11 # Load functions and constants for chromeos-install |
13 . "$(dirname "$0")/chromeos-common.sh" | 12 . "$(dirname "$0")/chromeos-common.sh" |
14 | 13 |
15 # Script must be run inside the chroot. | 14 # Script must be run inside the chroot. |
16 assert_inside_chroot | 15 assert_inside_chroot |
17 | 16 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 95 |
97 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image" | 96 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image" |
98 if [[ ! -s ${STATEFUL_IMG} ]]; then | 97 if [[ ! -s ${STATEFUL_IMG} ]]; then |
99 error "Can't find ${STATEFUL_IMG}" | 98 error "Can't find ${STATEFUL_IMG}" |
100 exit 1 | 99 exit 1 |
101 fi | 100 fi |
102 | 101 |
103 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM | 102 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM |
104 # systems will use a U-Boot script temporarily, but it goes in the same place. | 103 # systems will use a U-Boot script temporarily, but it goes in the same place. |
105 if [[ "$ARCH" = "arm" ]]; then | 104 if [[ "$ARCH" = "arm" ]]; then |
106 # U-Boot script copies the kernel into memory, then boots it. | 105 # We need to know the location and size of the kernel so we can create the |
| 106 # U-Boot script to point to it. Let's create one fake GPT first which will |
| 107 # set the appropriate environment variables. Then we can create the correct |
| 108 # script and install it for real. A bit awkward, but this is only temporary. |
| 109 echo "Installing fake GPT first, to calculate locations..." |
| 110 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG /dev/zero |
| 111 |
| 112 # Create the U-Boot script to copy the kernel into memory and boot it. |
107 KERNEL_OFFSET=$(printf "0x%08x" ${START_KERN_A}) | 113 KERNEL_OFFSET=$(printf "0x%08x" ${START_KERN_A}) |
108 KERNEL_SECS_HEX=$(printf "0x%08x" ${NUM_KERN_BLOCKS}) | 114 KERNEL_SECS_HEX=$(printf "0x%08x" ${NUM_KERN_SECTORS}) |
109 MBR_SCRIPT="${IMAGEDIR}/mbr_script" | 115 MBR_SCRIPT="${IMAGEDIR}/mbr_script" |
110 echo -e "echo\necho ---- ChromeOS Boot ----\necho\n" \ | 116 echo -e "echo\necho ---- ChromeOS Boot ----\necho\n" \ |
111 "mmc read 1 C0008000 $KERNEL_OFFSET $KERNEL_SECS_HEX\n" \ | 117 "mmc read 1 C0008000 $KERNEL_OFFSET $KERNEL_SECS_HEX\n" \ |
112 "bootm C0008000" > ${MBR_SCRIPT} | 118 "bootm C0008000" > ${MBR_SCRIPT} |
113 MKIMAGE="${FLAGS_board_root}/u-boot/mkimage" | 119 MKIMAGE="${FLAGS_board_root}/u-boot/mkimage" |
114 if [[ -f "$MKIMAGE".gz ]]; then | 120 if [[ -f "$MKIMAGE".gz ]]; then |
115 sudo gunzip "$MKIMAGE".gz | 121 sudo gunzip "$MKIMAGE".gz |
116 fi | 122 fi |
117 if [[ -x "$MKIMAGE" ]]; then | 123 if [[ -x "$MKIMAGE" ]]; then |
118 MBR_SCRIPT_UIMG="${MBR_SCRIPT}.uimg" | 124 MBR_SCRIPT_UIMG="${MBR_SCRIPT}.uimg" |
(...skipping 18 matching lines...) Expand all Loading... |
137 # Now populate the partitions. | 143 # Now populate the partitions. |
138 echo "Copying stateful partition..." | 144 echo "Copying stateful partition..." |
139 dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_STATEFUL} | 145 dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_STATEFUL} |
140 | 146 |
141 echo "Copying kernel..." | 147 echo "Copying kernel..." |
142 dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} | 148 dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} |
143 | 149 |
144 echo "Copying rootfs..." | 150 echo "Copying rootfs..." |
145 dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A} | 151 dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A} |
146 | 152 |
OLD | NEW |