From patchwork Tue Feb 1 15:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivanand Kunijadar X-Patchwork-Id: 12731920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DA65C433FE for ; Tue, 1 Feb 2022 15:40:16 +0000 (UTC) Received: from mo-csw.securemx.jp (mo-csw.securemx.jp [210.130.202.156]) by mx.groups.io with SMTP id smtpd.web12.49803.1643730015419980166 for ; Tue, 01 Feb 2022 07:40:15 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: toshiba-tsip.com, ip: 210.130.202.156, mailfrom: shivanand.kunijadar@toshiba-tsip.com) Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 211FeCu1018489; Wed, 2 Feb 2022 00:40:13 +0900 X-Iguazu-Qid: 2wGrYolv9doEUs4Ttx X-Iguazu-QSIG: v=2; s=0; t=1643730012; q=2wGrYolv9doEUs4Ttx; m=k58yQtv9rpseyaCOny6rRdLZjSmb52viMqhuNwl5psU= Received: from imx12-a.toshiba.co.jp (imx12-a.toshiba.co.jp [61.202.160.135]) by relay.securemx.jp (mx-mr1112) id 211FeBV0039156 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 2 Feb 2022 00:40:12 +0900 From: Shivanand.Kunijadar@toshiba-tsip.com To: cip-dev@lists.cip-project.org, jan.kiszka@siemens.com, quirin.gylstorff@siemens.com Cc: Shivanand Kunijadar , dinesh.kumar@toshiba-tsip.com, kazuhiro3.hayashi@toshiba.co.jp, akihiro27.suzuki@toshiba.co.jp Subject: [isar-cip-core v2 1/2] Add recipe to cause kernel panic during system boot Date: Tue, 1 Feb 2022 21:05:01 +0530 X-TSB-HOP: ON X-TSB-HOP2: ON Message-Id: <20220201153502.14230-2-Shivanand.Kunijadar@toshiba-tsip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <52fae1ea-25fc-e692-2b51-e503681d2efb@siemens.com> References: <52fae1ea-25fc-e692-2b51-e503681d2efb@siemens.com> MIME-Version: 1.0 X-OriginalArrivalTime: 01 Feb 2022 15:39:54.0449 (UTC) FILETIME=[F5808410:01D81781] List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 01 Feb 2022 15:40:16 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/7559 From: Shivanand Kunijadar This recipe adds systemd service to cause kernel panic during system boot. It helps to check the swupdate-rollback feature. Signed-off-by: Shivanand Kunijadar --- kas/opt/kernel-panic.yml | 18 ++++++++++++++ .../kernel-panic/files/sysrq-panic.service | 10 ++++++++ recipes-core/kernel-panic/kernel-panic.bb | 24 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 kas/opt/kernel-panic.yml create mode 100644 recipes-core/kernel-panic/files/sysrq-panic.service create mode 100644 recipes-core/kernel-panic/kernel-panic.bb diff --git a/kas/opt/kernel-panic.yml b/kas/opt/kernel-panic.yml new file mode 100644 index 0000000..47df7b1 --- /dev/null +++ b/kas/opt/kernel-panic.yml @@ -0,0 +1,18 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Toshiba Corporation, 2022 +# +# Authors: +# Shivanand Kunijadar +# +# SPDX-License-Identifier: MIT +# +# This kas file adds systemd service file to cause kernel panic during system boot. + +header: + version: 10 + +local_conf_header: + kernel-panic: | + IMAGE_INSTALL_append = " kernel-panic" diff --git a/recipes-core/kernel-panic/files/sysrq-panic.service b/recipes-core/kernel-panic/files/sysrq-panic.service new file mode 100644 index 0000000..169a97c --- /dev/null +++ b/recipes-core/kernel-panic/files/sysrq-panic.service @@ -0,0 +1,10 @@ +[Unit] +Description=sysrq panic + +[Service] +Type=oneshot +ExecStart=/bin/sh -c "echo c > /proc/sysrq-trigger" + +[Install] +WantedBy=default.target + diff --git a/recipes-core/kernel-panic/kernel-panic.bb b/recipes-core/kernel-panic/kernel-panic.bb new file mode 100644 index 0000000..511febb --- /dev/null +++ b/recipes-core/kernel-panic/kernel-panic.bb @@ -0,0 +1,24 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Toshiba Corporation, 2022 +# +# Authors: +# Shivanand Kunijadar +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg-raw + +DESCRIPTION = "Systemd service file to cause kernel panic" + +SRC_URI = " \ + file://sysrq-panic.service" + +do_install() { + install -v -d ${D}/lib/systemd/system + install -v -m 0644 ${WORKDIR}/sysrq-panic.service ${D}/lib/systemd/system/ + install -v -d ${D}/etc/systemd/system/default.target.wants + ln -s /lib/systemd/system/sysrq-panic.service ${D}/etc/systemd/system/default.target.wants/ +} From patchwork Tue Feb 1 15:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shivanand Kunijadar X-Patchwork-Id: 13005293 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mo-csw.securemx.jp (mo-csw.securemx.jp [210.130.202.156]) by mx.groups.io with SMTP id smtpd.web12.49804.1643730015622065525 for ; Tue, 01 Feb 2022 07:40:16 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: toshiba-tsip.com, ip: 210.130.202.156, mailfrom: shivanand.kunijadar@toshiba-tsip.com) Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 211FeCPW018488; Wed, 2 Feb 2022 00:40:13 +0900 X-Iguazu-Qid: 2wGrYolv9doEUs4Ttw X-Iguazu-QSIG: v=2; s=0; t=1643730012; q=2wGrYolv9doEUs4Ttw; m=DouDAPdje4NGp1V/YNbNK8pPPKpnsw+gEHah8+2W79c= Received: from imx12-a.toshiba.co.jp (imx12-a.toshiba.co.jp [61.202.160.135]) by relay.securemx.jp (mx-mr1111) id 211FeB7e006382 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 2 Feb 2022 00:40:12 +0900 From: "Kunijadar Shivanand" To: cip-dev@lists.cip-project.org, jan.kiszka@siemens.com, quirin.gylstorff@siemens.com Cc: Shivanand Kunijadar , dinesh.kumar@toshiba-tsip.com, kazuhiro3.hayashi@toshiba.co.jp, akihiro27.suzuki@toshiba.co.jp Subject: [isar-cip-core v2 2/2] README.swupdate.md: add readme file with steps to verify swupdate Date: Tue, 1 Feb 2022 21:05:02 +0530 X-TSB-HOP: ON X-TSB-HOP2: ON Message-Id: <20220201153502.14230-3-Shivanand.Kunijadar@toshiba-tsip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <52fae1ea-25fc-e692-2b51-e503681d2efb@siemens.com> References: <52fae1ea-25fc-e692-2b51-e503681d2efb@siemens.com> MIME-Version: 1.0 X-OriginalArrivalTime: 01 Feb 2022 15:39:54.0496 (UTC) FILETIME=[F587B000:01D81781] List-Id: From: Shivanand Kunijadar Prepare readme file with necessary steps to verify swupdate feature with rollback functionality. Signed-off-by: Shivanand Kunijadar --- doc/README.swupdate.md | 208 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 doc/README.swupdate.md diff --git a/doc/README.swupdate.md b/doc/README.swupdate.md new file mode 100644 index 0000000..56bc77c --- /dev/null +++ b/doc/README.swupdate.md @@ -0,0 +1,208 @@ + +Clone the isar-cip-core repository +``` +host$ git clone https://gitlab.com/cip-project/cip-core/isar-cip-core.git +``` + +Install `kas-container` from the [kas project](https://github.com/siemens/kas): + +``` +host$ wget https://raw.githubusercontent.com/siemens/kas/2.6.2/kas-container +host$ chmod a+x kas-container +``` + +Build the image for swupdate + +``` +host$ ./kas-container --isar build kas-cip.yml:kas/board/qemu-amd64.yml:kas/opt/ebg-swu.yml +``` +- save the generated swu build/tmp/deploy/images/qemu-amd64/cip-core-image-cip-core-buster-qemu-amd64.swu in a separate folder (ex: tmp) +- modify the image for example add a new version to the image by adding PV=2.0.0 to cip-core-image.bb +- rebuild the image using above command and start the new target +``` +host$ SWUPDATE_BOOT=y ./start-qemu.sh amd64 +``` + +Copy `cip-core-image-cip-core-buster-qemu-amd64.swu` file from `tmp` folder to the running system + +``` +root@demo:~# scp @:/tmp/cip-core-image-cip-core-buster-qemu-amd64.swu . +``` + +Check which partition is booted, e.g. with lsblk: + +``` +root@demo:~# lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sda 8:0 0 2G 0 disk +├─sda1 8:1 0 16.4M 0 part +├─sda2 8:2 0 32M 0 part +├─sda3 8:3 0 32M 0 part +├─sda4 8:4 0 1000M 0 part / +└─sda5 8:5 0 1000M 0 part +``` + +Apply swupdate and reboot +``` +root@demo:~# swupdate -i cip-core-image-cip-core-buster-qemu-amd64.swu +root@demo:~# reboot +``` +Check which partition is booted, e.g. with lsblk and the rootfs should have changed +``` +root@demo:~# lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sda 8:0 0 2G 0 disk +├─sda1 8:1 0 16.4M 0 part +├─sda2 8:2 0 32M 0 part +├─sda3 8:3 0 32M 0 part +├─sda4 8:4 0 1000M 0 part +└─sda5 8:5 0 1000M 0 part / +``` + +Check bootloader ustate after swupdate +``` +root@demo:~# bg_printenv +---------------------------- +Config Partition #0 Values: +in_progress: no +revision: 2 +kernel: C:BOOT0:cip-core-image-cip-core-buster-qemu-amd64-vmlinuz +kernelargs: console=tty0 console=ttyS0,115200 rootwait earlyprintk root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000001 rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 0 (OK) + +user variables: + +---------------------------- + Config Partition #1 Values: +in_progress: no +revision: 3 +kernel: C:BOOT1:vmlinuz +kernelargs: root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000002 console=tty0 console=ttyS0,115200 rootwait earlyprintk rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 2 (TESTING) +``` + +if Partition #1 usate is 2 (TESTING) then execute below command to confirm swupdate and the command will set ustate to "OK" +``` +root@demo:~# bg_setenv -c +``` + +# swupdate rollback example + +Build the image for swupdate with service which causes kernel panic during system boot using below command. + +``` +host$ ./kas-container --isar build kas-cip.yml:kas/board/qemu-amd64.yml:kas/opt/ebg-swu.yml:kas/opt/kernel-panic.yml +``` +- save the generated swu build/tmp/deploy/images/qemu-amd64/cip-core-image-cip-core-buster-qemu-amd64.swu in a separate folder (ex: tmp) +- build the image again without `kernel-panic.yml` recipe using below command +``` +host$ ./kas-container --isar build kas-cip.yml:kas/board/qemu-amd64.yml:kas/opt/ebg-swu.yml +``` + +Start the target on QEMU +``` +host$ SWUPDATE_BOOT=y ./start-qemu.sh amd64 +``` + +Copy `cip-core-image-cip-core-buster-qemu-amd64.swu` file from `tmp` folder to the running system + +``` +root@demo:~# scp @:/tmp/cip-core-image-cip-core-buster-qemu-amd64.swu . +``` + +Check which partition is booted, e.g. with lsblk: + +``` +root@demo:~# lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sda 8:0 0 2G 0 disk +├─sda1 8:1 0 16.4M 0 part +├─sda2 8:2 0 32M 0 part +├─sda3 8:3 0 32M 0 part +├─sda4 8:4 0 1000M 0 part / +└─sda5 8:5 0 1000M 0 part +``` + +Check bootloader ustate before swupdate and should be as below +``` +root@demo:~# bg_printenv +---------------------------- +Config Partition #0 Values: +in_progress: no +revision: 2 +kernel: C:BOOT0:cip-core-image-cip-core-buster-qemu-amd64-vmlinuz +kernelargs: console=tty0 console=ttyS0,115200 rootwait earlyprintk root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000001 rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 0 (OK) + +user variables: +---------------------------- +Config Partition #1 Values: +in_progress: no +revision: 1 +kernel: C:BOOT1:cip-core-image-cip-core-buster-qemu-amd64-vmlinuz +kernelargs: console=tty0 console=ttyS0,115200 rootwait earlyprintk root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000002 rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 0 (OK) +``` + +Apply swupdate as below +``` +root@demo:~# swupdate -i cip-core-image-cip-core-buster-qemu-amd64.swu +``` + +check bootloader ustate after swupdate. if the swupdate is successful then **revision number** should increase to **3** and status should be changed to **INSTALLED** for Partition #1. +``` +root@demo:~# bg_printenv +---------------------------- +Config Partition #0 Values: +in_progress: no +revision: 2 +kernel: C:BOOT0:cip-core-image-cip-core-buster-qemu-amd64-vmlinuz +kernelargs: console=tty0 console=ttyS0,115200 rootwait earlyprintk root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000001 rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 0 (OK) + +user variables: +---------------------------- +Config Partition #1 Values: +in_progress: no +revision: 3 +kernel: C:BOOT1:vmlinuz +kernelargs: root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000002 console=tty0 console=ttyS0,115200 rootwait earlyprintk rw initrd=cip-core-image-cip-core-buster-qemu-amd64-initrd.img +watchdog timeout: 60 seconds +ustate: 1 (INSTALLED) +``` + +Execute reboot command +- reboot command should cause kernel panic error. +- watchdog timer should expire and restart the qemu. bootloader should select previous partition to boot. +``` +root@demo:~# reboot +``` + +Once the system is restarted, check the bootloader ustate +- if update is failed then **revision number** should reduce to **0** and status should change to **FAILED** for Partition #1. +``` +root@demo:~# bg_printenv +---------------------------- + Config Partition #0 Values: +in_progress: no +revision: 2 +kernel: C:BOOT0:cip-core-image-cip-core-buster-qemu-amd64-vmlinuz +kernelargs: console=tty0 console=ttyS0,115200 rootwait earlyprintk root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000001 rw initrd=cip-core-image-cip-corg +watchdog timeout: 60 seconds +ustate: 0 (OK) + +user variables: +---------------------------- + Config Partition #1 Values: +in_progress: no +revision: 0 +kernel: C:BOOT1:vmlinuz +kernelargs: root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000002 console=tty0 console=ttyS0,115200 rootwait earlyprintk rw initrd=cip-core-image-cip-corg +watchdog timeout: 60 seconds +ustate: 3 (FAILED) +```