Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Banana Pi M2: USB Peripheral Driver UDC

Featured Replies

This isn't specific to armbian, I guess.

 

I am not sure if the mainline linux kernel supports USB peripheral/OTG on Banana Pi M2.

 

Armbian doesn't list anything in 

/sys/class/udc

, so I assume it isn't. 

 

In the v3.3 kernel released by Sinovoip, there is a dedicated option in the menuconfig for sunxi_usb. I am not sure where to look in the mainline kernel.

 

Anybody has a better idea about this? 

 

Thank you.

OTG was just introduced to 4.4 RC5 ... I just read about and was doing some tests but in host mode and on A20. No idea if this is operational within A31s / M2 too and how is with OTG mode.

 

If you want to try it, check my last kernel build:

 

http://mirror.igorpecovnik.com/test/Armbian_5.00_Bananapi_Debian_jessie_4.4.0-rc5.zip [tested]

http://mirror.igorpecovnik.com/test/h3/ [not tested yet]

 

OTG mode is default, for host you need to alter DTB.

Upps, I was too quick on posting this. :( That image is with a boot loader for normal Banana with A20 but the kernel which is inside is the correct one.

 

Use the image from download section (that one works!) and install a kernel and DTB pack from test/h3 directory. This is not from mainline but from other sources so I am not sure OTG is already in but worth trying.

 

I'll compile from mainline later when got back in office and put to /test dir.

 

In any case use image from download section and change kernel(s).

 

EDIT:

Use this kernel upgrade. You can install all debs since there is a u-boot for M2 too.

http://mirror.igorpecovnik.com/test/m2-debs.zip

  • Author

Thanks for the M2 debs!
 
It is failing to boot though, and gets stuck when "starting kernel" (screenshot)

 

There was one error when installing the new DTB

dpkg: error processing archive linux-dtb-dev-sunxi_5.00_armhf.deb (--install):
 trying to overwrite '/boot/dtb/sun8i-a33-et-q8-v1.6.dtb', which is also in package linux-dtb-next-sunxi 4.5

I'll try the H3 debs now

  • Author

Exact same story  :P

 

But there's some hope (just to keep myself happy) - I randomly came across phy-sun4i-usb.ko (assuming it is also applicable for sun6i) in the modules list 

  • Author

Wow! That was quick!! 

 

Surprisingly, both sun6i-a31s-bananapi-m2.dts and sun6i-a31s-sinovoip-bpi-m2.dts are in the tree!

 

Just curious - where do I look for the U-boot logs?

  • Author

Thanks for your time, Igor!  :)

 

My serial console shows almost the same output I get on HDMI, I guess the verbosity needs to be bumped up somehow.

  • Author

Yup, dmesg says ttyS0 is the serial port.

 

I did some digging around to learn a little more about U-boot and DTBs

 

Here's the commit that adds sun6i-a31s-sinovoip-bpi-m2 to the Makefile, but I can't figure out why sun6i-a31s-bananapi-m2.dts is still in the tree and when/why it was removed from the Makefile.

 

While the BPI-Mainline-uboot Makefile contains only sun6i-a31s-bananapi-m2.dts

 

I tried rebuilding the debs after changing the defconfig in U-boot. But the kernel doesn't boot anyway.

 

How do I see the detailed logs? I did change the loglevel in boot.cmd to 8, but the verbosity remains the same.

Edited by deadmetaphor

  • Author

I was able to boot with a 4.4-rc6 kernel, but USB peripheral drivers don't seem to be present (at least /sys/class/udc is empty)

 

Guess, only Android images have this working :rolleyes:  

 

--

  • Author

Yup, the BPI-M2 Android kernel is too "limiting" too. Because my final aim is to experiment with configfs gadgets (which seems more full-featured in the mainline kernel), but for some reason, Android refuses to boot if I do not enable android_usb.

 

I didn't try to load any modules manually. I'll try that now.

  • Author

Thanks!

 

I had CONFIG_USB_MUSB_DUAL_ROLE=y instead of CONFIG_USB_MUSB_HOST=y

 

Also, I had to enable usb_otg in the dtb for BPI M2

 

And, now musb is printing something to dmesg, although it's an error:

 

[   74.232805] musb-sunxi 1c19000.usb: Invalid or missing 'dr_mode' property
[   74.239659] musb-sunxi: probe of 1c19000.usb failed with error -22
  • Author

I am using the 4.4-rc6 kernel.

 

You were exactly right about device tree config! 

 

Setting dr_mode to "otg" (and CONFIG_USB_MUSB_DUAL_ROLE=y) gets rid of the "Invalid or missing 'dr_mode' property" error, but then there nothing in dmesg about musb (and right now I don't have an OTG cable to test if the host mode is working)

 

Setting dr_mode to "host" (CONFIG_USB_MUSB_HOST=y) gave the following

# dmesg | grep musb
[  107.463859] musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn)
[  107.463903] musb-hdrc: MHDRC RTL version 0.0 
[  107.463937] musb-hdrc: 11/11 max ep, 5184/8192 memory
[  107.464250] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[  107.464299] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[  107.465117] usb usb3: Manufacturer: Linux 4.4.0-rc6-sunxi musb-hcd
[  107.465135] usb usb3: SerialNumber: musb-hdrc.1.auto

So, I assume it is working (again, unable to test it at the moment).

 

Setting dr_mode to "otg" (and CONFIG_USB_MUSB_GADGET=y) always gives an error

musb-sunxi 1c19000.usb: Invalid or missing 'dr_mode' property
musb-sunxi: probe of 1c19000.usb failed with error -22

From drivers\usb\musb\sunxi.c

	switch (usb_get_dr_mode(&pdev->dev)) {
#if defined CONFIG_USB_MUSB_DUAL_ROLE || defined CONFIG_USB_MUSB_HOST
	case USB_DR_MODE_HOST:
		pdata.mode = MUSB_PORT_MODE_HOST;
		break;
#endif
#ifdef CONFIG_USB_MUSB_DUAL_ROLE
	case USB_DR_MODE_OTG:
		glue->extcon = extcon_get_edev_by_phandle(&pdev->dev, 0);
		if (IS_ERR(glue->extcon)) {
			if (PTR_ERR(glue->extcon) == -EPROBE_DEFER)
				return -EPROBE_DEFER;
			dev_err(&pdev->dev, "Invalid or missing extcon\n");
			return PTR_ERR(glue->extcon);
		}
		pdata.mode = MUSB_PORT_MODE_DUAL_ROLE;
		break;
#endif
	default:
		dev_err(&pdev->dev, "Invalid or missing 'dr_mode' property\n");
		return -EINVAL;
	}

TL;DR:

  • OTG mode will work only if CONFIG_USB_MUSB_DUAL_ROLE is set
  • Host mode will work if either of CONFIG_USB_MUSB_DUAL_ROLE and CONFIG_USB_MUSB_HOST are set
  • Author

Aha! No wonder CONFIG_USB_MUSB_GADGET=y always had that error...it's decided at compile time. Thanks!

 

I did find a lot of "gadget" related handling in musb, now I have to figure out if MUSB_PORT_MODE_DUAL_ROLE supports gadget mode. And, if I have the right .config to make it work (assuming it's expected to work on A31 based boards).

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.