From patchwork Wed May 12 12:39:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Salvini X-Patchwork-Id: 1477580 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgFFJ2h81z9tjw for ; Wed, 12 May 2021 22:57:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6013B82D45; Wed, 12 May 2021 14:57:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=koansoftware.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 723B082D4C; Wed, 12 May 2021 14:57:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.koansoftware.com (mail.koansoftware.com [178.79.174.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4383482AFF for ; Wed, 12 May 2021 14:57:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=koansoftware.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.salvini@koansoftware.com Received: from localhost (localhost [127.0.0.1]) by mail.koansoftware.com (Postfix) with ESMTP id D61B13F84D; Wed, 12 May 2021 14:57:28 +0200 (CEST) Received: from mail.koansoftware.com ([127.0.0.1]) by localhost (mail.koansoftware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zy1geZPKCqux; Wed, 12 May 2021 14:57:26 +0200 (CEST) From: Mauro Salvini To: u-boot@lists.denx.de Cc: Mauro Salvini , =?utf-8?q?C=C3=A9dric_Schiel?= =?utf-8?q?i?= , Matthias Brugger Subject: [PATCH] rpi: always set fdt_addr with firmware-provided FDT address Date: Wed, 12 May 2021 14:39:45 +0200 Message-Id: <20210512123945.25649-1-m.salvini@koansoftware.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Raspberry firmware prepares the FDT blob in memory at an address that depends on both the memory size and the blob size [1]. After commit ade243a211d6 ("rpi: passthrough of the firmware provided FDT blob") this FDT is passed to kernel through fdt_addr environment variable, handled in set_fdt_addr() function in board file. When u-boot environment is persistently saved, if a change happens in loaded FDT (e.g. for a new overlay applied), firmware produces a FDT address different from the saved one, but u-boot still use the saved one because set_fdt_addr() function does not overwrite the fdt_addr variable. So, for example, if there is a script that uses fdt commands for e.g. manipulate the bootargs, boot hangs with error libfdt fdt_check_header(): FDT_ERR_BADMAGIC Removing the fdt_addr variable in saved environment allows to boot. With this patch set_fdt_addr() function always overwrite fdt_addr value. [1] https://www.raspberrypi.org/forums//viewtopic.php?f=107&t=134018 Signed-off-by: Mauro Salvini Cc: Cédric Schieli Cc: Matthias Brugger --- board/raspberrypi/rpi/rpi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index df52a4689f..611013471e 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -318,9 +318,6 @@ static void set_fdtfile(void) */ static void set_fdt_addr(void) { - if (env_get("fdt_addr")) - return; - if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) return;