From patchwork Thu Aug 19 11:13:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 499733 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp406518jab; Thu, 19 Aug 2021 04:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLVKET9XPAwna8YxyJvXgHLLhx83grBv0UZ6b6moQDqjbDafyvw96YdD/ySWD5CC3nFcmZ X-Received: by 2002:a05:6402:22c7:: with SMTP id dm7mr15801243edb.105.1629370995144; Thu, 19 Aug 2021 04:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629370995; cv=none; d=google.com; s=arc-20160816; b=MhG2flLY9jJIv1WSd39yfWdlSrD82WWkG9xz/6A14QLBjXFauUcbg3eMKqOLpwdJYa Xm/Ou0fik7HmcysjpvH8wfpDGSQNU7SdYiMkBhMmxdA/hpyZbkQZU6c9Dz1vVo5yL7hi 55st3lBbJPEUs2DT7F74QI7WACv4hSsOK23+fAIpNG3UGG6B3N0JEeytj8eVwi3qq1Rn 3nlBS2r03vn8niGB7xEZlzByKAtKClwVOVxngEPJX6QkLifQINOoV+bE9qlWhvg+i1Tv eHRqlA7NiAknJyfFbN6S1J8s3liVUJpaRsH3m1ggsczAhLhQGP5gp2Zyzw5GhxgLJ7N2 RYMw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=tqD6ZTG8O5lPeoFr6RnWUeEuI9k5uQ7/FI/HfufL1cE=; b=0OGB5uhaUx5sbHDqe8AjTOh5JPHtrn4Zw6vbCJGSoY63wouSQqzlxkhpPH/WTMl+JE eXTrMPJf5iFDpT9sVO5phUmS8IpCh6grN+gJLbVgPsjW4Ty7YSIiQEv0rRPltEn/VClu pQUt2+tjEIAZlSQ57hf/1SD4QGzK0zLF8GfLLmtCyLxCzzmn3aX5CeFtjlPN3EiNkmYQ acGqKHU00UvYjg65xcbUirWJWv3no6T2yZFqSXn45n5k6QzCM/1SCMJpk04oRbKUQDQ2 uxRBNnjjOS/YfnMl8qLJ29yXLTUd+iOJBRGKsMwW6HVi7ZlXQzVC7LbivpPEvymg39TG IdIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLU2Q+GB; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id g17si3165313ejo.93.2021.08.19.04.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 04:03:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLU2Q+GB; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 35C1582E7D; Thu, 19 Aug 2021 13:03:14 +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="QLU2Q+GB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CCAE83131; Thu, 19 Aug 2021 13:03:11 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 965FD8312F for ; Thu, 19 Aug 2021 13:03:06 +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=loic.poulain@linaro.org Received: by mail-wm1-x334.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so3788336wml.3 for ; Thu, 19 Aug 2021 04:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tqD6ZTG8O5lPeoFr6RnWUeEuI9k5uQ7/FI/HfufL1cE=; b=QLU2Q+GBApsSOqrtM02sjUmJ3ynV69uonk7F3l4JYINY5k1pRWgd+nTkZcFKwJfDly 3vKjeFaRBR53vK4Td4XqmapJhWvJo4GqN2g2aJBAmyxsQQbYUr79SSYH+PmjnJ/P6fk0 3TmSQXg/fzqYjK1YPxV9KNL8YbpQici9dClmnssVIX+FS5r3zdfn+0axal9YGLEv4Jxp LupmrFcy/tTkK/LAUaW1TWx1N9/dwlBJZEtHORNqZWG/00dZYsu5zp/tyWsQPYuhYL1Z 4iH5/LlynPmrzyZ6UV2ZbXID3PzEQrqTFE3z+x1KBzOyE2HIB0/ikK48/hS/Cx4L3Nb+ Qdew== 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; bh=tqD6ZTG8O5lPeoFr6RnWUeEuI9k5uQ7/FI/HfufL1cE=; b=XYJ90c3tfOoEWw4/50M6BHJlu5lW+kWq4VrmEViIpZ5DQYf2NfkPHbVgDclc/YWdR0 HcnxdIVL+7dwoapb9H8O0EXFjRQcsBBuYnRg1RNwv5w8zkah5HrDGEyVkelUhZwlzopp 12BfNwVl1v1vj8kMt614bIaIo8/kuRrnmuGkkG3zsR4f3BbfOnTzHLOSoTOLzqCaaV+n Cz1jimpNcljd1pnFocb6Ur8898vxKB+OFTucM0Cf3i+h3d2tv1wmhgs9NCQKHBsi2o86 l8gyRdp58p10UwxQHwpvufJ04JP9pg33UlV6t5y5cBFVqz3V5BWCuoKH66NdiuLGP1pI Jiuw== X-Gm-Message-State: AOAM530On9Yy6/lYya9yD1RU9yQ/eK5OTJ4JMKlpcpTXOW8N69KXtZWy WqJrYUd2YcZsxKEFC9/qCT59Ug== X-Received: by 2002:a1c:751a:: with SMTP id o26mr12913602wmc.94.1629370985802; Thu, 19 Aug 2021 04:03:05 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.passengers.t31.sncf ([109.190.253.13]) by smtp.gmail.com with ESMTPSA id d8sm2705696wrv.20.2021.08.19.04.02.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Aug 2021 04:03:05 -0700 (PDT) From: Loic Poulain To: marex@denx.de Cc: u-boot@lists.denx.de, lukma@denx.de, Loic Poulain Subject: [PATCH 3/3] cmd: add acmconsole command Date: Thu, 19 Aug 2021 13:13:06 +0200 Message-Id: <1629371586-9349-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629371586-9349-1-git-send-email-loic.poulain@linaro.org> References: <1629371586-9349-1-git-send-email-loic.poulain@linaro.org> 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 command allows to start CDC ACM function and redirect console (stdin, stdout, stderr) to USB (acmconsole start). The console can then be accessed through the USB host for debugging purpose. The host can stop the session (acmconsole stop) to revert back console to serial and unregister CDC ACM USB function. Signed-off-by: Loic Poulain --- cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 ++ cmd/acmconsole.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 cmd/acmconsole.c -- 2.7.4 diff --git a/cmd/Kconfig b/cmd/Kconfig index ffef3cc..7cc9b1c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1382,6 +1382,14 @@ config CMD_AXI Interface) busses, a on-chip interconnect specification for managing functional blocks in SoC designs, which is also often used in designs involving FPGAs (e.g. communication with IP cores in Xilinx FPGAs). + +config CMD_USB_ACM_CONSOLE + bool "ACM USB console" + select USB_FUNCTION_ACM + help + Enable the command "acmconsole" for accessing u-boot console from a + USB host through CDC ACM protocol. + endmenu diff --git a/cmd/Makefile b/cmd/Makefile index ed36694..c116091 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o obj-$(CONFIG_CMD_BOOTZ) += bootz.o obj-$(CONFIG_CMD_BOOTI) += booti.o +ob-y += acmconsole.o obj-$(CONFIG_CMD_BTRFS) += btrfs.o obj-$(CONFIG_CMD_BUTTON) += button.o obj-$(CONFIG_CMD_CACHE) += cache.o @@ -174,6 +175,7 @@ obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o +obj-$(CONFIG_CMD_USB_ACM_CONSOLE) += acmconsole.o obj-$(CONFIG_CMD_XIMG) += ximg.o obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o obj-$(CONFIG_CMD_SPL) += spl.o diff --git a/cmd/acmconsole.c b/cmd/acmconsole.c new file mode 100644 index 0000000..dac8136 --- /dev/null +++ b/cmd/acmconsole.c @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * acmconsole.c -- Console over USB CDC serial (ACM) function gadget function + * + * Copyright (c) 2021, Linaro Ltd + */ + +#include +#include +#include +#include +#include +#include +#include + +int do_usb_acmconsole(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int ret; + + if (argc != 2) + return CMD_RET_USAGE; + + if (!strcmp(argv[1], "start")) { + ret = g_dnl_register("usb_serial_acm"); + if (ret) + return ret; + + /* ACM function creates a stdio device name 'stdio_acm' */ + console_assign(stdin, "stdio_acm"); + console_assign(stdout, "stdio_acm"); + console_assign(stderr, "stdio_acm"); + } else if (!strcmp(argv[1], "stop")) { + /* default to serial (TODO: restore initial devices) */ + console_assign(stdin, "serial"); + console_assign(stdout, "serial"); + console_assign(stderr, "serial"); + + g_dnl_unregister(); + g_dnl_clear_detach(); + } else { + return CMD_RET_USAGE; + } + + return 0; +} + +U_BOOT_CMD(acmconsole, CONFIG_SYS_MAXARGS, 1, do_usb_acmconsole, + "Console over USB CDC ACM", + "start - start console over USB CDC ACM gadget function\n" \ + "acmconsole stop - stop USB console");