| 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 # Load common constants. This should be the first executable line. | 7 # Load common constants. This should be the first executable line. |
| 8 # 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. |
| 9 . "$(dirname "$0")/common.sh" | 9 . "$(dirname "$0")/common.sh" |
| 10 | 10 |
| 11 # Load functions and constants for chromeos-install | 11 # Load functions and constants for chromeos-install |
| 12 . "$(dirname "$0")/chromeos-common.sh" | 12 . "$(dirname "$0")/chromeos-common.sh" |
| 13 | 13 |
| 14 # Script must be run inside the chroot. | 14 # Script must be run inside the chroot. |
| 15 restart_in_chroot_if_needed $* | 15 restart_in_chroot_if_needed $* |
| 16 | 16 |
| 17 get_default_board | 17 get_default_board |
| 18 | 18 |
| 19 # Flags. | 19 # Flags. |
| 20 DEFINE_string arch "" \ | 20 DEFINE_string arch "" \ |
| 21 "The target architecture (\"arm\" or \"x86\")." | 21 "The target architecture (\"arm\" or \"x86\")." |
| 22 DEFINE_string board "$DEFAULT_BOARD" \ | 22 DEFINE_string board "$DEFAULT_BOARD" \ |
| 23 "The board to build an image for." | 23 "The board to build an image for." |
| 24 DEFINE_string arm_extra_bootargs "" \ | |
| 25 "Additional command line options to pass to the ARM kernel." | |
| 26 DEFINE_integer rootfs_partition_size 1024 \ | 24 DEFINE_integer rootfs_partition_size 1024 \ |
| 27 "rootfs parition size in MBs." | 25 "rootfs parition size in MBs." |
| 28 | 26 |
| 29 # Usage. | 27 # Usage. |
| 30 FLAGS_HELP=$(cat <<EOF | 28 FLAGS_HELP=$(cat <<EOF |
| 31 | 29 |
| 32 Usage: $(basename $0) [flags] IMAGEDIR OUTDEV | 30 Usage: $(basename $0) [flags] IMAGEDIR OUTDEV |
| 33 | 31 |
| 34 This takes the image components in IMAGEDIR and creates a bootable, | 32 This takes the image components in IMAGEDIR and creates a bootable, |
| 35 GPT-formatted image in OUTDEV. OUTDEV can be a file or block device. | 33 GPT-formatted image in OUTDEV. OUTDEV can be a file or block device. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 error "Can't find ${OEM_IMG}" | 100 error "Can't find ${OEM_IMG}" |
| 103 exit 1 | 101 exit 1 |
| 104 fi | 102 fi |
| 105 | 103 |
| 106 ESP_IMG="${IMAGEDIR}/esp.image" | 104 ESP_IMG="${IMAGEDIR}/esp.image" |
| 107 if [ ! -s ${ESP_IMG} ]; then | 105 if [ ! -s ${ESP_IMG} ]; then |
| 108 error "Can't find ${ESP_IMG}" | 106 error "Can't find ${ESP_IMG}" |
| 109 exit 1 | 107 exit 1 |
| 110 fi | 108 fi |
| 111 | 109 |
| 112 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM | 110 # We'll need some code to put in the PMBR, for booting on legacy BIOS. |
| 113 # systems will use a U-Boot script temporarily, but it goes in the same place. | |
| 114 if [[ "$ARCH" = "arm" ]]; then | 111 if [[ "$ARCH" = "arm" ]]; then |
| 115 PMBRCODE=/dev/zero | 112 PMBRCODE=/dev/zero |
| 116 else | 113 else |
| 117 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) | 114 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) |
| 118 fi | 115 fi |
| 119 | 116 |
| 120 # Create the GPT. This has the side-effect of setting some global vars | 117 # Create the GPT. This has the side-effect of setting some global vars |
| 121 # describing the partition table entries (see the comments in the source). | 118 # describing the partition table entries (see the comments in the source). |
| 122 install_gpt $OUTDEV $(numsectors $ROOTFS_IMG) $(numsectors $STATEFUL_IMG) \ | 119 install_gpt $OUTDEV $(numsectors $ROOTFS_IMG) $(numsectors $STATEFUL_IMG) \ |
| 123 $PMBRCODE $(numsectors $ESP_IMG) false $FLAGS_rootfs_partition_size | 120 $PMBRCODE $(numsectors $ESP_IMG) false $FLAGS_rootfs_partition_size |
| 124 | 121 |
| 125 if [[ "$ARCH" = "arm" ]]; then | |
| 126 # assume /dev/mmcblk1. we could not get this from ${OUTDEV} | |
| 127 DEVICE=1 | |
| 128 MBR_SCRIPT_UIMG=$(make_arm_mbr \ | |
| 129 ${START_KERN_A} \ | |
| 130 ${NUM_KERN_SECTORS} \ | |
| 131 ${DEVICE} \ | |
| 132 "${FLAGS_arm_extra_bootargs}") | |
| 133 sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \ | |
| 134 if="$MBR_SCRIPT_UIMG" of=${OUTDEV} conv=notrunc | |
| 135 fi | |
| 136 | |
| 137 # Emit helpful scripts for testers, etc. | 122 # Emit helpful scripts for testers, etc. |
| 138 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" | 123 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" |
| 139 | 124 |
| 140 sudo= | 125 sudo= |
| 141 if [ ! -w "$OUTDEV" ] ; then | 126 if [ ! -w "$OUTDEV" ] ; then |
| 142 # use sudo when writing to a block device. | 127 # use sudo when writing to a block device. |
| 143 sudo=sudo | 128 sudo=sudo |
| 144 fi | 129 fi |
| 145 | 130 |
| 146 # Now populate the partitions. | 131 # Now populate the partitions. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 158 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ | 143 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
| 159 seek=${START_ROOTFS_A} | 144 seek=${START_ROOTFS_A} |
| 160 | 145 |
| 161 echo "Copying EFI system partition..." | 146 echo "Copying EFI system partition..." |
| 162 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP} | 147 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP} |
| 163 | 148 |
| 164 # Clean up temporary files. | 149 # Clean up temporary files. |
| 165 if [[ -n "${MBR_IMG:-}" ]]; then | 150 if [[ -n "${MBR_IMG:-}" ]]; then |
| 166 rm "${MBR_IMG}" | 151 rm "${MBR_IMG}" |
| 167 fi | 152 fi |
| OLD | NEW |