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

Side by Side Diff: bin/cros_make_image_bootable

Issue 3109018: make_image: Install u-boot scripts to ESP partition. (Closed) Base URL: ssh://git@chromiumos-git//crosutils.git
Patch Set: merge. Created 10 years, 4 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
« no previous file with comments | « no previous file | update_bootloaders.sh » ('j') | 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 # Script which ensures that a given image has an up-to-date 7 # Script which ensures that a given image has an up-to-date
8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. 8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs.
9 9
10 # Load common constants. This should be the first executable line. 10 # Load common constants. This should be the first executable line.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 fi 192 fi
193 193
194 # START_KERN_A is set by the first call to install the gpt. 194 # START_KERN_A is set by the first call to install the gpt.
195 local koffset="$(partoffset ${image} 2)" 195 local koffset="$(partoffset ${image} 2)"
196 sudo dd if="${FLAGS_output_dir}/vmlinuz.image" of="${image}" \ 196 sudo dd if="${FLAGS_output_dir}/vmlinuz.image" of="${image}" \
197 conv=notrunc bs=512 seek=${koffset} 197 conv=notrunc bs=512 seek=${koffset}
198 198
199 # Update the bootloaders. For legacy/efi x86, the EFI system partition 199 # Update the bootloaders. For legacy/efi x86, the EFI system partition
200 # will be updated and for arm, the mbr will be updated (for u-boot). 200 # will be updated and for arm, the mbr will be updated (for u-boot).
201 local kernel_part= 201 local kernel_part=
202 local bootloader_to=
203 local bootloader_to_flags=
204 local usb_disk="${FLAGS_usb_disk}" 202 local usb_disk="${FLAGS_usb_disk}"
205 203
204 # We should update the esp in place in the image.
205 local bootloader_to="${image}"
206 local esp_offset="$(partoffset ${image} 12)"
207 esp_offset=$((esp_offset * 512)) # sectors to bytes
208 local esp_size="$(partsize ${image} 12)"
209 esp_size=$((esp_size * 512)) # sectors to bytes
210 local bootloader_to_flags="--to_offset=${esp_offset} --to_size=${esp_size}"
211
206 if [[ "${FLAGS_arch}" = "x86" ]]; then 212 if [[ "${FLAGS_arch}" = "x86" ]]; then
207 # x86 should update the esp in place in the image.
208 bootloader_to="${image}"
209 local esp_offset="$(partoffset ${image} 12)"
210 esp_offset=$((esp_offset * 512)) # sectors to bytes
211 local esp_size="$(partsize ${image} 12)"
212 esp_size=$((esp_size * 512)) # sectors to bytes
213 bootloader_to_flags="--to_offset=${esp_offset} --to_size=${esp_size}"
214 # Use the kernel partition to acquire configuration flags. 213 # Use the kernel partition to acquire configuration flags.
215 kernel_part="--kernel_partition='${FLAGS_output_dir}/vmlinuz.image'" 214 kernel_part="--kernel_partition='${FLAGS_output_dir}/vmlinuz.image'"
216 # Install syslinux on the EFI System Partition. 215 # Install syslinux on the EFI System Partition.
217 kernel_part="${kernel_part} --install_syslinux" 216 kernel_part="${kernel_part} --install_syslinux"
218 elif [[ "${FLAGS_arch}" = "arm" ]]; then 217 elif [[ "${FLAGS_arch}" = "arm" ]]; then
219 # TODO(wad) mmcblk1p3 is hardcoded for arm for now! 218 # TODO(wad) mmcblk1p3 is hardcoded for arm for now!
220 usb_disk="/dev/mmcblk1p3" 219 usb_disk="/dev/mmcblk1p3"
221 # ARM doesn't support using the kernel image for kernel cmdline flags yet. 220 # ARM doesn't support using the kernel image for kernel cmdline flags yet.
222 kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" " 221 kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" "
223 # TODO(wad) Integrate dmtable extraction into the arm build 222 # TODO(wad) Integrate dmtable extraction into the arm build
224 # E.g. $(cat ${FLAGS_output_dir}/boot.config | tr -s '\n' ' ')" 223 # E.g. $(cat ${FLAGS_output_dir}/boot.config | tr -s '\n' ' ')"
225 local kpart_offset="--kernel_partition_offset=${koffset}" 224 local kpart_offset="--kernel_partition_offset=${koffset}"
226 local kpart_size="--kernel_partition_sectors=" 225 local kpart_size="--kernel_partition_sectors="
227 kpart_size="${kpart_size}$(partsize ${image} 2)" 226 kpart_size="${kpart_size}$(partsize ${image} 2)"
228 kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}" 227 kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}"
229 info "Using addition bootloader arguments: ${kernel_part}" 228 info "Using addition bootloader arguments: ${kernel_part}"
230 bootloader_to="${FLAGS_output_dir}/arm.mbr"
231 fi 229 fi
232 230
233 # Update partition 12 / legacy bootloaders and arm. 231 # Update partition 12
234 ${SCRIPTS_DIR}/update_bootloaders.sh \ 232 ${SCRIPTS_DIR}/update_bootloaders.sh \
235 --arch=${FLAGS_arch} \ 233 --arch=${FLAGS_arch} \
236 --to="${bootloader_to}" \ 234 --to="${bootloader_to}" \
237 --from="${FLAGS_rootfs_mountpoint}"/boot \ 235 --from="${FLAGS_rootfs_mountpoint}"/boot \
238 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \ 236 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \
239 --usb_disk="${usb_disk}" \ 237 --usb_disk="${usb_disk}" \
240 ${bootloader_to_flags} \ 238 ${bootloader_to_flags} \
241 $kernel_part 239 $kernel_part
242 240
243 if [[ "${FLAGS_arch}" == "arm" ]]; then
244 sudo dd bs=1 conv=notrunc if="${bootloader_to}" of="${image}"
245 sudo rm "${bootloader_to}"
246 fi
247
248 trap - EXIT 241 trap - EXIT
249 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \ 242 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \
250 -s "${FLAGS_statefulfs_mountpoint}" 243 -s "${FLAGS_statefulfs_mountpoint}"
251 } 244 }
252 245
253 # Create the directories if they don't exist. 246 # Create the directories if they don't exist.
254 mkdir -p ${FLAGS_rootfs_mountpoint} 247 mkdir -p ${FLAGS_rootfs_mountpoint}
255 mkdir -p ${FLAGS_statefulfs_mountpoint} 248 mkdir -p ${FLAGS_statefulfs_mountpoint}
256 mkdir -p ${FLAGS_espfs_mountpoint} 249 mkdir -p ${FLAGS_espfs_mountpoint}
257 250
258 make_image_bootable ${IMAGE} 251 make_image_bootable ${IMAGE}
259 252
260 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then 253 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then
261 rmdir ${FLAGS_rootfs_mountpoint} 254 rmdir ${FLAGS_rootfs_mountpoint}
262 rmdir ${FLAGS_statefulfs_mountpoint} 255 rmdir ${FLAGS_statefulfs_mountpoint}
263 rmdir ${FLAGS_espfs_mountpoint} 256 rmdir ${FLAGS_espfs_mountpoint}
264 fi 257 fi
OLDNEW
« no previous file with comments | « no previous file | update_bootloaders.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698