update_kernel: first cut at arm support
Change-Id: I5dc22223559d3cdad357530af66c14115da63c89
BUG=n0ne
TEST=update_kernel to seaboard (and mario for regression test)
Review URL: http://codereview.chromium.org/6031005
diff --git a/update_kernel.sh b/update_kernel.sh
index d1b735d..2c99723 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -16,7 +16,9 @@
restart_in_chroot_if_needed $*
DEFINE_string board "" "Override board reported by target"
+DEFINE_string device "" "Override boot device reported by target"
DEFINE_string partition "" "Override kernel partition reported by target"
+DEFINE_string arch "" "Override architecture reported by target"
DEFINE_boolean modules false "Update modules on target"
DEFINE_boolean firmware false "Update firmware on target"
@@ -33,14 +35,21 @@
rm -rf "${TMP}"
}
+function learn_device() {
+ [ -n "${FLAGS_device}" ] && return
+ remote_sh df /mnt/stateful_partition
+ FLAGS_device=$(echo "${REMOTE_OUT}" | awk '/dev/ {print $1}' | sed s/1\$//)
+ info "Target reports root device is ${FLAGS_device}"
+}
+
# Ask the target what the kernel partition is
function learn_partition() {
[ -n "${FLAGS_partition}" ] && return
remote_sh cat /proc/cmdline
- if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then
- FLAGS_partition="/dev/sda2"
+ if echo "${REMOTE_OUT}" | egrep -q "${FLAGS_device}3"; then
+ FLAGS_partition="${FLAGS_device}2"
else
- FLAGS_partition="/dev/sda4"
+ FLAGS_partition="${FLAGS_device}4"
fi
if [ -z "${FLAGS_partition}" ]; then
error "Partition required"
@@ -49,6 +58,23 @@
info "Target reports kernel partition is ${FLAGS_partition}"
}
+function make_kernelimage() {
+
+ if [[ "${FLAGS_arch}" == "arm" ]]; then
+ ./build_kernel_image.sh --arch=arm \
+ --root='/dev/${devname}${rootpart}' \
+ --vmlinuz=/build/${FLAGS_board}/boot/vmlinux.uimg --to new_kern.bin
+ else
+ vbutil_kernel --pack new_kern.bin \
+ --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
+ --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
+ --version 1 \
+ --config ../build/images/${FLAGS_board}/latest/config.txt \
+ --bootloader /lib64/bootstub/bootstub.efi \
+ --vmlinuz /build/${FLAGS_board}/boot/vmlinuz
+ fi
+}
+
function main() {
trap cleanup EXIT
@@ -56,21 +82,19 @@
remote_access_init
+ learn_arch
+
learn_board
+ learn_device
+
+ learn_partition
+
remote_sh uname -r -v
old_kernel="${REMOTE_OUT}"
- vbutil_kernel --pack new_kern.bin \
- --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
- --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
- --version 1 \
- --config ../build/images/"${FLAGS_board}"/latest/config.txt \
- --bootloader /lib64/bootstub/bootstub.efi \
- --vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz
-
- learn_partition
+ make_kernelimage
remote_cp_to new_kern.bin /tmp
@@ -78,9 +102,9 @@
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
echo "copying modules"
- tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar .
+ tar -C /build/"${FLAGS_board}"/lib/modules -cjf /tmp/new_modules.tar .
- remote_cp_to new_modules.tar /tmp/
+ remote_cp_to /tmp/new_modules.tar /tmp/
remote_sh mount -o remount,rw /
remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar
@@ -88,9 +112,9 @@
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
echo "copying firmware"
- tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar .
+ tar -C /build/"${FLAGS_board}"/lib/firmware -cjf /tmp/new_firmware.tar .
- remote_cp_to new_firmware.tar /tmp/
+ remote_cp_to /tmp/new_firmware.tar /tmp/
remote_sh mount -o remount,rw /
remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar
@@ -103,4 +127,4 @@
info "new kernel: ${REMOTE_OUT}"
}
-main $@
+main "$@"