From patchwork Mon Aug 29 18:17:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Reza Alizadeh Majd X-Patchwork-Id: 42070 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A5B9B27BBEA; Mon, 29 Aug 2022 19:19:34 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D91BF27BBE9 for ; Mon, 29 Aug 2022 19:19:33 +0100 (BST) Received: from localhost ([::1]:51956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSjMD-0003aM-1h for patchwork@mira.cbaines.net; Mon, 29 Aug 2022 14:19:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSjLi-0003Zd-Gt for guix-patches@gnu.org; Mon, 29 Aug 2022 14:19:15 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSjLh-0004FO-Ux for guix-patches@gnu.org; Mon, 29 Aug 2022 14:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSjLh-00024R-QC for guix-patches@gnu.org; Mon, 29 Aug 2022 14:19:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57070] [PATCH] bootloader: extlinux: support for optional FDTDIR Resent-From: Reza Alizadeh Majd Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 29 Aug 2022 18:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57070 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Mathieu Othacehe Cc: 57070@debbugs.gnu.org Received: via spool by 57070-submit@debbugs.gnu.org id=B57070.16617970827892 (code B ref 57070); Mon, 29 Aug 2022 18:19:01 +0000 Received: (at 57070) by debbugs.gnu.org; 29 Aug 2022 18:18:02 +0000 Received: from localhost ([127.0.0.1]:33775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSjKj-00023D-Tl for submit@debbugs.gnu.org; Mon, 29 Aug 2022 14:18:02 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:33677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSjKi-00022g-54 for 57070@debbugs.gnu.org; Mon, 29 Aug 2022 14:18:00 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 168F05C00F2; Mon, 29 Aug 2022 14:17:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 29 Aug 2022 14:17:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantherx.org; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1661797075; x=1661883475; bh=5GdSEFjI/M 96CLstyrDmveYGM0TQc6l/UWjKuSQtcZA=; b=XsEzUjf4SfvSarPzLMgGQqbQxh 2JA94ECW97QnRU6W2wjOLIl05fFGSklhMXBqCmM/pTCIx8fJ7Pwg0yqVwNIXfWKZ B6vf9foPo/ItT9TG2JNaxcZeu93Y+nPSXp3Ka1F2SLGiRmcahOKB/V9L4cztU8dH LWxvsBRwYoprCcBfn2aylF6Bus7H4CUnUxbFqoLDTMxLvnbgU8/mcB9+WPAPTMPI JVho8UMW/2oRVCas3Sdtu1SO2yLGWZf3c+Sb6pAHs8hvQtrixb3crFS66ISAExDi 5S5F5M4jFAo9PX7UO3dVGr1gIRzruJMXs46HXaNjJBQs5zts/rzMp4CnpogQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references: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=1661797075; x=1661883475; bh=5GdSEFjI/M96CLstyrDmveYGM0TQ c6l/UWjKuSQtcZA=; b=AOBaodSHl8SO10chQ7wl+Rkmg9oZRR2WNYsvMKQpfQDj dK/Vrf5y7+VXTzupb76nQYUxHzBPTIfUIXuQhuIWBaLE04MKGJfUSBij179gYJRS ojR+aiWJ8KvRwHP/+6ErKJb+h6E+UaYJeIkaQ4XjIj6gx+Tyc6aBGGKX/787OXvt T2UkPvRZxcSAAbDiltuZVcqaoEAEi7SH5PgjLsu2/07ZtPOVd9FmIAXGHYqUj0vL jJT1pkM2C7Wo3L8UOcyra9Umlxo34Z1YCy7AQrUdWETDUB6kFnSM98AOEc/031UP 2y5XKumXO7YZO71g6Ls7bvS2QqIVnBfTEU/DaVMoZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekuddguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfgjfhhoofggtgesmhdtreerredtvdenucfhrhhomheptfgv iigrucetlhhiiigruggvhhcuofgrjhguuceorhdrmhgrjhgusehprghnthhhvghrgidroh hrgheqnecuggftrfgrthhtvghrnhepvefhvdejueekhedthfelkeejjeduveeugfehhfel teduieduvefhgffhjefgfeeknecuffhomhgrihhnpehprghnthhhvghrgidrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrdhmrghj ugesphgrnhhthhgvrhigrdhorhhg X-ME-Proxy: Feedback-ID: i063944dc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Aug 2022 14:17:53 -0400 (EDT) Date: Mon, 29 Aug 2022 22:47:44 +0430 From: Reza Alizadeh Majd Message-ID: <20220829224744.3801f469@pantherx.org> In-Reply-To: <87ilmcpdv3.fsf@gnu.org> References: <20220809103044.27964-1-r.majd@pantherx.org> <20220816224004.1744c1d5@pantherx.org> <87lerc5iq6.fsf_-_@gnu.org> <20220828124938.0289bd68@pantherx.org> <87ilmcpdv3.fsf@gnu.org> Organization: PantherX X-Mailer: Claws Mail 4.1.0 (GTK 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Mathieu, On Sun, 28 Aug 2022 17:49:36 +0200 Mathieu Othacehe wrote: > >About that, any reason not to have this "device-tree-supports?" field >in the record? > >The record is about how to install the bootloader while > is about its configuration. So maybe it >would be a better fit? > I wanted to limit my patch to affect as minimum sections as possible. so I added the field to the record. I'm agree with your proposal, since the removal of FDTDIR is more of a configuration for an existing bootloader. I moved this option to the and submit a new patch. it would be great to have your feedback whenever you had time. Regards, Reza From a7e3e9afe22274397634e6dbe4caa9766adfb7a9 Mon Sep 17 00:00:00 2001 From: Reza Alizadeh Majd Date: Sun, 28 Aug 2022 12:34:46 +0430 Subject: [PATCH] bootloader: extlinux: support for optional FDTDIR There are situations that u-boot doesn't have to load from the device tree. some provide the device tree using a vendor bootloader (like what raspberry-pi does) or with an external bootloader that chainloads the u-boot (what Asahi does for m1n1 bootloader). Unfortunately we couldn't find any reliable document to enforce u-boot to pass the device tree via `extlinux.conf`, however during our tests, we found that removing the `FDTDIR` line from the `extlinux.conf` tend us to do so. There is also no reliable way to guess if u-boot bootloader should load device tree or not on a specific hardware. in addition, there are hardware that can be booted with both firmware device tree on some kernels and with special device tree on other (modified) kernels. the following changes provided to define an optional parameter in record, called which by default is set to #t to keep the current behavior unchanged. if this paramter is set to #f, the FDTDIR line will be discarded from the and u-boot doesn't load the device tree automatically. * gnu/bootloader.scm ()[device-tree-support?]: new field. * gnu/bootloader/extlinux.scm (extlinux-configuration-file): add FDTDIR line based on field of . * doc/guix.texi (Bootloader Configuration)[device-tree-support?]: Add documentation for the new field. --- doc/guix.texi | 7 ++++++ gnu/bootloader.scm | 50 ++++++++++++++++++++----------------- gnu/bootloader/extlinux.scm | 12 +++++++-- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 023b48ae35..8171481040 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36960,6 +36960,13 @@ corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}). The speed of the serial interface, as an integer. For GRUB, the default value is chosen at run-time; currently GRUB chooses 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}). + +@item @code{device-tree-support} (default: @code{#t}) +There are situations when @code{u-boot} shouldn't load the device tree from +the file system. because it is either unnecessary for the platform being used +or has already been loaded into RAM earlier in the boot process. in such cases +you can set this field to @code{#f}. setting this flag to @code{#f} removes +the @code{FDTDIR} line from the @file{/boot/extlinux/extlinux.conf}. @end table @end deftp diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 70e1836179..335133d224 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017 Leo Famulari ;;; Copyright © 2019, 2021 Ludovic Courtès ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2022 Reza Alizadeh Majd ;;; ;;; This file is part of GNU Guix. ;;; @@ -69,6 +70,7 @@ (define-module (gnu bootloader) bootloader-configuration-terminal-inputs bootloader-configuration-serial-unit bootloader-configuration-serial-speed + bootloader-configuration-device-tree-support? %bootloaders lookup-bootloader-by-name @@ -193,29 +195,31 @@ (define-with-syntax-properties (warn-target-field-deprecation (define-record-type* bootloader-configuration make-bootloader-configuration bootloader-configuration? - (bootloader bootloader-configuration-bootloader) ; - (targets %bootloader-configuration-targets ;list of strings - (default #f)) - (target %bootloader-configuration-target ;deprecated - (default #f) (sanitize warn-target-field-deprecation)) - (menu-entries bootloader-configuration-menu-entries ;list of - (default '())) - (default-entry bootloader-configuration-default-entry ;integer - (default 0)) - (timeout bootloader-configuration-timeout ;seconds as integer - (default 5)) - (keyboard-layout bootloader-configuration-keyboard-layout ; | #f - (default #f)) - (theme bootloader-configuration-theme ;bootloader-specific theme - (default #f)) - (terminal-outputs bootloader-configuration-terminal-outputs ;list of symbols - (default '(gfxterm))) - (terminal-inputs bootloader-configuration-terminal-inputs ;list of symbols - (default '())) - (serial-unit bootloader-configuration-serial-unit ;integer | #f - (default #f)) - (serial-speed bootloader-configuration-serial-speed ;integer | #f - (default #f))) + (bootloader bootloader-configuration-bootloader) ; + (targets %bootloader-configuration-targets ;list of strings + (default #f)) + (target %bootloader-configuration-target ;deprecated + (default #f) (sanitize warn-target-field-deprecation)) + (menu-entries bootloader-configuration-menu-entries ;list of + (default '())) + (default-entry bootloader-configuration-default-entry ;integer + (default 0)) + (timeout bootloader-configuration-timeout ;seconds as integer + (default 5)) + (keyboard-layout bootloader-configuration-keyboard-layout ; | #f + (default #f)) + (theme bootloader-configuration-theme ;bootloader-specific theme + (default #f)) + (terminal-outputs bootloader-configuration-terminal-outputs ;list of symbols + (default '(gfxterm))) + (terminal-inputs bootloader-configuration-terminal-inputs ;list of symbols + (default '())) + (serial-unit bootloader-configuration-serial-unit ;integer | #f + (default #f)) + (serial-speed bootloader-configuration-serial-speed ;integer | #f + (default #f)) + (device-tree-support? bootloader-configuration-device-tree-support? + (default #t))) (define-deprecated (bootloader-configuration-target config) bootloader-configuration-targets diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 6b5ff298e7..d9b6d8bf8a 100644 --- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 David Craven ;;; Copyright © 2017 Mathieu Othacehe +;;; Copyright © 2022 Reza Alizadeh Majd ;;; ;;; This file is part of GNU Guix. ;;; @@ -38,6 +39,9 @@ (define* (extlinux-configuration-file config entries (define all-entries (append entries (bootloader-configuration-menu-entries config))) + (define with-fdtdir? + (bootloader-configuration-device-tree-support? config)) + (define (menu-entry->gexp entry) (let ((label (menu-entry-label entry)) (kernel (menu-entry-linux entry)) @@ -46,12 +50,16 @@ (define (menu-entry->gexp entry) #~(format port "LABEL ~a MENU LABEL ~a KERNEL ~a - FDTDIR ~a/lib/dtbs + ~a INITRD ~a APPEND ~a ~%" #$label #$label - #$kernel (dirname #$kernel) #$initrd + #$kernel + (if #$with-fdtdir? + (string-append "FDTDIR " (dirname #$kernel) "/lib/dtbs") + "") + #$initrd (string-join (list #$@kernel-arguments))))) (define builder -- 2.37.1