public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Ethernet-over-USB confusion
@ 2018-06-26 17:47 tuxic
  2018-06-26 18:44 ` R0b0t1
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tuxic @ 2018-06-26 17:47 UTC (permalink / raw
  To: Gentoo

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 <name> 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.

What modules do I need loaded exactlu on the PC
and on the SoC?


Thanks for any help in advance!
Cheers
Meino




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] Ethernet-over-USB confusion
  2018-06-26 17:47 [gentoo-user] Ethernet-over-USB confusion tuxic
@ 2018-06-26 18:44 ` R0b0t1
  2018-06-26 21:06 ` [gentoo-user] " Ian Zimmerman
  2018-06-26 21:27 ` [gentoo-user] " Poison BL.
  2 siblings, 0 replies; 4+ messages in thread
From: R0b0t1 @ 2018-06-26 18:44 UTC (permalink / raw
  To: gentoo-user

On Tue, Jun 26, 2018 at 12:47 PM,  <tuxic@posteo.de> 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 <name> 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."


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gentoo-user] Re: Ethernet-over-USB confusion
  2018-06-26 17:47 [gentoo-user] Ethernet-over-USB confusion tuxic
  2018-06-26 18:44 ` R0b0t1
@ 2018-06-26 21:06 ` Ian Zimmerman
  2018-06-26 21:27 ` [gentoo-user] " Poison BL.
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Zimmerman @ 2018-06-26 21:06 UTC (permalink / raw
  To: gentoo-user

On 2018-06-26 19:47, tuxic@posteo.de wrote:

> But I cannot ssh into the SoC even if the IP address is corrected
> manually.

Usually ssh is not the first thing you try when testing a new network
setup.

-- 
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] Ethernet-over-USB confusion
  2018-06-26 17:47 [gentoo-user] Ethernet-over-USB confusion tuxic
  2018-06-26 18:44 ` R0b0t1
  2018-06-26 21:06 ` [gentoo-user] " Ian Zimmerman
@ 2018-06-26 21:27 ` Poison BL.
  2 siblings, 0 replies; 4+ messages in thread
From: Poison BL. @ 2018-06-26 21:27 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]

On Tue, Jun 26, 2018 at 1:47 PM, <tuxic@posteo.de> 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 <name> 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.
>
> What modules do I need loaded exactlu on the PC
> and on the SoC?
>
>
> Thanks for any help in advance!
> Cheers
> Meino
>

I haven't poked a pi zero yet with the usb ethernet gadget stuff, but I
know the beaglebone side sets up its own dhcp server for the process, as
per this in their getting started docs:

"If connected via USB, a network adapter should show up on your computer.
Your Beagle should be running a DHCP server that will provide your computer
with an IP address of either 192.168.7.1 or 192.168.6.1, depending on the
type of USB network adapter supported by your computer's operating system.
Your Beagle will reserve 192.168.7.2 or 192.168.6.2 for itself."

What IP/subnet are you seeing on the pi and your desktop/laptop it's
connected to for the USB interfaces?

-- 
Poison [BLX]
Joshua M. Murphy

[-- Attachment #2: Type: text/html, Size: 2171 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-26 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-26 17:47 [gentoo-user] Ethernet-over-USB confusion tuxic
2018-06-26 18:44 ` R0b0t1
2018-06-26 21:06 ` [gentoo-user] " Ian Zimmerman
2018-06-26 21:27 ` [gentoo-user] " Poison BL.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox