From patchwork Mon Jun 12 08:09:19 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: 691626 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp17050wru; Mon, 12 Jun 2023 01:14:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51qXc9GQ4kYetZ22gP7vQ8P2I5zQXsJsxYlQ9bxEUIhE6/CD7NDcyhzPt/tsHESqFZl2gE X-Received: by 2002:a05:6808:a1b:b0:39b:8121:4e35 with SMTP id n27-20020a0568080a1b00b0039b81214e35mr3244670oij.1.1686557689059; Mon, 12 Jun 2023 01:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686557689; cv=none; d=google.com; s=arc-20160816; b=GJQz37luoxI1kfTVQGPI7aIFmoak5lLO8Ki+P6BQRju4oO5Shq95bAwVlO1deaHL11 yX7iIWY9xwcXp9TdvTKJEnmtjRPHMnJReYhpkG4E46FC2ARj6hENIrXf2IxkJgbicZwi sQiIdido4q01r4ZWkqI3h63JAynnscDzOlsWJp0l1hDPGZBT53kJpyxfBqFeIWbYXgkY dJLMgcHFFYnZ8F+R3CixwqIqhBy1Td+A39QLi38kzIeLlqtxR6GZWlEW0JYZDs2plEN8 g4AZ3BZokHmgi5uusZSD8I8yQnCbn4MwraSOCPPK3JpugAuKTwCf5GMBfGrJo+37Bnqt oJzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ovU0MGhzCzTnjcROWLwnyI2Ykpmd6U3TMNgjgLiSVjI=; b=TivUkzJ6wyfEB671J+Y7nO9x9pB3qGq9kwsFFUErFcI3X65r0gFw/tH/Hf30KT9yjp c570ewDoEIM9bsTy+qN/jDcWM6zMeV42EHKtnOGMyleuCBjFBhEZUit8zlNZNKjyzYZs IvvTjS2Dp5Csd8haXnws/dVnZuwSyVfXWwFhFIfZUZ18PN20+FL2zkq9WGcPoNjFdbfS r6ICvjF7hARAVeA1kRaufeBg4bJAP0dQeakN9RWUuG3Olb5aIL0aFUGm6QSmCn3/fNWv EIS/Mg523MbYvpp/jghM/Oq4KKXH1Nujj8ARvVaoyL4RBF6bNfgdwHLOT9eQ3uVBp6VL hafg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jm5xWvCa; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id d6-20020a17090ab30600b0024e1ae3fb36si8437234pjr.128.2023.06.12.01.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 01:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jm5xWvCa; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E9588861A4; Mon, 12 Jun 2023 10:13:49 +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="Jm5xWvCa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99F1B86020; Mon, 12 Jun 2023 10:13:34 +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-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 042CF85C2B for ; Mon, 12 Jun 2023 10:13:29 +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-x435.google.com with SMTP id ffacd0b85a97d-307d20548adso2669174f8f.0 for ; Mon, 12 Jun 2023 01:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686557608; x=1689149608; 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=ovU0MGhzCzTnjcROWLwnyI2Ykpmd6U3TMNgjgLiSVjI=; b=Jm5xWvCancICF8Zwz5GdICYC8De56CUefrWLmiqUm0SItDQf/AuTxP2EUanJTCv5M1 lCvXn9SBxWI6d4iTj7l4A6uStckZRNocqy2Yh+dIA6ic+uzdyPseRd2YP1pb7uhIZsDO Wa4YTwJZnbcZCudA+9lnMQT638wfMEfyvSbqI5eSG3AMjkpRmYlBR19FW7KNDL+6pznD yW5cKfw72KXc3oDxUiiNVijrTDLuhoObEadOZUPcB3J+Gsj07W4x1liJP4FKaCAp9pKk KpWvjRqXmsfSh4IbFdBeyc8Uy0p1OAEmh6WH+hKly/JfhmztrZzHbkIzOPBnnh9Ulyvh 4Dcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686557608; x=1689149608; 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=ovU0MGhzCzTnjcROWLwnyI2Ykpmd6U3TMNgjgLiSVjI=; b=YjACnofJN4DuswvPh4S5a4PZXkd8KGzYnQFsCcJKn2pjzICLelmARjqFmXOQxQd5gq ETmibIVIZGMDp5Rdepz9sd3iqTEGRCnl+vX9ayb03y7BZ/oI5O7SCngHdddKcv6lzHzd 14Hn6tyOQZ3XJBf+zeux1ayJ4/NjbpwEwVtil89UmtR5ZFyC0qe0gvGYKWS7sKTHg8Mn irB6SWQmbWGe8g2lIb2bRiPR8Pv9ouL2yY8UomUFCq/jsuTqhslwOK1Zvxl62veE2f8k rewSrAio+2BVsm5VT+1ZYDbUR9JXB+M6RaM8rICUDpU/hjQOV3rGR4aHkXhzXp3JmhNP mqqA== X-Gm-Message-State: AC+VfDzRrQMNbqETGNoM66PmTq2W0Zjh1N23jXHmOThRWQYfxPs+sZen oVx//zCAm0jlwC3M+NDtHeCPGewZVQqFb1fG0Hw= X-Received: by 2002:a5d:4ac7:0:b0:307:88ba:c999 with SMTP id y7-20020a5d4ac7000000b0030788bac999mr4163329wrs.62.1686557608134; Mon, 12 Jun 2023 01:13:28 -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 m9-20020a056000008900b0030ae499da59sm11637390wrx.111.2023.06.12.01.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 01:13:27 -0700 (PDT) From: Rui Miguel Silva To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Rui Miguel Silva Subject: [PATCH v3 5/6] corstone1000: set kernel_addr based on boot_idx Date: Mon, 12 Jun 2023 09:09:19 +0100 Message-ID: <20230612081314.723786-6-rui.silva@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230612081314.723786-1-rui.silva@linaro.org> References: <20230612081314.723786-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