From mboxrd@z Thu Jan 1 00:00:00 1970 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 5739AC433FE for ; Sun, 17 Apr 2022 08:45:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1A0A83C58; Sun, 17 Apr 2022 10:45:17 +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="E/wvsmbg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5568F83C5A; Sun, 17 Apr 2022 10:45:16 +0200 (CEST) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 B7A4C83A62 for ; Sun, 17 Apr 2022 10:45:13 +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-ed1-x530.google.com with SMTP id b24so14504776edu.10 for ; Sun, 17 Apr 2022 01:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolautomation.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0Qw8vfB7pvGw1zO033RiBM6BM/vIaGFZh2VJhjdGQ2E=; b=E/wvsmbgFiqqTL6ccBlEKuTlLz8h5+mOKuYNQ/Ece4/dtfBIhwfKYuHg2ibxx8R9Oi BaQNZsACZzh7loBzxtZ6BFEiqJNImzYNK+Uax1urMsOl+XBMjYgLTIgvZasZqXvta0EE pPyFBuLRjv5mceKcuZLYwwddf4Ub6KepFQ/gQ= 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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0Qw8vfB7pvGw1zO033RiBM6BM/vIaGFZh2VJhjdGQ2E=; b=anrqCW7PuteGxY8WBwmHBHeMBWcW2L/As62FkodymdaadYCntqQ0+7DvcP4lc8+4IY 0sMZZP/GLggdl1VmO3C7N4JOYa9Z/jvL8PuXmkXCNPJA78hIBycwejwkzzkG7xkdCkkG k1gjyc/MtZSl5SEFF64W8SWEljJC5FaWKNF3aKurHmQOFu15WxalwikXjiVfW4Ot490N mAO3BGNcteLie/l/Z/ZDomku0oH/CZWM7PkgbrXeSzeLWuypErc+goW3JLXnpZWKm1z4 9NjMRiS7+62avbTftlfc7ty0diSSd23fKgUtvgTZt1nu9y6QpbBiSCZrQOTKTkaV3v17 4kBQ== X-Gm-Message-State: AOAM533lswS0qIrYU71RhLNFfGZLFuWc8rZgENXpsIV6j7NYXIRkr2u4 CkYn/5RxR9/e3dYiW25syuhcvQ== X-Google-Smtp-Source: ABdhPJzrdImN/be74Wv0/7Zo6Xn8TWv72a9UawkFBYqUSueH4TffCw3H58eo7nnBmHjuTB7EgPL0Jw== X-Received: by 2002:a05:6402:5191:b0:41c:e08c:ae21 with SMTP id q17-20020a056402519100b0041ce08cae21mr7064281edd.268.1650185113372; Sun, 17 Apr 2022 01:45:13 -0700 (PDT) Received: from cool ([212.143.232.88]) by smtp.gmail.com with ESMTPSA id x8-20020a170906134800b006e86ff7db33sm2183577ejb.68.2022.04.17.01.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 01:45:12 -0700 (PDT) Date: Sun, 17 Apr 2022 11:45:10 +0300 From: Sergey Nazaryev To: Loic Poulain Cc: u-boot@lists.denx.de Subject: Re: USB init before using usb_serial_acm gadget? Message-ID: <20220417084510.mdofaf22xf2zxyyu@cool> References: <20220414183117.wguqf5ggey7yxkhl@cool> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 > So I think the right place to call usb_gadget_initialize is probably > before registering the acm gadget function into acm_stdio_start(). Can > you try this? and submit a follow_up fix patch if working? It's required for `usb_gadget_initialize` to provide a "USB controller index" as an argument. It's pretty obvious how to do it in "interactive world" (e.g. to ask user for this number via CLI, like it was in commands mentioned in my previous message) but in our case we need to provide this number in non-interactive manner. There is not an elegant solution with hardcoding '0' as a controller index like it was done in `ether` gadget [1], but it seems that it was a temporary fix ("This is a preparatory work for DM support for UDC drivers") that occasionaly became a permament solution. So, that's why I suggested to add a new subcommand to `usb` for OTG initialization: in my opinion, it's better to require an explicit call of something like `usb otgstart 0` than hardcoding a '0' into the code. One more option is to add a new environment variable to explictly specify a controller index, and read this variable from all places when it requires. P.S. I already put `usb_gadget_intiialize(0)` to my board code, and ACM gadget started working; so the remaining problem is only to decide where is the best place for this call. [1]: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/usb/gadget/ether.c#L2355