# Tuning devd.conf for USB Ethernet on Remarkable 1?



## twschulz (Mar 28, 2020)

I'm using a Remarkable 1 and trying to connect it to my FreeBSD 12.1 machine. It connects just fine via USB as dmesg shows:


```
ugen0.3: <Linux 4.9.84-zero-gravitas with 2184000.usb RNDIS/Ethernet Gadget> at usbus0
urndis0 on uhub3
urndis0: <RNDIS Communications Control> on usbus0
ue0: <USB Ethernet> on urndis0
```

That's great, but I know that the remarkable has a DHCP server, so that it can actually give you an IP address for local access via a web server. So, I thought I would use devd(8) to run dhclient on the attached ueX.

However, it seems that while the urndis sets the vendor and product code (from debug):


```
Processing event '+urndis0 at bus=0 hubaddr=2 port=1 devaddr=3 interface=0 ugen=ugen0.3 vendor=0x04b3 product=0x4010 devclass=0x02 devsubclass=0x00 devproto=0x00 sernum="" release=0x0409 mode=host intclass=0x02 intsubclass=0x02 intprotocol=0xff on uhub3'
```

The USB Ethernet does not:

```
Processing event '!system=IFNET subsystem=ue0 type=ATTACH'
```

For the time being, I wrote this rule:


```
# Connect the Remarkable 1 device and get the IP address
attach 100 {
       device-name "urndis.+";
       match "vendor"    "0x04b3";
       match "product"    "0x4010";
       action "/sbin/dhclient ue0";
};
```

And this works, but the hardcoding of ue0 is incredibly *fragile* and is just waiting to break (if not on this machine, on another one). 

Is there some other information I could check or a knob I could adjust to make this work out of the box? Or should I write a more complex script that greps dmesg to get the correct ue out when this urndis attaches?


----------



## unitrunker (Mar 29, 2020)

Try $cdev in place of ue0.


----------



## twschulz (Mar 30, 2020)

That was a nice thought, Unfortunately $cdev is empty for that event.

I eventually just went with a rc script that devd calls with the urndis. That script looks through dmesg for ue on the passed in urndis. That works, but has some different issues, especially when one plugs and unplugs several times, but it feels slightly more robust.

I'll roll it up into a port if it holds up across a few machines.


----------



## zackb (Jan 9, 2021)

FreeBSD 12.2 with Remarkable 2:


```
$ usbconfig -d 0.5 dump_device_desc
ugen0.5: <Linux 4.14.78 with 30b20000.usb RNDIS/Ethernet Gadget> at usbus0, cfg=1 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0002  <Communication device>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x04b3
  idProduct = 0x4010
  bcdDevice = 0x0414
  iManufacturer = 0x0001  <Linux 4.14.78 with 30b20000.usb>
  iProduct = 0x0002  <RNDIS/Ethernet Gadget>
  iSerialNumber = 0x0000  <no string>
  bNumConfigurations = 0x0002

$ usbconfig -d ugen0.5 set_config 1

$ ifconfig ue0 inet 10.11.99.2

$ ifconfig ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether xx:xx:xx:xx:xx:xx
    inet 10.11.99.2 netmask 0xff000000 broadcast 10.255.255.255
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```


Then just go to http://10.11.99.1.


----------



## twschulz (Jan 10, 2021)

Yes, I have a Remarkable 2 and I think it just worked with my scripts without any changes. You can  steal shamelessly from my port. I guess I should roll it up and send it in.


----------



## zackb (Jan 17, 2021)

I manually assigned a static IP address vs. getting one dynamically from the Remarkable.

*twschulz* your scripts are more advanced and likely the right way to approach this problem. Thanks for linking your git repository.


----------



## twschulz (Jan 18, 2021)

zackb said:


> I manually assigned a static IP address vs. getting one dynamically from the Remarkable.


That works in _this_ case since there's no multiple devices connecting to the Remarkable's USB port, but who knows when something changes? 



zackb said:


> *twschulz* your scripts are more advanced and likely the right way to approach this problem. Thanks for linking your git repository.


You're welcome. I had a todo to submit it as a port. Unfortunately, the last months have been extremely busy with other things. I'll try to do a little QA on the port and at least submit the bug report.


----------

