From patchwork Sun Aug 28 08:19:38 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: 42018 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 26C0527BBEA; Sun, 28 Aug 2022 09:21:24 +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 5F6AE27BBE9 for ; Sun, 28 Aug 2022 09:21:23 +0100 (BST) Received: from localhost ([::1]:38598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSDXm-0005zC-I1 for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 04:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSDXS-0005yx-GW for guix-patches@gnu.org; Sun, 28 Aug 2022 04:21:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSDXR-0000Un-W9 for guix-patches@gnu.org; Sun, 28 Aug 2022 04:21:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSDXR-0005a9-Kr for guix-patches@gnu.org; Sun, 28 Aug 2022 04:21: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: Sun, 28 Aug 2022 08:21: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.166167480321327 (code B ref 57070); Sun, 28 Aug 2022 08:21:01 +0000 Received: (at 57070) by debbugs.gnu.org; 28 Aug 2022 08:20:03 +0000 Received: from localhost ([127.0.0.1]:57562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSDWL-0005XO-Lf for submit@debbugs.gnu.org; Sun, 28 Aug 2022 04:20:02 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:46673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSDWG-0005X9-Mr for 57070@debbugs.gnu.org; Sun, 28 Aug 2022 04:19:52 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A19A35C0098; Sun, 28 Aug 2022 04:19:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 28 Aug 2022 04:19:43 -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=1661674783; x=1661761183; bh=MZ4qDInLWv ZXsoF5WY7DexVAOEb/IEX0ZaEYbw7tgHM=; b=YMf9svH5CpnjHvtUsPCkHQi+1c wxaV7XtDoXrHy699mzM3drfO+R9QubL1I60awTUNaic019Haq8sXvN74u8w9RXkE B4mFCBW/B29qJhHr+iCaoAOQpUg9I5PdFZA1JKZdBhOyI7O2yYgKsRUgVVVHZPbE Xh1vhvmbeU/wQhXQB0QInExbb29BStGpA3mviN+PS1NGK7doz36AG/OpLc5PCbqd +G4HvxFLwE6amZhd+8tOrGyhNtXUk6FqRE3aIjjSp2EsvLhSiZ8Z8n8o7DoxmcKk YoKahhbnAnDg8dOquQ6ds6ILaUzgxYhLY225TZGwItjUMOOaHLEYXsZuANMA== 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=1661674783; x=1661761183; bh=MZ4qDInLWvZXsoF5WY7DexVAOEb/ IEX0ZaEYbw7tgHM=; b=VbyO2LubIPZrT2SQqn+QNn5yqHpuLtrqnpeTbrsnNHeM 6iQv1aTiBzvo27o3jGPvfYg65IbDGYHhCB+jBD3duqOszegQUcwSZ+OvedkrLzzT CsGxV1G1CZdE86UtsgZsCqcm0pW5+3FgjvJp7UlJnCSPQbHIoT9zrmMg5a1hUoV4 LAdNdc25LKJbwmvlZ7xPYjoJOV6ix00y2lt///l0OidsWq1cCMWb7GG9t6nKmEZP KVm/d/eBBXjMPMsmWjyyX0o81BnnFJSr724fUPcfmjV9bNUPJ4Pa1wnG7sMj0XLh wkSF8kl5NnHXQbFYOHz5hSE1G2wTBf/wqHP99RLx/A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejledgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkjghfohfogggtsehmtderreertddvnecuhfhrohhmpeftvgii rgcutehlihiirgguvghhucforghjugcuoehrrdhmrghjugesphgrnhhthhgvrhigrdhorh hgqeenucggtffrrghtthgvrhhnpeevhfdvjeeukeehtdfhleekjeejudevuefghefhleet udeiudevhffghfejgfefkeenucffohhmrghinhepphgrnhhthhgvrhigrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhdrmhgrjhgu sehprghnthhhvghrgidrohhrgh X-ME-Proxy: Feedback-ID: i063944dc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 28 Aug 2022 04:19:42 -0400 (EDT) Date: Sun, 28 Aug 2022 12:49:38 +0430 From: Reza Alizadeh Majd Message-ID: <20220828124938.0289bd68@pantherx.org> In-Reply-To: <87lerc5iq6.fsf_-_@gnu.org> References: <20220809103044.27964-1-r.majd@pantherx.org> <20220816224004.1744c1d5@pantherx.org> <87lerc5iq6.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 Thu, 25 Aug 2022 19:35:45 +0200 Mathieu Othacehe wrote: > >> * gnu/bootloader.scm ()[device-tree-support?]: new >> field. > >You need to document this new field in the "Bootloader Configuration" >documentation section. > I just checked the "Bootloader Configuration" section. it describes the "bootloader-configuration" record itself, but the proposed patch adds the "device-tree-supports?" field to the "bootloader" record. unfortunately I couldn't find the section describing the "bootloader" record fields. so I added the documentations as a note for the "bootloader" field of "bootloader-configuration" record. >> * gnu/tests/bootloader.scm: add tests for FDTDIR modification. > >This will test for regressions on an x86_64-linux machine that will >probably never use this FDTDIR thing. As those tests are expensive to >run an maintain we can probably remove the test. > OK, I removed the test from recent patch. Best, Reza From cbeba372def25a957f5d8942f01fbde6cdc03704 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 bootloader field of . * doc/guix.texi (Bootloader Configuration)[bootloader]: Add note about bootloader's optional FDTDIR support. --- doc/guix.texi | 9 +++++++++ gnu/bootloader.scm | 6 +++++- gnu/bootloader/extlinux.scm | 13 +++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 023b48ae35..25b336e958 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36814,6 +36814,15 @@ modules. In particular, @code{(gnu bootloader u-boot)} contains definitions of bootloaders for a wide range of ARM and AArch64 systems, using the @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}. +@quotation Note +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 the @code{device-tree-support?} field of the @code{bootloader} +record to @code{#f}. setting this flag to @code{#f} removes the @code{FDTDIR} +from the @file{/boot/extlinux/extlinux.conf}. +@end quotation + @vindex grub-efi-bootloader @code{grub-efi-bootloader} allows to boot on modern systems using the @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 70e1836179..32fd7f0c2e 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. ;;; @@ -54,6 +55,7 @@ (define-module (gnu bootloader) bootloader-disk-image-installer bootloader-configuration-file bootloader-configuration-file-generator + bootloader-device-tree-support? bootloader-configuration bootloader-configuration? @@ -172,7 +174,9 @@ (define-record-type* (disk-image-installer bootloader-disk-image-installer (default #f)) (configuration-file bootloader-configuration-file) - (configuration-file-generator bootloader-configuration-file-generator)) + (configuration-file-generator bootloader-configuration-file-generator) + (device-tree-support? bootloader-device-tree-support? + (default #t))) ;;; diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 6b5ff298e7..f3d69c0cc0 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,10 @@ (define* (extlinux-configuration-file config entries (define all-entries (append entries (bootloader-configuration-menu-entries config))) + (define with-fdtdir? + (let ((bootloader (bootloader-configuration-bootloader config))) + (bootloader-device-tree-support? bootloader))) + (define (menu-entry->gexp entry) (let ((label (menu-entry-label entry)) (kernel (menu-entry-linux entry)) @@ -46,12 +51,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