Page 1 of 1

Initializing g_cdc at boot time?

Posted: Fri Mar 29, 2019 7:00 pm
by DanClemmensen
The following commands allow me to use IP-over-USB instead of a serial connection:
su
modprobe -r g_mass_storage
modprobe g_cdc
ifconfig usb0 netmask 255.255.255.0 192.168.13.2

However, I'm not sure how to cause this to happen a boot time. I use Raspbian and Gentoo, but I've never used sun8xi before and I'm unsure of the init system. I don't understand where the init scheme is deciding to load g_mass_storage, so I don't know how to tell it to load g_cdc instead. I can probably figure out the static IP init myself.

Re: Initializing g_cdc at boot time?

Posted: Thu Apr 04, 2019 8:55 am
by igorp
DanClemmensen wrote:
The following commands allow me to use IP-over-USB instead of a serial connection:
su
modprobe -r g_mass_storage
modprobe g_cdc
ifconfig usb0 netmask 255.255.255.0 192.168.13.2

However, I'm not sure how to cause this to happen a boot time. I use Raspbian and Gentoo, but I've never used sun8xi before and I'm unsure of the init system. I don't understand where the init scheme is deciding to load g_mass_storage, so I don't know
how to tell it to load g_cdc instead. I can probably figure out the static IP init myself.


Most of available systems are Debian (systemd) compatible:

Recompile kernel with build-in support or:
- blacklist g_mass_storage (check /etc/modprobe.d/blacklist.conf)
- add g_cdc to /etc/modules

Re: Initializing g_cdc at boot time?

Posted: Thu Apr 04, 2019 3:11 pm
by DanClemmensen
Thanks, Igor.
I had figured out a variant of this. Since g_mass_storage is loaded during init, not during boot, I was able to keep it from loading by removing its entry from the modprobe.d directory. I added g_cdc to /etc/modules as you suggested.

To initialize the usb0 link, I added a static IP config to the file /etc/network/interfaces

I then configured my main Linux machine for IP forwarding and masquerade and plugged the NanoPi Duo into a USB port on the main machine. The the usb0 interface came up: I can ssh to it, and it can access the Internet.

I installed xorg and (after some fiddly configuration) used ssh -Y to connect, and I can run X GUI apps on the NanoPi with the windows showing up on my screen.

My goal is to be able to start with an unused NanoPi Duo and a pristine MicroSD image, then mount the image on my main Linux machine, run a script to modify the image and write it to a MicroSD card, and boot the NanoPi without needing anything except a single USB cable.