build_image: Add verity support for ARM.

- Build a "kernel image" which contains a uboot script and a uboot kernel
  image.
- Fix some sd* assumptions.
- Remove cruft that has never done anything usefull from update_bootloaders

BUG=none
TEST=Built, booted, and updated on tegra2_dev-board

Review URL: http://codereview.chromium.org/3396011

Change-Id: I00ecf57faa5fe64c8e33dd4c042f1dbed806c10a
This commit is contained in:
Kenneth Waters 2010-09-21 10:29:54 -07:00
parent bf9178b36e
commit ed54d93e2c
4 changed files with 41 additions and 36 deletions

View File

@ -125,8 +125,7 @@ make_image_bootable() {
cros_root=/dev/sd%D%P cros_root=/dev/sd%D%P
if [[ "${FLAGS_arch}" = "arm" ]]; then if [[ "${FLAGS_arch}" = "arm" ]]; then
# TODO(wad) assumed like in build_gpt for now. cros_root='/dev/${devname}${rootpart}'
cros_root=/dev/mmcblk1p3
fi fi
if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
cros_root=/dev/dm-0 cros_root=/dev/dm-0

View File

@ -241,13 +241,6 @@ esac
if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
enable_rootfs_verification_flag="--enable_rootfs_verification" enable_rootfs_verification_flag="--enable_rootfs_verification"
# Comment out this section if you need to start testing vboot on arm.
if [[ "${ARCH}" = "arm" ]]; then
warn "ARM does not yet support --enable_rootfs_verification"
warn "Root filesystem verification has been disabled."
enable_rootfs_verification_flag=
FLAGS_enable_rootfs_verification_flag=${FLAGS_FALSE}
fi
fi fi
# Hack to fix bug where x86_64 CHOST line gets incorrectly added. # Hack to fix bug where x86_64 CHOST line gets incorrectly added.

View File

@ -88,8 +88,13 @@ if [[ -n "${FLAGS_rootfs_image}" && -n "${FLAGS_rootfs_hash}" ]]; then
# the verified boot device. Doing so will claim /dev/sdDP out from # the verified boot device. Doing so will claim /dev/sdDP out from
# under the system. # under the system.
if [[ ${FLAGS_root} = "/dev/dm-0" ]]; then if [[ ${FLAGS_root} = "/dev/dm-0" ]]; then
table=${table//HASH_DEV//dev/sd%D%P} if [[ "${FLAGS_arch}" = "x86" ]]; then
table=${table//ROOT_DEV//dev/sd%D%P} base_root='/dev/sd%D%P'
elif [[ "${FLAGS_arch}" = "arm" ]]; then
base_root='/dev/${devname}${rootpart}'
fi
table=${table//HASH_DEV/${base_root}}
table=${table//ROOT_DEV/${base_root}}
fi fi
verity_args="dm=\"vroot none ro,${table}\"" verity_args="dm=\"vroot none ro,${table}\""
info "dm-verity configuration: ${verity_args}" info "dm-verity configuration: ${verity_args}"
@ -188,8 +193,39 @@ EOF
trap - EXIT trap - EXIT
elif [[ "${FLAGS_arch}" = "arm" ]]; then elif [[ "${FLAGS_arch}" = "arm" ]]; then
# FIXME: For now, ARM just uses the unsigned kernel by itself. # FIXME: This stuff is unsigned, and will likely change with vboot_reference
cp -f "${FLAGS_vmlinuz}" "${FLAGS_to}" # but it doesn't technically have to.
kernel_script="${FLAGS_working_dir}/kernel.scr"
kernel_script_img="${FLAGS_working_dir}/kernel.scr.uimg"
# HACK: !! Kernel image construction requires some stuff from portage, not
# sure how to get that information here cleanly !!
kernel_image="${FLAGS_vmlinuz/vmlinuz/vmlinux.uimg}"
WORK="${WORK} ${kernel_script} ${kernel_script_img}"
kernel_size=$((($(stat -c %s "${kernel_image}") + 511) / 512))
script_size=16
# Build boot script image
echo -n 'setenv bootargs ${bootargs} ' > "${kernel_script}"
tr '\n' ' ' <"${FLAGS_working_dir}/boot.config" >> "${kernel_script}"
echo >> "${kernel_script}"
printf 'read ${devtype} 0:${kernelpart} ${loadaddr} %x %x\n' \
${script_size} ${kernel_size} >> "${kernel_script}"
echo 'bootm ${loadaddr}' >> ${kernel_script}
mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
-n kernel_script -d "${kernel_script}" "${kernel_script_img}"
if [ $(stat -c %s "${kernel_script_img}") -gt $((512 * ${script_size})) ]
then
echo 'Kernel script too large for reserved space.'
exit 1
fi
# Assemble image
rm -f "${FLAGS_to}"
dd if="${kernel_script_img}" of="${FLAGS_to}" bs=512 count="${script_size}"
dd if="${kernel_image}" of="${FLAGS_to}" bs=512 seek="${script_size}"
else else
error "Unknown arch: ${FLAGS_arch}" error "Unknown arch: ${FLAGS_arch}"
fi fi

View File

@ -183,29 +183,6 @@ if [[ "${FLAGS_arch}" = "x86" ]]; then
sudo syslinux -d /syslinux "${ESP_DEV}" sudo syslinux -d /syslinux "${ESP_DEV}"
fi fi
elif [[ "${FLAGS_arch}" = "arm" ]]; then elif [[ "${FLAGS_arch}" = "arm" ]]; then
# Extract kernel flags
kernel_cfg=
old_root="sd%D%P"
if [[ -n "${FLAGS_kernel_cmdline}" ]]; then
info "Using supplied kernel_cmdline to update templates."
kernel_cfg="${FLAGS_kernel_cmdline}"
elif [[ -n "${FLAGS_kernel_partition}" ]]; then
info "Extracting the kernel command line from ${FLAGS_kernel_partition}"
kernel_cfg=$(dump_kernel_config "${kernel_partition}")
fi
dm_table=
if echo "$kernel_cfg" | grep -q 'dm="'; then
dm_table=$(echo "$kernel_cfg" | sed -s 's/.*dm="\([^"]*\)".*/\1/')
fi
# TODO(wad) assume usb_disk contains the arm boot location for now.
new_root="${FLAGS_usb_disk}"
info "Replacing dm slave devices with /dev/${new_root}"
dm_table="${dm_table//ROOT_DEV/\/dev\/${new_root}}"
dm_table="${dm_table//HASH_DEV/\/dev\/${new_root}}"
warn "FIXME: cannot replace root= here for the arm bootloader yet."
dm_table="" # TODO(wad) Clear it until we can fix root=/dev/dm-0
# Copy u-boot script to ESP partition # Copy u-boot script to ESP partition
if [ -r "${FLAGS_from}/boot-A.scr.uimg" ]; then if [ -r "${FLAGS_from}/boot-A.scr.uimg" ]; then
sudo mkdir -p "${ESP_FS_DIR}/u-boot" sudo mkdir -p "${ESP_FS_DIR}/u-boot"