How to get USB OTG port to work in Device mode?

I am trying to get USB OTG to work on the Khadas VIM so I can SSH into the box from my MacBook via the USB-A-to-USB-C cable. I am familiar with doing so on the Raspberry Pi Zero using these instructions:

However, after setting up boot for Khadas VIM I do not find a config.txt nor a cmdline.txt file. Is there an alternative way to do for Khadas VIM?

If this is not appropriate for the Khadas VIM forums maybe point me to more appropriate forums, please?

1 Like

I’m not sure I understand. What OS is on the Vim?

Hi, Mike:
It’s quite different OS between Khadas VIM and RPi.

If you wanna SSH feature, just make sure:

  • You have installed SSH package on your OS
  • Ensure your VIM is network connected
  • run ssh user@ip-of-your-vim to login into VIM from remote

Anyway, it’s same approach with Linux Ditro to setup SSH for VIM.

Good luck!

If you connect an additional key, you can remotely run programs with a graphical interface

ssh -X user@ip_vim

You can not only run console programs, but with a graphical interface (firefox, etc).

ssh -X root@ip_vim

(synaptic gparted etc)

Sorry for not being clear. I have Ubuntu 16.04 on an SD Card using this process. Ubuntu, based on Debian is similar to Raspbian so I was looking for same configuration files but did not find them.

I can do that already and have been configuring the software on the device using SSH in that manner. For those who want to know how to do this on Ubuntu, here are the instructions that I found and followed and they work perfectly.

Unfortunately, one of the features of our desired product offering that we hope to base on Khadas VIM is for our users to be able to turn off WiFi and access SSH using only a wired USB OTG connection. This will allow the device to work with no local network connection or prior configuration, and make it so that no one can hack into it over WiFi.

We already have a Raspberry Pi Zero configured to work in exactly this way, but for many reasons the RPiZero is not a viable solution for us.

When we see that Khadas VIM has an OTG port as part of its specification why should we not be able to configure it to have TCP over USB OTG?

Hi, Mike:

  • SSH over USB OTG on VIM, we still need more research on it, as we are in Chinese Sprint Festival util 5 Feb, so we need reply you after then.
  • As the debian OS, both Ubuntu on VIM is quite common setup with RPi, but, the different part of bootloader/u-boot, VIM with different approach to load OS
    • RPi: use external boot.ini for ENV configuration
    • VIM with Ubuntu: user internal ENV configuration
    • VIM with LibreELEC, use external boot.ini ENV

Thank you! Looking forward to this.

Hope you had a very good Chinese Sprint Festival!

is there anything new here since 2 months ago ?
I power my VIM pro board using 2 pins from its 40 pin header,
It boots ok,
and I can open a shell session to the board from a linux PC using minicom and an an usb-ttl 3.3V cable.
Then I connect the usb-c cable provided with the board and try to create a point to point network thru it and between the VIM and my linux PC.

I also am familiar with doing the same on my RPI0 board running raspbian jessie and also on my Beaglebone black running ubuntu.

The problem with VIM is that I cannot find how make the usb-c socket as slave and behave as a virtual ethernet port.

Please check if it is even possible, my OS is ubuntu server (see below) , running from emmc
uname -a …
Linux Khadas 3.14.29 #126 SMP PREEMPT Sat Feb 11 00:33:23 CST 2017 aarch64 aarcx


Hi, Ravelo:
One of our guy did try to port the OTG-SSH from Pi Zero to Khadas VIM, but I finally hang it on as he was stuck at some problems then:

  • As the kernel version is quite different, VIM is still 3.1x, but Pi Zero is 4.x
  • the OTG driver architecture also comes with some different

Anyway, I think we will continue the effort and also hope some forks who know this well can help to figure it out.


tks for answer gouwa,
let’s hope then that compatibility with mainline linux kernel for vim will be ok very soon and we’ll benefit from latest kernel which come with more support for usb otb on s905x based boards like odroid c2

trying to get ethernet via usb (g_ether) work, as part of the usb gadgets.

modprobe g_ether
not found in /lib/modules/3.14.29

it’s available in the official armbian kernels, but i cannot find it in balbes150 builds, which are quite useful in many ways.

