From patchwork Fri Oct 22 15:55:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 1544994 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ZrCyMGdx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbTTm41V1z9sXN for ; Sat, 23 Oct 2021 02:55:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9789E8326F; Fri, 22 Oct 2021 17:55:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="ZrCyMGdx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CB93831BA; Fri, 22 Oct 2021 17:55:42 +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,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 5993E834C1 for ; Fri, 22 Oct 2021 17:55:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aouledameur@baylibre.com Received: by mail-wm1-x332.google.com with SMTP id u8-20020a05600c440800b0030d90076dabso9148429wmn.1 for ; Fri, 22 Oct 2021 08:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9mWdD2BV3h9CL8MuTiBBiH6IgR1Y+no6Ut7b36spS1c=; b=ZrCyMGdxGArB6PWo0ilBcfk/Tdsb4gw9zsQ6Q54usleROVIdTHdtzZFC51o9vRBNA4 xS1GIH8HiOVvW19+hSfEtptgcBt96ySMq545WMeW8Nm8thGt8hOqJlEU9yNS8MYfHxsy 7CSo1YFRMrCvRdg8e3xTraQHaxsoBOdCpm7C0rPzqLOqsfL+JFYziGGXspj9UHHTCk7L JHZzTlN30bGxh+KnK1fxT2xO5OMuv4r7SVIeylcZRuj9pt/2aUXLZgzIYh2YLXB7MkSu rWP3ha5py5tzKA9RQew1jAdjOktklt/cJhPchQ+2KXIpbwxiya7ThxEE53YR3vsfKiJY bgiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9mWdD2BV3h9CL8MuTiBBiH6IgR1Y+no6Ut7b36spS1c=; b=Pn2fRqa0HX3EunfPP3g+9aIxkIzVO76JQiX8uUDcmC9t3kDwLR91xM8oHSiHARYc0z ZRy2Pm3XY8IatRrYzzMqTvNsLevcSeEUsQyGihUxJArruOjGl1DTx2vf//Y9zqtfc8qT 4MY6Mb9UsKiLYX1X1nuBjhidhtGxrlKHiUAyYdLRa0gV/Nt4sexAMBuuEl2lD4aSi17r FtxaNsaynDAbywwZBoSakuKwQzkqBw6IVUiRNxYWGbnaIRHQF/crR4iYryhsVWjaI3Zu A8pdeshFg7fQB5QQGyNOZFfa+H0m9gPsoRsDcXpPF3jFKzAb9pIItwM1hS3DSldqK46K Gydw== X-Gm-Message-State: AOAM532x8XHUb/fshjsBw7VJcAuglW1wa7k72Yud3N518ctT3Sf+X7Re 9CJiTWk0HFuWwjnBDgq7ZsVx+zyCI/HRlg== X-Google-Smtp-Source: ABdhPJyqpp89qUyv679Aoyx6YeF6uXZoctF+uo9B6SNPbbismPV900h0t3xjkpc8K8rR/pg/qeF/gw== X-Received: by 2002:a7b:c1cc:: with SMTP id a12mr579793wmj.23.1634918138832; Fri, 22 Oct 2021 08:55:38 -0700 (PDT) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id k17sm12615071wmj.0.2021.10.22.08.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 08:55:38 -0700 (PDT) From: Amjad Ouled-Ameur To: u-boot@lists.denx.de Cc: Amjad Ouled-Ameur , Anton Leontiev , Bin Meng , Dimitri John Ledkov , Jernej Skrabec , Kory Maincent , Neil Armstrong , Ramon Fried , Simon Glass , khilman@baylibre.com, trini@konsulko.com Subject: [PATCH] cmd: pxe_utils: sysboot: add label override support Date: Fri, 22 Oct 2021 17:55:26 +0200 Message-Id: <20211022155526.54368-1-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.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.103.2 at phobos.denx.de X-Virus-Status: Clean This will allow consumers to choose a pxe label at runtime instead of having to prompt the user. One good use-case for this, is choosing whether or not to apply a dtbo depending on the hardware configuration. e.g: for TI's AM335x EVM, it would be convenient to apply a particular dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the pxe menu should have 2 labels, one with the dtbo and the other without, then the "pxe_label_override" env variable should point to the label with the dtbo at runtime only when the jumper is on PRUSS mode. This change can be used for different use-cases and bring more flexibilty to consumers who use sysboot/pxe_utils. if "pxe_label_override" is set but does not exist in the pxe menu, the code should fallback to the default label if given, and no failure is returned but rather a warning message. Signed-off-by: Amjad Ouled-Ameur --- cmd/pxe_utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 067c24e5ff4b..b1009f9c7547 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -1354,9 +1354,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) struct pxe_label *label; struct list_head *pos; struct menu *m; + char *label_override; int err; int i = 1; char *default_num = NULL; + char *override_num = NULL; /* * Create a menu and add items for all the labels. @@ -1367,6 +1369,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) if (!m) return NULL; + label_override = env_get("pxe_label_override"); + list_for_each(pos, &cfg->labels) { label = list_entry(pos, struct pxe_label, list); @@ -1375,11 +1379,22 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) menu_destroy(m); return NULL; } + if (label_override && + (strcmp(label->name, label_override) == 0)) + override_num = label->num; if (cfg->default_label && (strcmp(label->name, cfg->default_label) == 0)) default_num = label->num; } + if (label_override) { + if (override_num) + default_num = override_num; + else + printf("Missing override pxe label: %s\n", + label_override); + } + /* * After we've created items for each label in the menu, set the * menu's default label if one was specified.