Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[soft-reboot] Add support for platforms based on Device Tree #1963

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

dflynn-Nokia
Copy link
Contributor

The soft-reboot command currently expects a platform that uses GRUB.
Information about the current kernel boot arguments is extracted from the
GRUB config file. This commit adds support for platforms that do not use GRUB
but rather uses Device Tree to define the current kernel boot arguments.
Example platform architectures using Device Tree include armhf and arm64.

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

Previous command output (if the output of a command-line utility has changed)

sudo soft-reboot
Error response from daemon: Container 68b38ffde1c8a95922eed7706a2f92c46e5b6582539cecc4aaa7263803db56e3 is not running
cat: /host/grub/grub.cfg: No such file or directory
requested COLD shutdown
syscall kexec_file_load not available.
Read on /host failed: Is a directory
Cannot read /hostFailed to arm Watchdog for 180 seconds
Nothing has been loaded!

New command output (if the output of a command-line utility has changed)

Successful reboot via kexec to Sonic login prompt

The soft-reboot command currently expects a platform that uses GRUB.
Information about the current kernel boot arguments is extracted from the
GRUB config file. This commit adds support for platforms that do not use GRUB
but rather uses Device Tree to define the current kernel boot arguments.
Example platform architectures using Device Tree include armhf and arm64.
sujinmkang
sujinmkang previously approved these changes Dec 8, 2021
# 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/.$/\n/')" SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you add "\n" new line before SONIC_BOOT_TYPE ?
And also don't you need to put the first " in front instead of next ')' as below?
BOOT_OPTIONS="$(cat /sys/firmware/devicetree/base/chosen/bootargs | sed 's/.$/\n/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both good points.
The contents of /sys/firmware/devicetree/base/chosen/bootargs includes a trailing null character that yields a warning during the variable assignment. I replaced that with '\n' but better to just strip it away.
Your suggestion for " placement also works and looks cleaner.
I'll make these changes.

Thanks,

@sujinmkang
Copy link
Collaborator

@dflynn-Nokia Can you also please share the show reboot-cause output and the reboot-cause determination syslog message?
you can grep the log messages with sudo zgrep reboot-cause /var/log/syslog.

@sujinmkang sujinmkang self-assigned this Dec 8, 2021
@dflynn-Nokia
Copy link
Contributor Author

dflynn-Nokia commented Dec 8, 2021

As you requested, here's the reboot-cause info from syslog
Note that I first did a normal reboot followed by a soft-reboot.

admin@localhost:~$ sudo zgrep reboot-cause /var/log/syslog
Dec 8 22:38:31.189792 localhost INFO systemd[1]: process-reboot-cause.timer: Succeeded.
Dec 8 22:38:31.190008 localhost INFO systemd[1]: Stopped Delays process-reboot-cause until network is stably connected.
Dec 8 22:39:26.070231 localhost INFO systemd[1]: Started Delays process-reboot-cause until network is stably connected.
Dec 8 22:39:40.789338 localhost INFO determine-reboot-cause: Starting up...
Dec 8 22:39:40.813349 localhost INFO determine-reboot-cause: No reboot cause found from /proc/cmdline
Dec 8 22:39:41.622787 localhost INFO chassis: /host/reboot-cause/reboot-cause.txt indicates the reboot cause: User issued 'reboot' command [User: admin, Time: Wed 08 Dec 2021 10:38:17 PM UTC]
Dec 8 22:39:41.960583 localhost INFO systemd[1]: determine-reboot-cause.service: Succeeded.
Dec 8 22:40:54.364948 localhost INFO process-reboot-cause: Starting up...
Dec 8 22:40:54.365358 localhost INFO process-reboot-cause: Previous reboot cause: User issued 'reboot' command [User: admin, Time: Wed 08 Dec 2021 10:38:17 PM UTC]
Dec 8 22:40:54.407038 localhost INFO systemd[1]: process-reboot-cause.service: Succeeded.
Dec 8 22:41:28.013736 localhost INFO systemd[1]: Started Delays process-reboot-cause until network is stably connected.
Dec 8 22:41:45.770350 localhost INFO determine-reboot-cause: Starting up...
Dec 8 22:41:45.796083 localhost INFO determine-reboot-cause: No reboot cause found from /proc/cmdline
Dec 8 22:41:46.608570 localhost INFO chassis: /host/reboot-cause/reboot-cause.txt indicates the reboot cause: User issued 'soft-reboot' command [User: admin, Time: Wed 08 Dec 2021 10:40:59 PM UTC]
Dec 8 22:41:46.959148 localhost INFO systemd[1]: determine-reboot-cause.service: Succeeded.

And here's the value of /proc/cmdline after soft-reboot

admin@localhost:~$ cat /proc/cmdline
root=/dev/sda2 rw rootwait rootfstype=ext4 panic=1 console=ttyS0,115200 mtdparts=spi0.0:4m(boot),-(spi-rootfs) net.ifnames=0 loopfstype=squashfs loop=image-202012.0-f93d1f64a/fs.squashfs systemd.unified_cgroup_hierarchy=0 varlog_size=512 loglevel=4 SONIC_BOOT_TYPE=soft

@sujinmkang sujinmkang merged commit 14889ce into sonic-net:master Dec 9, 2021
@dflynn-Nokia dflynn-Nokia deleted the soft-reboot-devtree branch December 9, 2021 14:35
qiluo-msft pushed a commit that referenced this pull request Dec 20, 2021
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
judyjoseph pushed a commit that referenced this pull request Jan 9, 2022
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
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
Update submodule sonic-utilities that contains the following commits:

Revert "[202012] [generate_dump] allow to extend dump with plugin scripts (sonic-net#1945)" (sonic-net#1993)
[soft-reboot] Add support for platforms based on Device Tree (sonic-net#1963)
[Reclaiming buffer][202012] Database migrator for reclaiming buffer (sonic-net#1898)
[202012] [generate_dump] allow to extend dump with plugin scripts (sonic-net#1945)

Signed-off-by: dprital <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants