From patchwork Sun Jan 14 13:39:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 3284 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Sun, 14 Jan 2024 14:39:48 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-oa1-f56.google.com (mail-oa1-f56.google.com [209.85.160.56]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 40EDdkC5016657 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 14 Jan 2024 14:39:47 +0100 Received: by mail-oa1-f56.google.com with SMTP id 586e51a60fabf-1ef4f8d294esf9932526fac.1 for ; Sun, 14 Jan 2024 05:39:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705239580; cv=pass; d=google.com; s=arc-20160816; b=Ak3m4BFZwmF379U/ZHiZqXayts1xgA9uueOqCuWG/2/ONK1aklBn2jZGSEI4QryFKw 3AlqGPNB9J5Qisak7fJJIVfBXv9BAulKdefR4tv6x0k+mArCdfuU3+qM/XlT8YkHsH4O Uf5uIa3Mi2vb18raBYhnPmllv5edQMJHIqkcqvh6kWfu2224l+IWX4c57aol+krjWt/t 2AXNMSop+KVNKemAruCaHgCTeOA2eKo6qykUHeXplFaQaRjFLvzeDexVzv4IgVl1Xvlg z115VNv9kBe84f/0YGsL94yeTSSCOqCb0CyUmcVzmz8RsdKNOpOF0jPONAJrtVLJOX1x R+9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MjJJuYOiC9BX/T/lvQ2fPEKV9/Yo1rqoFYLSwVV0qqs=; fh=IlHmq1Kl6WDqsYIcQXzwFqB72MHx6soicqMlhBagVr4=; b=0plv9BjRyGisf0RtlSyW7MKq1Vcm+tTcm5D6kouugMIb+nH6ttXCn2g1FbIwBDVriC eiqpwv7B88y99z+0NO/dzxwSxxX5dgIgFnaa90VW3DmDzkXouJcnJw8qdFMRbMnubtam WJzMBjt3YEnv9crm+omVGD7TI8iIB2K8xu+m1I68Jt2M94/7xL8isQ7Mokx+orE8ilxN LVj8xavktw1Qgmt+Sr3tJYX8llCg1JfAxfeafXgWExTGGL04L5SmUm1erbtzyu+01mqp sbYUj5LzshP2U0fewp62OY+cYwyVv1YXyhSJZ6kvJTmdbshaZJehclj5Q404Ppfd+2lu r0tA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=pN2ZI1dy; spf=pass (google.com: domain of fm-294854-202401141339378a6d5c5173cdc401c3-gkyk1n@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-202401141339378a6d5c5173cdc401c3-gKYK1n@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1705239580; x=1705844380; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=MjJJuYOiC9BX/T/lvQ2fPEKV9/Yo1rqoFYLSwVV0qqs=; b=hmU3uTe4Hs1Grkvb/w0aAdiRAD2HU1oC2CvxC5OoM+kRmWEdFXw7skzvPdRv8udGad Z4A5VmQcNFbZG2cFnUUGj3adBwcZeCa3lcraw35FeiFAWua1vUqD6vl7PiMQ9kNDiXAb TYw5o/pk3UJD1YfgM+UE4QTc+JX+ljjYqvq5jCZrnup782+Ar7dhtGX3kysdm/lpx8S7 RVzo5HUH4K/M6Ft//k8Oky3D0oTsXqnWH80Ag/IMLPr6S/HXkW05LMbX/nT8RnNUKqUr INLv0DflI10q+PAfFUu9CiJBhv3G3L5UxKmavb5rCZODe0d5iSGDr9AoOKoot0oFakuj Ec1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705239580; x=1705844380; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MjJJuYOiC9BX/T/lvQ2fPEKV9/Yo1rqoFYLSwVV0qqs=; b=ayt/eTEaOfBvRWnns5l/JtorbPydLRXv1D83ZdGSmHrOGvIrG0x16nP1JmIdRtoeDv 6dUuIxGQubFmkNugmrd7gps16Gb5Qq7A5pO++DGoXEB6vhA2F7p+PMB1ZConZB5a0hMi YgNgACLz/hH+gf8SPqGSewB+wG654Qa1HXqrFkxO4972vCea+mQlY67N//7g/8VpM6FI QKkRj4VuqyqE2QAAN+6K3hd+roN6bJOy8Ja7BPw49ovrKTHZeFsbCRrOa/hgXitKyUrY N9tVvW2aqpcrp6N2URY+EnVlg+5zy1bFps6MLG3vzzYN6pjsYyuoxc+oCuuTXzarMFxs hw7Q== X-Gm-Message-State: AOJu0YzC3EkY8Fl1HntPxJuZ5RtON/otroFqwLLIo9ot8yfdM3U3TmzF 9dJVU6NZz/bCikmNSRabK4E= X-Google-Smtp-Source: AGHT+IHmB6ccxypJyiVzbMsHx0PsFNrf9NRJsiKC6WPKT/ooVyaZSYXQnMgZMBZFFY3SL5CtJx6lUg== X-Received: by 2002:a05:6871:5ca:b0:1fb:75a:7790 with SMTP id v10-20020a05687105ca00b001fb075a7790mr5014649oan.65.1705239580067; Sun, 14 Jan 2024 05:39:40 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6870:ed86:b0:206:937d:920 with SMTP id fz6-20020a056870ed8600b00206937d0920ls2590733oab.0.-pod-prod-02-us; Sun, 14 Jan 2024 05:39:39 -0800 (PST) X-Received: by 2002:a05:6808:2222:b0:3bd:44a2:1fc9 with SMTP id bd34-20020a056808222200b003bd44a21fc9mr5106641oib.58.1705239579299; Sun, 14 Jan 2024 05:39:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705239579; cv=none; d=google.com; s=arc-20160816; b=AIryVWfVBNKzG+LS84usQiM7iW3iELfYC/WTh3JPIx3Vwy3XHrywE7ecOdr4JUg4/8 qE/aU1U37mcz169cskZdLNYKKj8uEIMKxdXOojdYUpT8e/dbiObhVR18QT5p2wHxXL2V DJcf3NhkfRy3GgbLh6UslbBGl487NulgX8VvUlArdNpZFO6ySEeskO6jtOy5MJcLO7ao O4q5fSMRTM7CvgTbl4o0eGtK5KCyyP73Ibab+KHQo8HwCZ/pTvOR604EYsYYU+AqVw4H /c8qd9dSChtzwNzS4o4zaoaLE8kH7tmhCRuNIdXQhl/UeQSGca5pJxHBbSDNKkPZqEW1 hUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=JTCyBG7XsxBc+A9vBYiBCr/AeJn7nJ2/wIZ8jTQV4p0=; fh=IlHmq1Kl6WDqsYIcQXzwFqB72MHx6soicqMlhBagVr4=; b=rH8OGGse+HzE/kYqKxJMLgps8QP56SjXWCDJAXXwXts9ko2TQUNDqcTNczHG+gsCLa QwNk9cJSz12ThGy+VuJDyTCk6Rto8d7hctuU+8siaj2Ce9g6NqVKx/dZNx6qQTxMt/Ha Kw88h1P8cXF5e/pDb+meylDXX2aHKFwaEkR2m3Hxa02lCGL3lRcZebQ9D6nDVBqSYdtE yMp2rm27jcTLxSbxhjHWz1UFX2tgqIW3mCM3DAgAytj1XQtqUgIDe1+sl+tEAoK3lnuO paTt0749Qpu5+rkFhskfn6uYakbwMMo/Ch5k31AX5s7wJKj/swv9XWEgKlqaWD1S98Mw jBHw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=pN2ZI1dy; spf=pass (google.com: domain of fm-294854-202401141339378a6d5c5173cdc401c3-gkyk1n@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-202401141339378a6d5c5173cdc401c3-gKYK1n@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net. [185.136.65.225]) by gmr-mx.google.com with ESMTPS id bd36-20020a056808222400b003bb7afbe66csi537002oib.4.2024.01.14.05.39.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jan 2024 05:39:38 -0800 (PST) Received-SPF: pass (google.com: domain of fm-294854-202401141339378a6d5c5173cdc401c3-gkyk1n@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) client-ip=185.136.65.225; Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 202401141339378a6d5c5173cdc401c3 for ; Sun, 14 Jan 2024 14:39:37 +0100 X-Patchwork-Original-From: "'Jan Kiszka' via isar-users" From: Jan Kiszka To: isar-users Cc: Nishanth Menon Subject: [PATCH v2 08/11] wic: Add hybrid-boot bootloader source plugin Date: Sun, 14 Jan 2024 14:39:31 +0100 Message-Id: <74c8eb194dee34263799e64e96bcd1dfff45a105.1705239574.git.jan.kiszka@siemens.com> In-Reply-To: References: MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-294854:519-21489:flowmailer X-Original-Sender: jan.kiszka@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=pN2ZI1dy; spf=pass (google.com: domain of fm-294854-202401141339378a6d5c5173cdc401c3-gkyk1n@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-202401141339378a6d5c5173cdc401c3-gKYK1n@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Jan Kiszka Reply-To: Jan Kiszka Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Jan Kiszka Creates a hybrid partition table of both GPT and DOS, only adding the first active partition to the DOS table. This addresses use cases where the (firmware-)bootable partition is not the EFI partition while EFI should be used later on. The bootimg-biosplusefi does not suite here. Usage in a wks file: part /bootable-partition --active ... part / ... bootloader --source hybrid-boot ... Signed-off-by: Jan Kiszka --- .../lib/wic/plugins/source/hybrid-boot.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 meta/scripts/lib/wic/plugins/source/hybrid-boot.py diff --git a/meta/scripts/lib/wic/plugins/source/hybrid-boot.py b/meta/scripts/lib/wic/plugins/source/hybrid-boot.py new file mode 100644 index 00000000..c73e89e6 --- /dev/null +++ b/meta/scripts/lib/wic/plugins/source/hybrid-boot.py @@ -0,0 +1,38 @@ +# +# Copyright (c) Siemens AG, 2024 +# +# SPDX-License-Identifier: MIT +# +# DESCRIPTION +# This creates a hybrid DOS partition table for a GPT disk, adding the +# partition marked as bootable to that table. This is useful if the boot +# partition is different from the EFI partition so that bootimg-biosplusefi +# cannot be used. Implemented as bootloader source plugin. + +import logging + +from wic import WicError +from wic.pluginbase import SourcePlugin +from wic.misc import exec_native_cmd + +logger = logging.getLogger('wic') + +class HybridBoot(SourcePlugin): + """ + Create hybrid partition table with a single bootable partition. + """ + + name = 'hybrid-boot' + + @classmethod + def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + for part in creator.parts: + if part.active: + break + else: + raise WicError("No active partition found") + + logger.info("Creating hybrid partition table, using partition %d as bootable DOS partition" % part.realnum) + exec_native_cmd("sgdisk %s --hybrid %d:EE" % (disk.path, part.realnum), native_sysroot) + exec_native_cmd("sfdisk --label-nested dos -A %s %d" % (disk.path, part.realnum), native_sysroot)