Tuning devd.conf for USB Ethernet on Remarkable 1?

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:

Code:
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):

Code:
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:
Code:
Processing event '!system=IFNET subsystem=ue0 type=ATTACH'

For the time being, I wrote this rule:

Code:
# 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?
 
Last edited by a moderator:
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.
 
FreeBSD 12.2 with Remarkable 2:

Code:
$ 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.
 
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.
 
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? :)

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.
 
Back
Top