Activate "ETH over USB" on Linux [SIMPLE TRICK]

Hi,

I need to modify the kernel to enable the USB networking ability for my network of development boards. (currently 1master & 10servers) we need to use usb connections for networking functionalities.

My question: is it possible to modify the linux kernel without compiling a whole image from scratch. We are now developing a network of mashines and are thinking ahead, doing some planning, to reduce our workload in the future and for avoiding the need to reinstall all the OSes on the whole network. Optimally we would never need to reinstall an image /only reboot a mashine and do meaningful changes on the kernel over ssh. Metaphoricallly speaking: we need to be able to transform a prototype airplane into a super jet, without ever landing.

I already went through a decent amount of research for aprox. 1 week and I think the solution is something like this:

https://cateee.net/lkddb/web-lkddb/USB_NET_CDCETHER.html

https://nxp.gitbook.io/d2x/software/d2x-application/enabling-usb-network

and a lot more… (these are the most relevant ones)

(We will modify and play around with the kernels in the future, I just finished my last course of my ITCP School, I just picked up Programming at University and I will very probably go deeper into Kernels in the near future)

For now I only need to change this one thing and I will surely work on kernels later on my path.

(and hopefully get someone on board that has relevant experience with the linux kernel)

The main goal is to activate “ETH over USB” for a simple trick, in order to get rid of obsolete periphery in the future. (here&now: get rid of the eth port) We are passing little data volume over ssh. (from one master to multiple servers)

What I already know/the keywords that I’m using for further research are:

I need to modify the “drivers/net/usb/Kconfig”

CONFIG_USB_NET_CDCETHER

cdc-ecm class for ethernet over usb

Enabling USB RNDIS Support

The problem split in 2 is:

  1. Can I modify a kernel without the need of reinstalling the whole OS

  2. How to activate USB Networking(eth over usb)

Thank you in advance,

Best Regards,

Annony

If you are using our official Debian / Ubuntu image that option should be enabled in kernel already. You can follow this guide to test it.

We also have a deb package to simplify those steps. You can find it here. We are collecting user feedbacks before we add it to our APT repo and Wiki.

3 Likes

Thankyou for the quick reply.

As I understand the configuration requires me to have direct access to the board.
Is this right?

Is there any possibility then to directly access the Radxa Zero using the host mashine,
without the need of wifi or separate keyboard and monitor. (we have all of that)

The boards are very handy for our project and we would like to have a plug and play solution to scale our system.

It is very important to minimize the effort of plugging and unplugging the boards, as we are using and configuring them from a distance. We are practically plugging them into our host and accessing the host over distance.

It would be very handy to use the boards as they are delivered.
Thankyou for your help.

Best Regards,

Annony

The easiest way is still to have serial console, WiFi or Ethernet cable connected to your Zeroes. I mention this again since you didn’t seem to be aware that you can control Zero with serial port, which is relatively low cost, and can even be used to access boot loader environment, which is not possible with USBNET or Ethernet. The point is if this is a production system it is always better to have redundant connections to the system to reduce downtime, since we all know the question of hardware failure is not whether but when.

With that being said, you can try to modify the image before you flash it to your Zero so you can have USBNET pre-configured. This is more of a general Linux question so you can find some articles online, but the major steps on top of my head should be:

# Install qemu-user-static to run aarch64 binary on x86_64 system,
# and kpartx from multipath-tools to mount distro image
sudo apt update && sudo apt install -y qemu-user-static multipath-tools
# Mount image
sudo kpartx -a debian.img && sudo mount /dev/mapper/loop0p1 /mnt
# Chroot into aarch64 system
sudo cp /usr/bin/qemu-aarch64-static /mnt/usr/bin/
LANG=C.UTF-8 sudo chroot /mnt /usr/bin/qemu-aarch64-static /bin/bash
###
# You can now set up the system as you wish, including install USBNET and set up IP address
###
# Exit chroot and umount the image
exit
sudo umount /mnt && sudo kpartx -d debian.img
# You can now flash this updated debian.img as usual

This script is untested but should give you a starting point.

1 Like

Thankyou. Perfect. Is there a possibility for donations?

I would like to send directly to your Paypal.
Directly said: Give me your Paypal, I send you Money.

@RadxaYuntian
I hope I’m not offending or overseeing aspects on a cultural plain.
I want to express gratitude. Thankyou for your intellectual support!

Always glad to be helpful. Good luck with your project!

I would really like to see this in the default image to simplify initial setups: write the image to the eMMC, unplug/replug the USB, wait a moment, and then be able to ssh over usb … unless something goes drastically wrong, you wouldn’t even need a serial console any more.

The issue is that our default image was set up with adbd enabled by default, which conflicts with usbnet. Having usbnet enabled by default will be a breaking change so we want to be careful about it.