mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 05:26:58 +02:00
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
This commit is contained in:
parent
fd38b5bdfe
commit
f53fa0d5f8
@ -66,6 +66,17 @@ function learn_board() {
|
|||||||
info "Target reports board is ${FLAGS_board}"
|
info "Target reports board is ${FLAGS_board}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function learn_arch() {
|
||||||
|
[ -n "${FLAGS_arch}" ] && return
|
||||||
|
remote_sh uname -m
|
||||||
|
FLAGS_arch=$(echo "${REMOTE_OUT}" | sed s/armv7l/arm/g)
|
||||||
|
if [ -z "${FLAGS_arch}" ]; then
|
||||||
|
error "Arch required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
info "Target reports arch is ${FLAGS_arch}"
|
||||||
|
}
|
||||||
|
|
||||||
function remote_reboot {
|
function remote_reboot {
|
||||||
info "Rebooting."
|
info "Rebooting."
|
||||||
remote_sh "touch /tmp/awaiting_reboot; reboot"
|
remote_sh "touch /tmp/awaiting_reboot; reboot"
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
restart_in_chroot_if_needed $*
|
restart_in_chroot_if_needed $*
|
||||||
|
|
||||||
DEFINE_string board "" "Override board reported by target"
|
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 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 modules false "Update modules on target"
|
||||||
DEFINE_boolean firmware false "Update firmware on target"
|
DEFINE_boolean firmware false "Update firmware on target"
|
||||||
|
|
||||||
@ -33,14 +35,21 @@ function cleanup {
|
|||||||
rm -rf "${TMP}"
|
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
|
# Ask the target what the kernel partition is
|
||||||
function learn_partition() {
|
function learn_partition() {
|
||||||
[ -n "${FLAGS_partition}" ] && return
|
[ -n "${FLAGS_partition}" ] && return
|
||||||
remote_sh cat /proc/cmdline
|
remote_sh cat /proc/cmdline
|
||||||
if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then
|
if echo "${REMOTE_OUT}" | egrep -q "${FLAGS_device}3"; then
|
||||||
FLAGS_partition="/dev/sda2"
|
FLAGS_partition="${FLAGS_device}2"
|
||||||
else
|
else
|
||||||
FLAGS_partition="/dev/sda4"
|
FLAGS_partition="${FLAGS_device}4"
|
||||||
fi
|
fi
|
||||||
if [ -z "${FLAGS_partition}" ]; then
|
if [ -z "${FLAGS_partition}" ]; then
|
||||||
error "Partition required"
|
error "Partition required"
|
||||||
@ -49,6 +58,23 @@ function learn_partition() {
|
|||||||
info "Target reports kernel partition is ${FLAGS_partition}"
|
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() {
|
function main() {
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
@ -56,21 +82,19 @@ function main() {
|
|||||||
|
|
||||||
remote_access_init
|
remote_access_init
|
||||||
|
|
||||||
|
learn_arch
|
||||||
|
|
||||||
learn_board
|
learn_board
|
||||||
|
|
||||||
|
learn_device
|
||||||
|
|
||||||
|
learn_partition
|
||||||
|
|
||||||
remote_sh uname -r -v
|
remote_sh uname -r -v
|
||||||
|
|
||||||
old_kernel="${REMOTE_OUT}"
|
old_kernel="${REMOTE_OUT}"
|
||||||
|
|
||||||
vbutil_kernel --pack new_kern.bin \
|
make_kernelimage
|
||||||
--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
|
|
||||||
|
|
||||||
remote_cp_to new_kern.bin /tmp
|
remote_cp_to new_kern.bin /tmp
|
||||||
|
|
||||||
@ -78,9 +102,9 @@ function main() {
|
|||||||
|
|
||||||
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
|
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
|
||||||
echo "copying modules"
|
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 mount -o remount,rw /
|
||||||
remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar
|
remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar
|
||||||
@ -88,9 +112,9 @@ function main() {
|
|||||||
|
|
||||||
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
|
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
|
||||||
echo "copying firmware"
|
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 mount -o remount,rw /
|
||||||
remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar
|
remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar
|
||||||
@ -103,4 +127,4 @@ function main() {
|
|||||||
info "new kernel: ${REMOTE_OUT}"
|
info "new kernel: ${REMOTE_OUT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user