Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C97CDC433EF for ; Sat, 13 Nov 2021 13:09:46 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3344E60551 for ; Sat, 13 Nov 2021 13:09:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3344E60551 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C430A8310A; Sat, 13 Nov 2021 14:09:42 +0100 (CET) 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="CMav9Vif"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CDD8683116; Sat, 13 Nov 2021 14:09:40 +0100 (CET) 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 02B8783108 for ; Sat, 13 Nov 2021 14:09:36 +0100 (CET) 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 p18so611971wmq.5 for ; Sat, 13 Nov 2021 05:09:36 -0800 (PST) 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=SrlrFVuerjsb2omi2VKFaaicfV+t6gpS4hAgo5s2gIs=; b=CMav9VifsFZ+YjJtP4XlYN+do5Cy0+oWS8SayFzQwJ8txdfXUcA7Zu0yvQtCjjuTIU BQVI0WQMP3RUdSmjoa8mPUQkYRY2APdA2xtlHSqKYhDXJ3ysgD5ER++pZNrGsu6+Gfd4 QJ++njHBiS0eyiXwdE9Abh5JUt9Y1ezhO88k/C928qlDqklyY9T8TbvkcTd70RqbbZDx DjDVWNj5ZawHC8hhvBZY0s4IhZRsk8n5Y6B/u7lAnYlkaBqQQcERJqb3KEHP1lw2y3kA aKutvdApLzzZu4zwc+QRhPUp6THPpBpmyvcmCbHWm7slYEtttFRpDbfBiC/wpgVYZ0yA TGUA== 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=SrlrFVuerjsb2omi2VKFaaicfV+t6gpS4hAgo5s2gIs=; b=w0zPdIYbkm3QQbORBPWdxSnnDAChEZxrSctKFOfu9cFVJK80uKvtT9c/7iCIrDwS/o 0h4Lh2E9u1fvLirephHP/0MeQJBoS+qONOVsh9aXLXb7I+D0y9qaR7Eq61CieaMfc+7N XSYmGZjbM2W/RMFjRDvC7LD1PCWr7vfkYoq7/ARqYzVAoFwydfch7hPsuYq4OTTOc8A3 u6G6WfASsqfpTCkVSf2jAI2TXT18jDdRZUFrPpc8C0tyLFSVzZ0MgmXyMLpvYu03pFn7 RCgeUdR/VpGmPTTIJqjdhWP7sosO2q8cn8YAyPL1CRo05GPK0odqOVj4e2T2F0YL9Gdm IyDg== X-Gm-Message-State: AOAM530JU+4hXcQ4GDvdBXb6zbNcIYUUM2VrIQ5ZsW32CNaYKSmhu9JU Oyt1uuJXSTZgWif3yWgs7lAitLn8jJJhZw== X-Google-Smtp-Source: ABdhPJw9bygecAMbtqHyVsH+kD98+HZXHIEFYyiGjdPioOFS95aej5fR0sSYIgnCotUjqRzLsx9E7g== X-Received: by 2002:a7b:cc95:: with SMTP id p21mr43821399wma.45.1636808976530; Sat, 13 Nov 2021 05:09:36 -0800 (PST) Received: from localhost.localdomain (248.172.185.81.rev.sfr.net. [81.185.172.248]) by smtp.googlemail.com with ESMTPSA id g13sm5913982wrd.57.2021.11.13.05.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 05:09:35 -0800 (PST) From: Amjad Ouled-Ameur To: u-boot@lists.denx.de Cc: Amjad Ouled-Ameur , Artem Lapkin , Bin Meng , Jernej Skrabec , Kory Maincent , Neil Armstrong , Ramon Fried , Simon Glass , Zhaofeng Li , khilman@baylibre.com, trini@konsulko.com Subject: [PATCH v2] cmd: pxe_utils: sysboot: add label override support Date: Sat, 13 Nov 2021 14:09:20 +0100 Message-Id: <20211113130920.17425-1-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 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 --- Changes in v2: - Use !strcmp() instead of strcmp()==0 - Add "pxe_label_override" documentation boot/pxe_utils.c | 15 +++++++++++++++ doc/README.pxe | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a7a84f26c1d5..defc806fdc4f 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1349,9 +1349,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. @@ -1361,6 +1363,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); @@ -1372,6 +1376,17 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) if (cfg->default_label && (strcmp(label->name, cfg->default_label) == 0)) default_num = label->num; + if (label_override && !strcmp(label->name, label_override)) + override_num = label->num; + } + + + if (label_override) { + if (override_num) + default_num = override_num; + else + printf("Missing override pxe label: %s\n", + label_override); } /* diff --git a/doc/README.pxe b/doc/README.pxe index b67151ca510e..a1f0423adbec 100644 --- a/doc/README.pxe +++ b/doc/README.pxe @@ -92,6 +92,12 @@ pxe boot fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily store fdt overlay(s) before applying them to the fdt blob stored at 'fdt_addr_r'. + pxe_label_override - override label to be used, if exists, instead of the + default label. This will allow consumers to choose a pxe label at + runtime instead of having to prompt the user. If "pxe_label_override" is set + but does not exist in the pxe menu, pxe would fallback to the default label if + given, and no failure is returned but rather a warning message. + pxe file format =============== The pxe file format is nearly a subset of the PXELINUX file format; see -- 2.25.1