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

Side by Side Diff: update_bootloaders.sh

Issue 3448022: build_image: Merge x86 and ARM where possible. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Codereview ate my homework. Created 10 years, 2 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 | « image_to_usb.sh ('k') | 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
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 # Helper script that generates the legacy/efi bootloader partitions. 7 # Helper script that generates the legacy/efi bootloader partitions.
8 # It does not populate the templates, but can update a loop device. 8 # It does not populate the templates, but can update a loop device.
9 9
10 . "$(dirname "$0")/common.sh" 10 . "$(dirname "$0")/common.sh"
11 . "$(dirname "$0")/chromeos-common.sh" # installer 11 . "$(dirname "$0")/chromeos-common.sh" # installer
12 12
13 get_default_board 13 get_default_board
14 14
15 # Flags. 15 # Flags.
16 DEFINE_string arch "x86" \ 16 DEFINE_string arch "x86" \
17 "The boot architecture: arm or x86. (Default: x86)" 17 "The boot architecture: arm or x86. (Default: x86)"
18 # TODO(wad) once extlinux is dead, we can remove this. 18 # TODO(wad) once extlinux is dead, we can remove this.
19 DEFINE_boolean install_syslinux ${FLAGS_FALSE} \ 19 DEFINE_boolean install_syslinux ${FLAGS_FALSE} \
20 "Controls whether syslinux is run on 'to'. (Default: false)" 20 "Controls whether syslinux is run on 'to'. (Default: false)"
21 DEFINE_string from "/tmp/boot" \ 21 DEFINE_string from "/tmp/boot" \
22 "Path the legacy bootloader templates are copied from. (Default /tmp/boot)" 22 "Path the legacy bootloader templates are copied from. (Default /tmp/boot)"
23 DEFINE_string to "/tmp/esp.img" \ 23 DEFINE_string to "/tmp/esp.img" \
24 "Path to esp image or ARM output MBR (Default: /tmp/esp.img)" 24 "Path to esp image (Default: /tmp/esp.img)"
25 DEFINE_integer to_offset 0 \ 25 DEFINE_integer to_offset 0 \
26 "Offset in bytes into 'to' if it is a file (Default: 0)" 26 "Offset in bytes into 'to' if it is a file (Default: 0)"
27 DEFINE_integer to_size -1 \ 27 DEFINE_integer to_size -1 \
28 "Size in bytes of 'to' to use if it is a file. -1 is ignored. (Default: -1)" 28 "Size in bytes of 'to' to use if it is a file. -1 is ignored. (Default: -1)"
29 DEFINE_string vmlinuz "/tmp/vmlinuz" \ 29 DEFINE_string vmlinuz "/tmp/vmlinuz" \
30 "Path to the vmlinuz file to use (Default: /tmp/vmlinuz)" 30 "Path to the vmlinuz file to use (Default: /tmp/vmlinuz)"
31 # The kernel_partition and the kernel_cmdline each are used to supply 31 # The kernel_partition and the kernel_cmdline each are used to supply
32 # verified boot configuration: dm="". 32 # verified boot configuration: dm="".
33 DEFINE_string kernel_partition "/tmp/vmlinuz.image" \ 33 DEFINE_string kernel_partition "/tmp/vmlinuz.image" \
34 "Path to the signed kernel image. (Default: /tmp/vmlinuz.image)" 34 "Path to the signed kernel image. (Default: /tmp/vmlinuz.image)"
35 DEFINE_string kernel_cmdline "" \ 35 DEFINE_string kernel_cmdline "" \
36 "Kernel commandline if no kernel_partition given. (Default: '')" 36 "Kernel commandline if no kernel_partition given. (Default: '')"
37 DEFINE_string kernel_partition_offset "0" \ 37 DEFINE_string kernel_partition_offset "0" \
38 "Offset to the kernel partition [KERN-A] (Default: 0)" 38 "Offset to the kernel partition [KERN-A] (Default: 0)"
39 DEFINE_string kernel_partition_sectors "0" \ 39 DEFINE_string kernel_partition_sectors "0" \
40 "Kernel partition sectors (Default: 0)" 40 "Kernel partition sectors (Default: 0)"
41 DEFINE_string usb_disk /dev/sdb3 \ 41 DEFINE_string usb_disk /dev/sdb3 \
42 "Path syslinux should use to do a usb (or arm!) boot. Default: /dev/sdb3" 42 "Path syslinux should use to do a usb boot. Default: /dev/sdb3"
43 43
44 # Parse flags 44 # Parse flags
45 FLAGS "$@" || exit 1 45 FLAGS "$@" || exit 1
46 eval set -- "${FLAGS_ARGV}" 46 eval set -- "${FLAGS_ARGV}"
47 set -e 47 set -e
48 48
49 # If not provided by chromeos-common.sh, this will update all of the 49 # If not provided by chromeos-common.sh, this will update all of the
50 # boot loader files (both A and B) with the data pulled 50 # boot loader files (both A and B) with the data pulled
51 # from the kernel_partition. The default boot target should 51 # from the kernel_partition. The default boot target should
52 # be set when the rootfs is stuffed. 52 # be set when the rootfs is stuffed.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 # and replace HDROOTA and HDROOTB with the correct /dev/sd%D%P. 95 # and replace HDROOTA and HDROOTB with the correct /dev/sd%D%P.
96 } 96 }
97 fi 97 fi
98 98
99 ESP_DEV= 99 ESP_DEV=
100 if [[ ! -e "${FLAGS_to}" ]]; then 100 if [[ ! -e "${FLAGS_to}" ]]; then
101 error "The ESP doesn't exist" 101 error "The ESP doesn't exist"
102 # This shouldn't happen. 102 # This shouldn't happen.
103 info "Creating a new esp image at ${FLAGS_to}" anyway. 103 info "Creating a new esp image at ${FLAGS_to}" anyway.
104 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI 104 # Create EFI System Partition to boot stock EFI BIOS (but not ChromeOS EFI
105 # BIOS). We only need this for x86, but it's simpler and safer to keep the 105 # BIOS). ARM uses this space to determine which partition is bootable.
106 # disk images the same for both x86 and ARM.
107 # NOTE: The size argument for mkfs.vfat is in 1024-byte blocks. 106 # NOTE: The size argument for mkfs.vfat is in 1024-byte blocks.
108 # We'll hard-code it to 16M for now. 107 # We'll hard-code it to 16M for now.
109 ESP_BLOCKS=16384 108 ESP_BLOCKS=16384
110 /usr/sbin/mkfs.vfat -C "${FLAGS_to}" ${ESP_BLOCKS} 109 /usr/sbin/mkfs.vfat -C "${FLAGS_to}" ${ESP_BLOCKS}
111 ESP_DEV=$(sudo losetup -f) 110 ESP_DEV=$(sudo losetup -f)
112 if [ -z "${ESP_DEV}" ]; then 111 if [ -z "${ESP_DEV}" ]; then
113 die "No free loop devices." 112 die "No free loop devices."
114 fi 113 fi
115 sudo losetup "${ESP_DEV}" "${FLAGS_to}" 114 sudo losetup "${ESP_DEV}" "${FLAGS_to}"
116 else 115 else
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 elif [[ "${FLAGS_arch}" = "arm" ]]; then 184 elif [[ "${FLAGS_arch}" = "arm" ]]; then
186 # Copy u-boot script to ESP partition 185 # Copy u-boot script to ESP partition
187 if [ -r "${FLAGS_from}/boot-A.scr.uimg" ]; then 186 if [ -r "${FLAGS_from}/boot-A.scr.uimg" ]; then
188 sudo mkdir -p "${ESP_FS_DIR}/u-boot" 187 sudo mkdir -p "${ESP_FS_DIR}/u-boot"
189 sudo cp "${FLAGS_from}/boot-A.scr.uimg" \ 188 sudo cp "${FLAGS_from}/boot-A.scr.uimg" \
190 "${ESP_FS_DIR}/u-boot/boot.scr.uimg" 189 "${ESP_FS_DIR}/u-boot/boot.scr.uimg"
191 fi 190 fi
192 fi 191 fi
193 192
194 set +e 193 set +e
OLDNEW
« no previous file with comments | « image_to_usb.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698