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 BC1C8C433EF for ; Thu, 14 Apr 2022 19:03:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6BE783DDA; Thu, 14 Apr 2022 21:03:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=coolautomation.com 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; secure) header.d=coolautomation.com header.i=@coolautomation.com header.b="BTLbB5hP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79A2883E69; Thu, 14 Apr 2022 20:37:38 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 9319483952 for ; Thu, 14 Apr 2022 20:37:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=coolautomation.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sergey@coolautomation.com Received: by mail-ej1-x631.google.com with SMTP id r13so11691235ejd.5 for ; Thu, 14 Apr 2022 11:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolautomation.com; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=IHBE0QDyHCFfRnxreDuLT+lWWpZFPiMLbnwUYgok2iU=; b=BTLbB5hPG0WK3ATQDmd5e0lsuQxmsdK/VhddWI1Ka0fiBYCqLErlImOhh78aItgqc3 dNx7Q3Xbt85n+VBU28dWz3k8Sfeq7+0J9PQM0hpg6oMj6uAEuIphhvZQ5kvnBJpK7+RZ BDWKFgdyT2EH9rbCYvYmzLL1UZawY0QkWa6nI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=IHBE0QDyHCFfRnxreDuLT+lWWpZFPiMLbnwUYgok2iU=; b=yBoJnqLswZQ9UNfiMiAXND9mFjsd7VJMd++6SBQcGhAdIlyr/HVfF3rkwKYJWlTP9i MdZ49KRbntK3ZNOmie2bf/NcRLuo64Q8UFOH2QoC36irEJD+ikhR9RCdDnlKe1FfNb3t 76I7lbE5K2eOMxI2pchrwKMRaJAKkaE+cnjU9jardZy/4F97LdHCSkI0qwG63z5Xk3kE uRi00rE1UXgkcZzSEf5kLLAxkVx6b5UA5h6TZrPcM6DZpjfpcNH96UFyn1FgMAfO6pGE KZnY/UMitH/uyIMmuV3Ilh0iTnpzs484Vuf7XhdW4rEzDo24BAFbWPBa89DSPec7pZ7u Zj9A== X-Gm-Message-State: AOAM530fAheE7GL/8fjzrUkZ4NcTXWikWsLKvccSyOUi8+kfrFiqHjjY DIa5+uuWwKRVcEn889/Rv91ZzDhjUU5rXA== X-Google-Smtp-Source: ABdhPJxVkBrR4OHsJwoxB7pYam6zkN0n0LsJZm8dCvccIoSWsQJcLaZmqmHVMsuTA1P5JEB3iiReeQ== X-Received: by 2002:a17:906:9746:b0:6e0:5c9a:1a20 with SMTP id o6-20020a170906974600b006e05c9a1a20mr3594137ejy.714.1649961454992; Thu, 14 Apr 2022 11:37:34 -0700 (PDT) Received: from cool ([212.143.232.88]) by smtp.gmail.com with ESMTPSA id au9-20020a170907092900b006e8985cc68asm893426ejc.1.2022.04.14.11.37.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 11:37:34 -0700 (PDT) Date: Thu, 14 Apr 2022 21:37:32 +0300 From: Sergey Nazaryev To: u-boot@lists.denx.de Subject: USB init before using usb_serial_acm gadget? Message-ID: <20220414183732.o47bcymdsexbydcp@cool> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Mailman-Approved-At: Thu, 14 Apr 2022 21:03:13 +0200 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.5 at phobos.denx.de X-Virus-Status: Clean Hi! As I can see, recently [1] the implementation of USB ACM gadget has been merged into U-boot master. I tried to use it but the problem is that running `setenv stdout usbacm` on my board based on STM32MP157 leads to errors below: STM32MP> setenv stdout usbacm couldn't find an available UDC g_dnl_register: failed!, error: -19 ## Error inserting "stdout" variable, errno=22 After some research I've found that USB OTG controller must be initialized somehow before we can actually start using any gadget. For instance, on my STM32MP board `dwc2_udc_otg_probe` should be called. My research shows that `usb_gadget_initalize` is responsible for it; so, for this reason, there are explicit calls of `usb_gadget_initialize` (e.g. usb_dnl_dfu [2], usb_dnl_sdp [3]) before actual usage of any gadget. However, unlike all other gadgets, usb_serial_acm code and code that uses it don't call usb_gadget_initialize at all. Okay, I understand that usb_serial_acm shouldn't initialize USB controllers by itself, but it's still unclear who must be responsible for it. So, my main question is: what's the best place for `usb_gadget_initialize` call? Should I put it to board-specific code (board/vendor/xxx.c) or maybe it's better to put `usb_gadget_initialize` into new `usb` subcommand (`usb otgstart` or something like that) and call it before `setenv stdout usbacm`? Thank you in advance, Sergey [1]: https://source.denx.de/u-boot/u-boot/-/commit/fc2b399ac03b91339a1cb1bfd4d1a9ca87fe95c6 [2]: https://source.denx.de/u-boot/u-boot/-/blob/master/common/dfu.c#L28 [3]: https://source.denx.de/u-boot/u-boot/-/blob/master/cmd/usb_gadget_sdp.c#L24