From patchwork Mon May 29 14:02:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 1787147 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UVr/jhBa; dkim-atps=neutral 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVHLy34h1z20Py for ; Tue, 30 May 2023 00:03:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E65285CC7; Mon, 29 May 2023 16:02:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UVr/jhBa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 246C885CC7; Mon, 29 May 2023 16:02:45 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9B14385A42 for ; Mon, 29 May 2023 16:02:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rui.silva@linaro.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-30adc51b65cso2804813f8f.0 for ; Mon, 29 May 2023 07:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685368962; x=1687960962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dPPipuhC4MEkABwHH3XrQ+CI4LHoXl7Tgfus6E59A1Y=; b=UVr/jhBaTuLnd4nL20sO+jSuiSdFtNHXjBhSpOC0tL8uW68iQwkCPYT2zr95cDcDk8 6uaOAUVKiMsq6lgySP+fHoP/plu2CfpGs80GR/uOlXCK3JpKDHRqeDldh2nXF5G/3ulS /GL4UrWjMde9un6WDleG3OqyT/lE6XHdyIN1W9VWVrudEC1svsPg4gf2cghnR49fa9yU sDHtHGmwpEWwa2wKJAdkbuappgJs0Bzvx+iy9jSd+syxrOKzAmFfLVXGD4dfPpNAEwyI FRfmkAwBy39lYUwTuU5EGG6TGQfWxxn6QZabIy3kwQ0qqqrkeO5H0hRSqug8G6E4Ion5 FcDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685368962; x=1687960962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dPPipuhC4MEkABwHH3XrQ+CI4LHoXl7Tgfus6E59A1Y=; b=NwEu1dVU9PSSDAzOrk7rjjCrzGtea02KfPArYDm74yp/S+ULjwHLlWr/cWkDV/W2Tv 83/zfFLGKp5eOxVzl/2Cx5ITJNVE2tTMGMVWdFWnf5BL/raDJk6xYWLlN0yxhNKegE2W ySPG45ZSLhxkQTYC9gARZ6Z7VIu7ReIWFqgAUdfsG34mwXbzsjJERt4Ct74P6A7SKf6C Z+Pv4lmfBGJ//KitgPQTfdasHavjLhkmAi01F0Ab+qHMbKt874N+hp00GgSijIlZQKeW ZEqAGOHR/wp8WmzjI7c4XnaSafxK4Zy5Ou0ngcxKQ7D5wR8NIq56NfpsgojRnYMFMfz4 pHBg== X-Gm-Message-State: AC+VfDzIuWzKGhMg6NnVppk61DzkDeqYT1xnjx4T20z3i1053Wr7Qtj1 CWDjg5z4u0/4bH8CImErSj4mu4teeQ0lEjIlsGY= X-Google-Smtp-Source: ACHHUZ5p5V4GOD+CL1R0+rjp+7RojOWmdEiwjoT7RDLXPF7A1Qm7f8lvYfVcyWP7SblFSKtwg0qhPw== X-Received: by 2002:a5d:4d02:0:b0:307:8718:7891 with SMTP id z2-20020a5d4d02000000b0030787187891mr10042505wrt.54.1685368961744; Mon, 29 May 2023 07:02:41 -0700 (PDT) Received: from arch-thunder.local (a109-49-33-111.cpe.netcabo.pt. [109.49.33.111]) by smtp.gmail.com with ESMTPSA id w12-20020a5d544c000000b002fed865c55esm54123wrv.56.2023.05.29.07.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 07:02:41 -0700 (PDT) From: Rui Miguel Silva To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Rui Miguel Silva Subject: [PATCH v2 5/6] corstone1000: set kernel_addr based on boot_idx Date: Mon, 29 May 2023 15:02:28 +0100 Message-Id: <20230529140229.3225090-6-rui.silva@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230529140229.3225090-1-rui.silva@linaro.org> References: <20230529140229.3225090-1-rui.silva@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean We need to distinguish between boot banks and from which partition to load the kernel+initramfs to memory. For that, fetch the boot index, fetch the correspondent partition, calculate the correct kernel address and then set the env variable kernel_addr with that value. Signed-off-by: Rui Miguel Silva --- board/armltd/corstone1000/corstone1000.c | 56 +++++++++++++++++++++++- configs/corstone1000_defconfig | 1 + 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c index 1bead7a0a8b4..a4567449f1be 100644 --- a/board/armltd/corstone1000/corstone1000.c +++ b/board/armltd/corstone1000/corstone1000.c @@ -5,16 +5,24 @@ * Rui Miguel Silva */ +#include #include #include #include #include -#include #include +#include +#include #include #include #include +#define CORSTONE1000_KERNEL_PARTS 2 +#define CORSTONE1000_KERNEL_PRIMARY "kernel_primary" +#define CORSTONE1000_KERNEL_SECONDARY "kernel_secondary" + +static int corstone1000_boot_idx; + static struct mm_region corstone1000_mem_map[] = { { /* CVM */ @@ -103,6 +111,52 @@ void fwu_plat_get_bootidx(uint *boot_idx) *boot_idx = CONFIG_FWU_NUM_BANKS; log_err("corstone1000: failed to read active index\n"); } +} + +int board_late_init(void) +{ + struct disk_partition part_info; + struct udevice *dev, *bdev; + struct nvmxip_plat *plat; + struct blk_desc *desc; + int ret; + + ret = uclass_first_device_err(UCLASS_NVMXIP, &dev); + if (ret < 0) { + log_err("Cannot find kernel device\n"); + return ret; + } + + plat = dev_get_plat(dev); + device_find_first_child(dev, &bdev); + desc = dev_get_uclass_plat(bdev); + ret = fwu_get_active_index(&corstone1000_boot_idx); + if (ret < 0) { + log_err("corstone1000: failed to read boot index\n"); + return ret; + } + + if (!corstone1000_boot_idx) + ret = part_get_info_by_name(desc, CORSTONE1000_KERNEL_PRIMARY, + &part_info); + else + ret = part_get_info_by_name(desc, CORSTONE1000_KERNEL_SECONDARY, + &part_info); + + if (ret < 0) { + log_err("failed to fetch kernel partition index: %d\n", + corstone1000_boot_idx); + return ret; + } + + ret = 0; + + ret |= env_set_hex("kernel_addr", plat->phys_base + + (part_info.start * part_info.blksz)); + ret |= env_set_hex("kernel_size", part_info.size * part_info.blksz); + + if (ret < 0) + log_err("failed to setup kernel addr and size\n"); return ret; } diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig index 2d391048cd67..5be5335bdfc1 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig @@ -20,6 +20,7 @@ CONFIG_CONSOLE_RECORD=y CONFIG_LOGLEVEL=7 # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_BOARD_LATE_INIT=y CONFIG_SYS_MAXARGS=64 CONFIG_SYS_CBSIZE=512 # CONFIG_CMD_CONSOLE is not set