setting up a “sandwich stack”: simply connect one khadas vim to another and have a mini cluster, powered by one 2,5A source. usb net would be the obvious choice here using the usb-a to usb-c OTG cable.

one wifi adapter is used for AP. the other could be used as a wifi bridge, but ethernet is more reliable.
the speed of usbnet between both boxes should be comparable to fast ethernet.

use cases would be to use one box as a tv box, and the other as a tvheadend server, or a headless kodi, containing the mysql server, which scrapes sources to put them into a cache for faster retrieval, others might like to experiment with a small docker swarm. since clustering is already planned with the khadas case, ethernet over usb (OTG) should be available.

maybe someone who has been there before, can walk me through the various build environments to configure the kernel accordingly :wink:

Did anyone manage to get this working? I want to use ethernet networking to connect a number of VIMs together to save on cabling in a project so need to get this working

thanks :slight_smile:

1 Like

looks like i need to enable USB gadget mode in the kernel and enable the USB ethernet gadget, but cant get a .config file that works and menuconfig setup that follows exmaples off the web just results in a restart of the config process when building debs, e.g.

will keep trying - as when i get a working kernel build then i dont get usb0 as a network device - so something wrong

Nope. I gave up on it because I realized there were too many hurdles to get a Khadas working my use-case. That said, we have yet to find something that will.

Have got USB0 as a device - now to get it working with the host…

Needed CONFIG_USB_ETH set in the kernel config along with gadget support


Can explain how to do this on vim 3
I want to do ssh over usb is it possible this way ?

@g4b42 has worked this out for me - you will need to modify a few files and rebuild the kernel - but its straight forward to do using fenix. How I did it yesterday:

  1. download fenix and pick the options that you want, then let it run until it has downloaded linux, the ctrl-c to halt the build (when it starts building linux is when i stopped it)

  2. in the linux directory apply the following changes

  3. start the fenix build again and press enter when asked if you want to proceed with the modified files

  4. burn the resulting image to your VIM3

  5. create a script called in /root/ with the following contents and make it executable. Note that each MAC address has to be unique - so if creating multiple devices to put on the same hub then you need to change these per device.
    [ ! -d “/config” ] && mkdir /config
    mount -t configfs none /config
    mkdir /config/usb_gadget/g1
    echo 0x18d1 > /config/usb_gadget/g1/idVendor
    echo 0x4ee1 > /config/usb_gadget/g1/idProduct
    mkdir /config/usb_gadget/g1/strings/0x409
    echo 12345678 > /config/usb_gadget/g1/strings/0x409/serialnumber
    echo Dummy > /config/usb_gadget/g1/strings/0x409/manufacturer
    echo Demo > /config/usb_gadget/g1/strings/0x409/product
    mkdir /config/usb_gadget/g1/configs/c.1
    mkdir /config/usb_gadget/g1/configs/c.1/strings/0x409
    echo “Conf 1” > /config/usb_gadget/g1/configs/c.1/strings/0x409/configuration
    echo 120 > /config/usb_gadget/g1/configs/c.1/MaxPower
    mkdir /config/usb_gadget/g1/functions/eem.f0
    echo “66:77:88:99:aa:00” > /config/usb_gadget/g1/functions/eem.f0/host_addr
    echo “00:11:22:33:44:00” > /config/usb_gadget/g1/functions/eem.f0/dev_addr
    ln -s /config/usb_gadget/g1/functions/eem.f0 /config/usb_gadget/g1/configs/c.1/$
    echo ff400000.dwc2_a > /config/usb_gadget/g1/UDC

  6. edit /etc/network/interfaces and add the following for usb0 - assumes an available DHCP server for where the device is being plugged into, can also set for a static IP address if required
    auto usb0
    iface usb0 inet dhcp
    pre-up /root/

  7. reboot and use your device with USB ethernet - a useful check to make sure its working is to use ip a or ifconfig to make sure that a) usb0 shows up as a device and b) it has an IP address assigned to it

  8. ask Khadas nicely to put this config changes into the standard kernel build to save some steps :slight_smile:


cool does it work can I ssh into my VIM3 with this ?

yes - am using it to SSH into all the devices on my USB hub back plane in my miner thread