From patchwork Thu Mar 4 13:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1447351 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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=nY/tpsyR; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Drss430Kjz9sRf for ; Fri, 5 Mar 2021 00:58:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8DF5828FD; Thu, 4 Mar 2021 14:53:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="nY/tpsyR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C69082857; Thu, 4 Mar 2021 14:52:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (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 108A38276B for ; Thu, 4 Mar 2021 14:52:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x232.google.com with SMTP id q203so7117208oih.5 for ; Thu, 04 Mar 2021 05:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3RuKvFhySolsAjowShwSKp9R30R3Ah8bs34aYOsOc74=; b=nY/tpsyRHT9/arv2XM6YHJpQFHjwAEDQHDZ2np7cON9rBZdDd4m59P5RHZ+ydGW2gn 9KQP8TfHnrN8KmqzIWM2HjRw5b+gaBUr2tcAds1iLPZ3tWwzqNjlmshTeCOZXiTDtXg7 RQ0kVfmeZNrSymE55ow/Raoqgkj5Bi3ZXoBu4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3RuKvFhySolsAjowShwSKp9R30R3Ah8bs34aYOsOc74=; b=D1joj+fqTd7BFR7YQAH1VJiYoVPVV4AHViyGeiafkz5jQKNpis7wYaLzYvb6TytZ8m 6AGO6QELmJ7MWb8d1sMCPHxE1syEyIZS1btcLTxHgyDn68+RIxW/0AKZRf5h48HYfz9F PUuyeslG8pcnvISThBvtPD/gd595/yJOaSaPePc4IRu+Ia0jC/c4jZ+5/ZRpyrso6r+u W2X5O/2BlF704gDMv+dc59cIdpVT1Z1AeuZGXggv2uY2/6jbnTDxAFhTH2UsBtm9JSKN AVivW1Ervxu26Zu+FwlKo5bXnMFaaxHocn4O6Zyw7WVE4sV+tFbMOmhHJxuYSxlF8AXd 1qCg== X-Gm-Message-State: AOAM533LE4YUmvwft5fgyZprmGY6BG8SQQCd9IVAchifoXvVbsn+mOV0 Xi96CeKby0G+mQCYh2GL0s/O7OwTOMh2bXZ9 X-Google-Smtp-Source: ABdhPJyl2fPafD123JHpsrHXfIlfj07vXBr/lUCawIr+xR55rjvoIfI9FlFbKZ0bv0JhziR8VKTyRQ== X-Received: by 2002:a05:6808:1d7:: with SMTP id x23mr2915410oic.31.1614865938364; Thu, 04 Mar 2021 05:52:18 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id x10sm4029465otp.19.2021.03.04.05.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 05:52:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Stephen Warren , Stephen Warren , Simon Glass Subject: [PATCH v4 37/42] sandbox: Update os_find_u_boot() to find the .img file Date: Thu, 4 Mar 2021 06:51:13 -0700 Message-Id: <20210304135118.643277-36-sjg@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210304135118.643277-1-sjg@chromium.org> References: <20210304135118.643277-1-sjg@chromium.org> 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 At present this function can only locate the u-boot ELF file. For SPL it is handy to be able to locate u-boot.img since this is what would normally be loaded by SPL. Add another argument to allow this to be selected. While we are here, update the function to load SPL when running in TPL, since that is the next stage. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/os.c | 8 +++++--- arch/sandbox/cpu/spl.c | 2 +- include/os.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index f5000e64966..2d9583c17ca 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -777,7 +777,7 @@ int os_jump_to_image(const void *dest, int size) return os_jump_to_file(fname); } -int os_find_u_boot(char *fname, int maxlen) +int os_find_u_boot(char *fname, int maxlen, bool use_img) { struct sandbox_state *state = state_get_current(); const char *progname = state->argv[0]; @@ -801,8 +801,8 @@ int os_find_u_boot(char *fname, int maxlen) return 0; } - /* Look for 'u-boot-tpl' in the tpl/ directory */ - p = strstr(fname, "/tpl/"); + /* Look for 'u-boot-spl' in the spl/ directory */ + p = strstr(fname, "/spl/"); if (p) { p[1] = 's'; fd = os_open(fname, O_RDONLY); @@ -829,6 +829,8 @@ int os_find_u_boot(char *fname, int maxlen) if (p) { /* Remove the "spl" characters */ memmove(p, p + 4, strlen(p + 4) + 1); + if (use_img) + strcat(p, ".img"); fd = os_open(fname, O_RDONLY); if (fd >= 0) { close(fd); diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index ce5aae87fb6..f82b0d3de16 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -37,7 +37,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image, char fname[256]; int ret; - ret = os_find_u_boot(fname, sizeof(fname)); + ret = os_find_u_boot(fname, sizeof(fname), false); if (ret) { printf("(%s not found, error %d)\n", fname, ret); return ret; diff --git a/include/os.h b/include/os.h index d2a4afeca0f..77d8bd89d0f 100644 --- a/include/os.h +++ b/include/os.h @@ -324,9 +324,10 @@ int os_jump_to_image(const void *dest, int size); * * @fname: place to put full path to U-Boot * @maxlen: maximum size of @fname + * @use_img: select the 'u-boot.img' file instead of the 'u-boot' ELF file * Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found */ -int os_find_u_boot(char *fname, int maxlen); +int os_find_u_boot(char *fname, int maxlen, bool use_img); /** * os_spl_to_uboot() - Run U-Boot proper