From patchwork Tue May 2 13:11:59 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: 678399 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp499915wrs; Tue, 2 May 2023 06:13:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QtwkiBPga/uzbd/y3a+1CjxaWGi3YifU7k5Somu5x0FCzMZh/qtUKkjvFlM6k2Ff2lZJ8 X-Received: by 2002:a05:6a00:1789:b0:642:ffef:1d03 with SMTP id s9-20020a056a00178900b00642ffef1d03mr1883983pfg.32.1683033209910; Tue, 02 May 2023 06:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683033209; cv=none; d=google.com; s=arc-20160816; b=xUn6ZMJgsC1bQpEHw3HjYXG8vjtVlMmCo1n6VIaQp/Ho/WSv01etX0nfmw2fwJsRre 6ifXtsF8aj7jqrcItCjbPWLNqoD/odTW0DsViUDm7e4OwwuARiArY1WQwskBYKMfNLEP /MSaOpZNrba+ePnISMbaBNIi7B6acOLW3kQBZcuIcYpEOF8LCYk9v+UL7eLaFiWI1PTM wXuDNG0HwfnBaffIKgs/Y3d+irE8oC6nOAIR9szreLt7rdzUsTG1WpkT6Fq29iRJRb5o 3mluu+/jHVgkFW02BZsuVLHZngoiEYBc82PTPjp448G7EvOFzmM/cKKFCB657IYCTcJR Pqdw== 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=0kXcHmrTGhAsYW+GY8q4oSakae8yeLX+s+0qCphutOE=; b=uvTqLMA9sw2655645styzirXNhCFU1JVwOzcRQcZbi/NCkVDqnhHPxYsk1CKEVtWSd DjaCbrtvQbMSz7hQ2JYXge4H02Wo4Lm3vk3r53o1ThbX/V69xaJWNfqXojUugekvFGn3 ebdbeg+wgJ44ZYZl7R+nVFWFSu5C6G4iXmZQSxJCBzntez6gp/yCKIouMMyI8/Fqjs5u d3lyandXIATpTxY6lHVmk/BSNxOjek8NKRzyHosLgx1SHbCZr7Rm0VpzJK4mWfnrA4T+ zbwi0Iy0C60gHFjfXOKAEZnTW/W4BNpv82WyLibKLYLtAtUZqBWtH5IdfSiwRnCp2r6a G6WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gINWAWG0; 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 n184-20020a6327c1000000b0051b8ab9b2a7si30851295pgn.193.2023.05.02.06.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 06:13:29 -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=gINWAWG0; 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 D948B84735; Tue, 2 May 2023 15:12:31 +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="gINWAWG0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D278984754; Tue, 2 May 2023 15:12:29 +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-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (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 57E3E84735 for ; Tue, 2 May 2023 15:12:26 +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-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f315712406so168621185e9.0 for ; Tue, 02 May 2023 06:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683033145; x=1685625145; 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=0kXcHmrTGhAsYW+GY8q4oSakae8yeLX+s+0qCphutOE=; b=gINWAWG0cLDdP9l3uRjPqwdi6peLc5nVVuVKhItSO7sdXcB9meiRGdvAOBsiuiUrPd gmtDTnUsCbyVhFvYPNBYua6slV4TR+GDfwn5v5Wo1yCdiprHJsRYYRjvAgIXfKTeXDGs M4vKZxqI98V09WaMMxH/YlxpGEXvRaRAvfj32rcV9hrOFFBPloEE+YVkx+icNjBZrAZ4 YPLwbGbKGP3KCV5VnkP8k2pz9FWkG7UN5JTQ/ruAci889nCCgCFMnyj9o2blSIqBxY2v c1Y/sTZekv3TB2Za35ed7VfYeaqRl4tTYYz1W2ZUSUdKcmSMNw9Q/qAvULO28CCzo3Fs j+4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683033145; x=1685625145; 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=0kXcHmrTGhAsYW+GY8q4oSakae8yeLX+s+0qCphutOE=; b=M6vNMavH3M4Fu6/KfUxHTUKEwEjBqbpes9pu6FjLoOtSd3+B8DiYUAM0ZTU7xXHoJf PXfx0L74r6SGRxB7xlf9LLx4xr0P+3iUizdg2q2mIC2uxO9GXmzQXLeXZzxwYKMTYpCL GG+0YQ9WqEuyfIM7POU/XXJHEb/Hc06S5DzyP+X5pNxovrzUrK9opajxk61VWGuK3LYT hr8S8sgJjziQHlX8bDoJu8mZtMMdQgnHD9tt5ktLhYo3oFkZsIyPcj/DsTbdiy//tzK/ NlrYc2Se3/OherT04aq4P9T+7I10A8navy61J0B+wTvxARSrSRDotqQpB9fvFS9jQpeA sszw== X-Gm-Message-State: AC+VfDzXHIxgP8wzg8CVXOsPAzSmRV2UupEm+GrnsSToNCP9vZOmK48x Nlj1nirqmOfwgkW9ZN46F1//PRfoJ0vQWGKmIFI= X-Received: by 2002:a05:600c:190e:b0:3f1:96a8:3560 with SMTP id j14-20020a05600c190e00b003f196a83560mr15849858wmq.10.1683033144996; Tue, 02 May 2023 06:12:24 -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 c21-20020a7bc855000000b003f17300c7dcsm35277121wml.48.2023.05.02.06.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 06:12:24 -0700 (PDT) From: Rui Miguel Silva To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Rui Miguel Silva Subject: [PATCH 5/6] corstone1000: set kernel_addr based on boot_idx Date: Tue, 2 May 2023 14:11:59 +0100 Message-Id: <20230502131200.2551513-6-rui.silva@linaro.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230502131200.2551513-1-rui.silva@linaro.org> References: <20230502131200.2551513-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