From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-4.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 24FD940819; Fri, 26 Aug 2022 13:12:38 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id F0D3D4075B; Fri, 26 Aug 2022 13:12:34 +0000 (UTC) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by atuin.qyliss.net (Postfix) with ESMTPS id 4DC76407C3 for ; Fri, 26 Aug 2022 13:12:30 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3C1035C0386; Fri, 26 Aug 2022 09:12:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 26 Aug 2022 09:12:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1661519548; x=1661605948; bh=jM0w5Vo0ee2KXqM8gp0jvonqZ xRKh1orDz3xYZT5Wi0=; b=OnZ3PU/0oXQSficxql3Y7kFnPa9jeS1DaXQCvd+o7 bLIHZCHbrt2He1NY8ucHO5+upZwRfvHg9pkbr4NHrA1yZrbBEyxf4rEoc2jST/rc gjQjtTuasHrL+3/Dl4f6zRl0wKYCIg7dtC+9P9eNXHmB9bNgsLKqt6VvWHPhLGwQ Abg82LVHdLuOHZyq3gb9XXZF3BziFDndkI/qjHqicIMBLJcRckqgb45Fmihno9zW 0EEOqjzrW+42zlzRWP9nEWtV565dXTuw4i+5r6wOI8lDTKrsJg32KOgEfRBMBX9S SseNvcGy6O+32e0xO+oE+oP3w0qVRi+xyvy887r9/tWXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1661519548; x=1661605948; bh=jM0w5Vo0ee2KXqM8gp0jvonqZxRKh1orDz3 xYZT5Wi0=; b=boz9SEcwUh0r+q6/WgRbc60R6dKZTjsmmGPDkR/PBsZEtn+eSvw NlqNS0e1YsELF/q8Q5hcPP7M265FqVmMza2PqprP2nBcWFRmHYbSkKI3ZuVm+Yl2 0uD833m9yAieEB/kLuE9G8+mO4E98+16j544SRkEeGEOeDRSOLuXlCZ5C67t1NZa 6UMiMCSUkNkW9zmrr02Px1TGU/fYA63q4o+80OXYtt1VtUJgVjZYTdbwFkXi0mFR 71mERGo0qp1887EZUsLu0h3zaElyHwi76Vv3qF8o86549RyW8nvX4HPfPcXk9wja B+Qa63dKJUk4HQFx+aPvDtlYakrh09ey+9w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejhedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomheptehlhihsshgr ucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepkedugf ekfeefvdeihedtheevjeetueejhffhuddtueffhfeikeevteffheefgeevnecuffhomhgr ihhnpehsphgvtghtrhhumhdqohhsrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepqhihlhhishhsseigvddvtddrqhihlhhishhsrdhn vght X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Aug 2022 09:12:26 -0400 (EDT) Received: by x220.qyliss.net (Postfix, from userid 1000) id F20CA62D; Fri, 26 Aug 2022 13:12:25 +0000 (UTC) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH] scripts/make-gpt.sh: reserve 8 MiB at start of GPT Date: Fri, 26 Aug 2022 13:09:25 +0000 Message-Id: <20220826130923.1840670-1-hi@alyssa.is> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UZWARPANKTBCCFXJKIJTO2PGTNABW3AX X-Message-ID-Hash: UZWARPANKTBCCFXJKIJTO2PGTNABW3AX X-MailFrom: qyliss@x220.qyliss.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Yuriy Nesterov , Ville Ilvonen X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In some cases (e.g. a product built on Spectrum where updates to both firmware and OS are delivered by the same vendor), it makes sense to include firmware in the same image as the OS. This firmware tends to live in the start of the image, after the GPT header. (The exact location varies by board.) The 1 MiB reserved by sfdisk by default is not enough for this. The conventional value seems to be 8 MiB. On NixOS, this is configurable with the sdImage.firmwarePartitionOffset option, but this defaults to 8 MiB and I wasn't able to find any examples in searches on DuckDuckGo and GitHub of anybody using any other value, so it looks like 8 MiB is broadly acceptable. Signed-off-by: Alyssa Ross --- Yuriy, if you'd like to test this patch, here's some documentation about how to do that. :) https://spectrum-os.org/doc/testing-patches.html scripts/make-gpt.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index 56076d3..55f38d6 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -1,12 +1,13 @@ #!/bin/sh -eu # # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ # # usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID]... ONE_MiB=1048576 -TWO_MiB=2097152 +NINE_MiB=9437184 # Prints the number of 1MiB blocks required to store the file named # $1. We use 1MiB blocks because that's what sfdisk uses for @@ -41,8 +42,9 @@ shift nl=$'\n' table="label: gpt" -# Keep 1MiB free at the start, and 1MiB free at the end. -gptBytes=$TWO_MiB +# Keep 8MiB free at the start (to provide space for firmware if +# required), and 1MiB free at the end. +gptBytes=$NINE_MiB for partition; do sizeMiB="$(sizeMiB "$(partitionPath "$partition")")" table="$table${nl}size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")" @@ -52,6 +54,7 @@ done rm -f "$out" truncate -s "$gptBytes" "$out" sfdisk "$out" <