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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8B8D3C433FE for ; Fri, 4 Nov 2022 22:59:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FE0B841D1; Fri, 4 Nov 2022 23:59:09 +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="k0jdN3Pc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BEB4B84E89; Fri, 4 Nov 2022 23:49:00 +0100 (CET) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 5162385149 for ; Fri, 4 Nov 2022 23:48:57 +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-io1-xd34.google.com with SMTP id b2so4906201iof.12 for ; Fri, 04 Nov 2022 15:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lUr/vDZ/YX9e73A0iuqEcLtoIiSuQUGCZhMZ/D8nS5E=; b=k0jdN3PcYh9EViGDpybdqOxyH+3JElLarHy4ajPSyb+NjiaMN6luduhNQPvmcA1Xom Xs0I/XGUrT2k62erRpDSU+LOVNAqqnxEH66P941G6/xKPXcip27t5KjmqC+Y6IHHytB9 pGZgL1RLTZEUKJosoCYh4TYq9OfQ+PhxBQP9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lUr/vDZ/YX9e73A0iuqEcLtoIiSuQUGCZhMZ/D8nS5E=; b=H/jhlobJcgqkd1sPpou8zjwRW75BrqtiQAQ3d8Cop0DW1ZPJbwqxP5DfU4p/eDnjNO lk9J3n5s8CQAKqRkddeyMztdRXp4dTqKCK+e5DmR9gl/klw7Coi0dL0JAS001CDtbN1z tPwnCPK9Tuf3VCDvQBMDm5vF1Yef2idCVbGZuLi/EF8tPg3TR+uwev+ppvLjUPqsX0c9 NTzZV9p7u4q5dTYX38hEY6qWnkH3kt1VdwPOukhB7C+LpAGjNGwQLGrLe1FKQYDMIT2G vPyUWiwVDvm4+9B8gk61d6Dsr/3m/hNjCGIUUuRPTw6tq/W5SaZiL/bJRf/oyBRhhiQW eL3A== X-Gm-Message-State: ACrzQf28ORNwg46MxtKP5w/Ey2/6Igg+foP+X6vvEDVl/GVJGFT2avHB 2cZ0K36yhh55pb6ZxVcOCQuH2lSdMk4c8g== X-Google-Smtp-Source: AMsMyM5yGn6RkypOej1shkMDTwYnhklPkGP85V6pBFju6xOgbCSBKpSDAf7QrF5XACsBRZsum1tXzQ== X-Received: by 2002:a02:a49:0:b0:375:496b:b233 with SMTP id 70-20020a020a49000000b00375496bb233mr21083016jaw.78.1667602135292; Fri, 04 Nov 2022 15:48:55 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003734c4d01d2sm95189jao.61.2022.11.04.15.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 15:48:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Anatolij Gustschin , Simon Glass , Andre Przywara , Andrew Davis , Andrew Scull , Artem Lapkin , Etienne Carriere , Igor Opaniuk , Ilias Apalodimas , Jaehoon Chung , Jagan Teki , Jan Kiszka , Joe Hershberger , John Keeping , Lukasz Majewski , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Marek Vasut , Masahisa Kojima , Michal Simek , Ovidiu Panait , Patrice Chotard , Patrick Delaunay , Philippe Reynes , Ramon Fried , Sean Anderson , Stefan Roese , Steven Lawrance , Thomas Huth , uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 00/25] bootstd: Add a boot menu Date: Fri, 4 Nov 2022 16:48:18 -0600 Message-Id: <20221104224844.467576-1-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 04 Nov 2022 23:59:07 +0100 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.6 at phobos.denx.de X-Virus-Status: Clean So far standard boot lacks a boot menu, although it is possible to create a rudimentary one using the existing 'bootmenu' command. Even then, this text-based menu offer only basic functionality and does not take full advantage of the displays which are common on many devices. This series provides a 'bootflow menu' command which allows the user to select from the available bootflows. An attempt is made to show the name of the available operating systems, by reading more information into the bootflow. A logo can be read also, where supported, so that this can be presented to the user when an option is highlighted. Full use is made of TrueType fonts, if enabled. For cases where only a serial console is available, it falls back to a simple text-based menu. All of this is implementing using a new 'expo' construct, a collection of scenes (like menu screens) which can be navigated by the user to view information and select options. This is fairly general and should be able to cope with a wider array of use cases, with less hacking of the menu code, such as is currently needed for CMD_BOOTEFI_BOOTMGR. Of course it would be possible to enhance the existing menu rather than creating a new setup. Instead it seems better to make the existing menu use expo, if code space permits. It avoids the event-loop problem and should be more extensible, given its loosely coupled components and use of IDs instead of pointers. Further motivation is provided in the documentation. For now the CLI keypress-decoding code is split out to be used by the new menu. The key codes defined by menu.h are reused also. This is of course just a starting point. Some ideas for future work are included in the documentation. Changes in v2: - Drop the _add suffix on expo creation function - Fix 'touse' typo - Fix pylint warning in mkdir_cond() - Put strings in a separate structure referenced by ID - Rebase to master - Rename vidconsole_get_font() to vidconsole_get_font_size() - Update for new API Simon Glass (25): sandbox: Enable mmc command and legacy images cli: Move readline character-processing to a state machine bootmenu: Add a few comments menu: Rename KEY_... to BKEY_... menu: Update bootmenu_autoboot_loop() to return the code menu: Update bootmenu_loop() to return the code menu: Use a switch statement menu: Make use of CLI character processing image: Add a function to find a script in an image image: Move common image code to image_board and command video: Enable VIDEO_ANSI by default only with EFI video: truetype: Rename the metrics function video: Fix unchnaged typo video: Add font functions to the vidconsole API bootstd: Read the Operating System name for distro/scripts bootstd: Allow reading a logo for the OS menu: Factor out menu-keypress decoding expo: Add basic implementation expo: Add support for scenes expo: Add support for scene menus expo: Add basic tests bootstd: Support creating a boot menu bootstd: Add a test for the bootstd menu bootstd: Support setting a theme for the menu expo: Add documentation .../cmd_stm32prog/cmd_stm32prog.c | 2 +- arch/sandbox/dts/test.dts | 11 + boot/Kconfig | 12 + boot/Makefile | 3 + boot/bootflow.c | 1 + boot/bootflow_internal.h | 47 ++ boot/bootflow_menu.c | 284 +++++++++ boot/bootmeth-uclass.c | 69 ++- boot/bootmeth_distro.c | 36 ++ boot/bootmeth_script.c | 40 +- boot/bootstd-uclass.c | 2 + boot/expo.c | 170 ++++++ boot/image-board.c | 133 +++++ boot/scene.c | 414 ++++++++++++++ boot/scene_internal.h | 123 ++++ boot/scene_menu.c | 390 +++++++++++++ cmd/bootflow.c | 44 +- cmd/bootmenu.c | 19 +- cmd/eficonfig.c | 38 +- cmd/font.c | 11 +- cmd/source.c | 140 +---- common/Makefile | 6 +- common/cli_getch.c | 208 +++++++ common/cli_readline.c | 150 +---- common/command.c | 19 + common/menu.c | 157 +++-- configs/sandbox_defconfig | 2 + configs/sandbox_flattree_defconfig | 2 + configs/snow_defconfig | 4 + configs/tools-only_defconfig | 2 + doc/develop/expo.rst | 188 ++++++ doc/develop/index.rst | 1 + drivers/usb/gadget/f_sdp.c | 2 +- drivers/video/Kconfig | 7 +- drivers/video/console_truetype.c | 37 +- drivers/video/vidconsole-uclass.c | 33 ++ include/bootflow.h | 40 ++ include/bootmeth.h | 16 + include/bootstd.h | 4 + include/cli.h | 74 +++ include/command.h | 12 + include/expo.h | 521 +++++++++++++++++ include/image.h | 17 +- include/menu.h | 77 ++- include/video.h | 2 +- include/video_console.h | 75 ++- test/boot/Makefile | 2 + test/boot/bootflow.c | 130 +++++ test/boot/expo.c | 539 ++++++++++++++++++ test/cmd/font.c | 6 +- test/py/tests/bootstd/armbian.bmp.xz | Bin 0 -> 1384 bytes test/py/tests/bootstd/mmc4.img.xz | Bin 0 -> 7072 bytes test/py/tests/test_android/test_avb.py | 2 + test/py/tests/test_ut.py | 218 ++++++- 54 files changed, 4075 insertions(+), 467 deletions(-) create mode 100644 boot/bootflow_internal.h create mode 100644 boot/bootflow_menu.c create mode 100644 boot/expo.c create mode 100644 boot/scene.c create mode 100644 boot/scene_internal.h create mode 100644 boot/scene_menu.c create mode 100644 common/cli_getch.c create mode 100644 doc/develop/expo.rst create mode 100644 include/expo.h create mode 100644 test/boot/expo.c create mode 100644 test/py/tests/bootstd/armbian.bmp.xz create mode 100644 test/py/tests/bootstd/mmc4.img.xz -- 2.38.1.431.g37b22c650d-goog