Skip to content

Commit

Permalink
[soft-reboot] Add support for platforms based on Device Tree (#1963)
Browse files Browse the repository at this point in the history
What I did
Add soft-reboot command support for the armhf and arm64 platforms

How I did it
Add logic to retrieve kernel boot arguments from the Device Tree rather than from the GRUB config for these platforms

How to verify it
Execute the soft-reboot command on an armhf or arm64 platform
  • Loading branch information
dflynn-Nokia committed Dec 9, 2021
1 parent 7ceccd7 commit 14889ce
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions scripts/soft-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,33 @@ function setup_reboot_variables()
if grep -q aboot_platform= /host/machine.conf; then
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
elif grep -q onie_platform= /host/machine.conf; then
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
if [ -r /host/grub/grub.cfg ]; then
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
# Handle architectures supporting Device Tree
elif [ -f /sys/firmware/devicetree/base/chosen/bootargs ]; then
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
BOOT_OPTIONS="$(cat /sys/firmware/devicetree/base/chosen/bootargs | sed 's/.$//') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
# If initrd is a U-Boot uImage, remove the uImage header
if file ${INITRD} | grep -q uImage; then
INITRD_RAW=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd-raw.img/g')
tail -c+65 < ${INITRD} > ${INITRD_RAW}
INITRD=${INITRD_RAW}
fi
else
error "Unknown ONIE platform bootloader. ${REBOOT_TYPE} is not supported."
exit "${EXIT_NOT_SUPPORTED}"
fi
else
error "Unknown bootloader. ${REBOOT_TYPE} is not supported."
exit "${EXIT_NOT_SUPPORTED}"
fi
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
}
function load_kernel() {
Expand Down

0 comments on commit 14889ce

Please sign in to comment.