OTG micro usb usage as a gadget BananaPiM3

(claudioItaly) #1

Continua la discussione da SSH connection over the USB OTG connection - how?:Hi, please,

I’d like to test OTG port of my Banana Pi M3 and I’ve seen a patch is required to the kernel in order to make it working.

If I well understand I’ve to modify a source code of the sunxi kenel, recomile it and upload it. Is it true?

Is there any faster way aviding to recompiling?

if I try modprobe g_ether I’m notified modprobe: FATAL: Module g_ether not found. I’ve it into: pi@bpi-iot-ros-ai:/lib/modules/4.4.50+/kernel/drivers/usb/gadget/legacy $ ls g_acm_ms.ko g_audio.ko g_ether.ko g_mass_storage.ko g_multi.ko g_serial.ko g_zero.ko gadgetfs.ko g_cdc.ko g_hid.ko g_midi.ko g_printer.ko g_webcam.ko

Could you please help me ? thanks

(markov85) #2

Hi man,

Did you find a solution to this already ? Please post some info if you’ve done that.

BR, markov85

(Adam B) #3

@markov85: Hi. Maybe I could help with this, but I’ve got a question. What kernel version do you have? Is it 4.4.50 as @claudioItaly said? If it is this kernel version could you tell me where did you find it? Any link? I’m using 3.10.xx linux kernel but I’m looking for any newer one. If I have any new one I could try to recompile it and test it - but on Banana PI M2 Ultra (because I have this board, not M3).

(markov85) #4

Hi Adam,

I don’t know how to build a kernel or let alone an entire image. So I am just using one of the ready images - provided by Sinovoip - The Ubuntu Mate, kernel 3.10.107, from 24-Aug-2017 : 2017-08-24-ubuntu-16.04-mate-desktop-beta-bpi-m2u-sd-emmc.img from here: (https://drive.google.com/file/d/0B_YnvHgh2rwjM1A5UjVpWUdDdk0/view)

I am really going to appreciate it if you or someone else could help!

Thanks, Georgi

(Adam B) #5

Hi Georgi,

I’ve got very good news for you. It is working for me. Today after hard work with the Linux kernel sources I did it. Just a few minutes ago I uploaded the kernel and modules for banana pi m2 ultra to get ethernet connection via usb. Direct link for the archive with kernel and module is here: http://goo.gl/xEf9jL

How to run it?

1. Copy my kernel and the modules to your SD card
2. Run the Linux system from SD card
3. echo -n 0 > /sys/devices/soc/usbc0/otg_role
4. modprobe g_ether
5. echo -n 2 > /sys/devices/soc/usbc0/otg_role
6. connect PC and BPI M2ULTRA with usb cable
7. configure IP addresses on both sides (usb0 interface)


(markov85) #6

Hi man,

Thank you so much, finally I get an usb that gets recognized as an ethernet device. I just wanted to ask you about two things:

  • Could you share the steps to produce the kernel file and modules so that other people too can fix this issue for themselves in the future ?
  • Also could you make some step by step tutorial , continuing after the steps you posted before about how to configure both the banana and you own PC , so that you can perfor SSH login from your own PC to the banana pi.

Again, many thanks for following on this request!

BR, markov85

(Adam B) #7

Hi Georgi,

The next steps are:

7. Configure IP address on PC side:
# ifconfig usb0 netmask up
8. Configure IP address on BPI side:
# ifconfig usb0 netmask up
9. Run sshd daemon on BPI side:
# /sbin/sshd

At this point all the ethernet transmission should be working via usb cable: ping, telnet, ssh, etc.

Regarding the sources of the kernel - they can be obtained by cloning git repo: https://github.com/BPI-SINOVOIP/BPI-M2U-bsp.git

and there is .pdf file inside with the description how to compile everything.

(markov85) #8

Hi again Adam,

IT FINALLY WORKS, I was able to ssh to my bananapi.

Btw, some corrections on my side for step 7, “usb0” had been renamed/changed to “enp0s20f0u3i1” in my case see below:

~$ dmesg | grep usb0 [12525.034178] cdc_subset 1-3:1.1 usb0: register 'cdc_subset' at usb-0000:00:14.0-3, Linux Device, ee:65:85:22:31:d4 [12525.037058] cdc_subset 1-3:1.1 enp0s20f0u3i1: renamed from usb0

for step 9. it should be :

# usr/sbin/sshd

and just for completion, step 10 could be, login to the BPI from the PC side by:

$ ssh -x -l pi

Gratitudes, markov85

(markov85) #9

Btw Adam,

Do you continue to have audio , after applying (copying over) the kernel file and /lib/ folder? I used to have the HDMI audio working with the monitor, but now it seems to be gone.



(Adam B) #10

Hi. If I find some time I’ll try to add audio and video support. But generally I treat BPI as a development board rather than multimedia center…