From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F45A138334 for ; Tue, 26 Jun 2018 18:44:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 809EAE093D; Tue, 26 Jun 2018 18:44:22 +0000 (UTC) Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com [IPv6:2a00:1450:4010:c07::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ABE91E0855 for ; Tue, 26 Jun 2018 18:44:21 +0000 (UTC) Received: by mail-lf0-x22d.google.com with SMTP id b7-v6so7298541lfa.0 for ; Tue, 26 Jun 2018 11:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=7rHz0mJiqgMu3m/s/8seWf45TCuT8wBkcdKm7zunQjs=; b=blpOFAzudiukizFP0Ig0zs22BcQ0U4zPvSGL+0aTlYHIJymuc0MgOwbW4QxVfeq7Le yFINvY667yH3TYX4OPRrKMduiifrzm2nzFIcvqUTTTj/ie+DP5egSKSw+YgCTGgNUN9r xFKRckf4CMsbjCQQlp1tyEzcMzewXdrWN2FEtC9BOyHfq/3akNhK9zYna1CRvv3xqyox Bfq4GaMNeM4z2TBSJLqXYc6GOIYt2F7J6YTtPLRuNfIlpgzKG3xDyEMB/lS/EJeAuj5E I2jaQ4eRK83DOtuuyYypjJQuRd0Y9QC8/TH2LLRDLi8J2JU9pXMZ6YL4Q/w1R0v3we7p numA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=7rHz0mJiqgMu3m/s/8seWf45TCuT8wBkcdKm7zunQjs=; b=EfSx5r6jxsFlb98PX3aM8iPTgLVs39cXI1432JGcxFZrp5Qz5+lS6NV85UkfTN1lDv DaIyJ4E1a/I93ASFXr5KxP2q2TWSH1NZShdkqrQ91C/4zmzd+nsbcXQY1Cz2vV4KzG0B jxxMgEWllk9o78lKmjsw1Ohje52MVw6fgGxauy4Qtn2aBn+McBtR5pHCBW4QP/cN13yG KRnRoEJ8PsvHwL5jhTrXPUCxrsQz0F7ViEXLvXEKYxqQC2mlPKqlyaUzwsU9Se4zr70c 70S5K+ZJgDcZlpPg290ZRckWu3bwrQ6iIB9Gd6TqSmTeOkBZAFbyKVjJHfRBNxEzTlGw 44yg== X-Gm-Message-State: APt69E1LnIFjYdlvTBFlEri8h87My/o3THhQt7B1hYL309NqFjutR2JN f4d7Xi2bPrhzqriBRw+3qPvNDdbpU95J+rHHvu34NQ== X-Google-Smtp-Source: AAOMgpezMKr9nj+C1T8tIrlAeKTKpYKsFGWXjg7P18E0Bm2ZR1mskcfPWQDEKTZsggEXmLjd0OY/9eC2bYJZTMjhhJM= X-Received: by 2002:a19:e1cc:: with SMTP id l73-v6mr1982352lfk.102.1530038659472; Tue, 26 Jun 2018 11:44:19 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Received: by 2002:a2e:854a:0:0:0:0:0 with HTTP; Tue, 26 Jun 2018 11:44:19 -0700 (PDT) In-Reply-To: <20180626174742.wpg7zh37xrgp76mg@solfire> References: <20180626174742.wpg7zh37xrgp76mg@solfire> From: R0b0t1 Date: Tue, 26 Jun 2018 13:44:19 -0500 Message-ID: Subject: Re: [gentoo-user] Ethernet-over-USB confusion To: gentoo-user@lists.gentoo.org Content-Type: text/plain; charset="UTF-8" X-Archives-Salt: 348e0d73-1f0f-45df-81e0-add06bb00fe0 X-Archives-Hash: c035cf4baea56d475f7b55118f236068 On Tue, Jun 26, 2018 at 12:47 PM, wrote: > Hi, > > short question: > > I want to access my Raspberry Pi Zero W via Ethernet-over-USB > via ssh. > On the Raspberry I have to include a module called g_ether. > After rebooting I can see a new interface whith an IP assigned > via ifconfig. > On my PC I see a new inteface and dmesg tells me, that > usb0 was renamed to a hillarious cryoted other name > and this also shows up when using ifconfig. > But it has a complete different IP assigned, > > But I cannot ssh into the SoC even if the IP > address is corrected manually. > Can you SSH into it at all via some other interface? Can you ping it? Try g_multi so that you can have a serial terminal to log in with. If possible switch to using g_ffs. I have included a script at the end of my message which will create both CM and ACM (serial) endpoints. On the device, bring up the interface and give a fixed static IP to the interface. A route should be created but if not route everything on that subnet through the gadget ethernet device. On the host, bring up the interface and give a fixed static IP to the interface. A route should be created but if not route everything on that subnet through the gadget ethernet device. It may be necessary to bring up the device first. > What modules do I need loaded exactlu on the PC > and on the SoC? > If usbX shows up and is renamed then you have the proper driver loaded. There should be a message labelled "cdc_XXX." By default g_ether should use CDC ECM (Ethernet control model), but it is also possible to use CDC EEM (Ethernet emulation model), CDC NCM (network control model), or RNDIS (remote network driver interface specification, Windows). Of the protocols ECM is the simplest, and in theory should have the worst throughput do to inefficiency when wrapping Ethernet frames. However in my tests it had the highest throughput by a few Mb/s (~90Mbit). EEM and NCM were tied (88Mbit) though NCM is the newest and may eventually surpass the others. RNDIS was slower by 10-15Mb/s (70Mbit) and a full specification does not exist. However, it may be necessary if you wish to easily use your device with Windows machines. Cheers, R0b0t1 --- #!/bin/bash set -euo pipefail # General configuration: GADGET_NAME="testgadget" LANGUAGE=0x409 MANUFACTURER="R0b0t1" PRODUCT="Test Gadget" # Function configuration: HOST_ADDRESS="1a:55:89:a2:69:42" DEV_ADDRESS="1a:55:89:a2:69:41" if [ "$EUID" -ne 0 ]; then echo "This script must run as root." exit 1 fi echo "Loading libcomposite..." CONFIGFS="/sys/kernel/config/usb_gadget" GADGET="$CONFIGFS/$GADGET_NAME" modprobe libcomposite while [ ! -d $CONFIGFS ]; do sleep 0.01 done echo "Cleaning existing gadget..." find $GADGET/configs/*/* -maxdepth 0 -type l -exec rm {} \; || true find $GADGET/configs/*/strings/* -maxdepth 0 -type d -exec rmdir {} \; || true find $GADGET/os_desc/* -maxdepth 0 -type l -exec rm {} \; || true find $GADGET/functions/* -maxdepth 0 -type d -exec rmdir {} \; || true find $GADGET/strings/* -maxdepth 0 -type d -exec rmdir {} \; || true find $GADGET/configs/* -maxdepth 0 -type d -exec rmdir {} \; || true rmdir $GADGET || true #find "$GADGET/configs" -maxdepth 2 -type l -exec "rm" {} \; #find "$GADGET"/configs/*/strings/* -maxdepth 0 -type d -exec "rmdir" {} \; #find "$GADGET"/os_desc/* -maxdepth 0 -type l -exec "rm" {} \; #find "$GADGET"/configs/functions/* -maxdepth 0 -type d -exec "rmdir" {} \; #find "$GADGET"/configs/* -maxdepth 0 -type d -exec "rmdir" {} \; #rmdir "$GADGET" echo "Creating gadget..." mkdir "$GADGET" cd "$GADGET" echo "Configuring device identifiers..." echo 0x1d6b > idVendor # Linux Foundation echo 0x0104 > idProduct # Multifunction Composite Gadget echo 0x0001 > bcdDevice # v0.1.0 echo 0x0200 > bcdUSB # USB 2.0 mkdir "strings/$LANGUAGE" echo "$MANUFACTURER" > "strings/$LANGUAGE/manufacturer" echo "$PRODUCT" > "strings/$LANGUAGE/product" echo "Configuring composite device..." echo 0xEF > bDeviceClass echo 0x02 > bDeviceSubClass echo 0x01 > bDeviceProtocol # This is necessary for multifunction devices to work with Windows due to deficiencies in the same's driver stack. echo "Configuring OS-specific descriptors..." echo 1 > os_desc/use echo 0xcd > os_desc/b_vendor_code echo MSFT100 > os_desc/qw_sign echo "Creating Ethernet endpoint (CDC NCM) (1/1)..." mkdir "functions/ncm.usb0" #echo "$HOST_ADDRESS" > "functions/ncm.usb0/host_addr" #echo "$DEV_ADDRESS" > "functions/ncm.usb0/dev_addr" echo "Creating serial endpoint (1/2)..." mkdir "functions/acm.usb0" echo "Creating configuration..." mkdir "configs/c.1" echo 500 > "configs/c.1/MaxPower" mkdir "configs/c.1/strings/$LANGUAGE" echo "Config 1" > "configs/c.1/strings/$LANGUAGE/configuration" ln -s "functions/ncm.usb0" "configs/c.1" ln -s "functions/acm.usb0" "configs/c.1" ln -s "configs/c.1" "os_desc/c.1" echo "Attaching device..." udevadm settle ls "/sys/class/udc/" > UDC echo "Done."