deadmetaphor Posted December 24, 2015 Posted December 24, 2015 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.
Igor Posted December 24, 2015 Posted December 24, 2015 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.
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 Thanks Igor! I am downloading the first image and will test with it.
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 Wanted to confirm if that was a Banana Pi M2 image, because it didn't even boot
Igor Posted December 24, 2015 Posted December 24, 2015 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 1
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 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
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 Exact same story 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
Igor Posted December 24, 2015 Posted December 24, 2015 OK, I'll try it. EDIT: I found two problems U-boot seeks for: sun6i-a31s-bananapi-m2.dtb but we have sun6i-a31s-sinovoip-bpi-m2.dtb Filesystem was corrupted for no reason. Have to check build process.
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 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?
Igor Posted December 24, 2015 Posted December 24, 2015 I made just a quick look, perhaps the problem is only broken file system within image. On a serial console where I also monitored a kernel output ... I am more or less out for today, so fixing probably comes tomorrow.
deadmetaphor Posted December 24, 2015 Author Posted December 24, 2015 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.
zador.blood.stained Posted December 24, 2015 Posted December 24, 2015 @deadmetaphot To get kernel messages on serial console you need to add "console=ttyS0,115200" to bootargs in boot.cmd and recompile it to boot.scr I'm assuming that ttyS0 is the right device for Banana Pi M2
deadmetaphor Posted December 25, 2015 Author Posted December 25, 2015 (edited) 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 December 25, 2015 by deadmetaphor
deadmetaphor Posted December 28, 2015 Author Posted December 28, 2015 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 --
Igor Posted December 28, 2015 Posted December 28, 2015 Thanks for update. Have you load an module ? "sunxi" Android kernel is buggy and has other limitations
deadmetaphor Posted December 28, 2015 Author Posted December 28, 2015 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.
Igor Posted December 28, 2015 Posted December 28, 2015 Check my experiments with musb driver (module sunxi) but on A20. This is host mode, Banana PI. http://pastebin.com/abyijkm7
deadmetaphor Posted December 28, 2015 Author Posted December 28, 2015 Thanks for that pastebin, I had no clue that musb was applicable for sun*i devices too. musb is all but quiet on this machine http://pastebin.com/ZwDPzA0y Which def_config are you using?
Igor Posted December 28, 2015 Posted December 28, 2015 https://github.com/igorpecovnik/lib/blob/master/config/linux-sunxi-dev.config
deadmetaphor Posted December 28, 2015 Author Posted December 28, 2015 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
Igor Posted December 28, 2015 Posted December 28, 2015 You need kernel 4.4+ and you might be missing this in device tree: &usb_otg { dr_mode = "otg"; status = "okay"; }; Change dr_mode to host ... if OTG is not operational and you will have a normal USB port but you need a powered usb hub.
deadmetaphor Posted December 28, 2015 Author Posted December 28, 2015 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
zador.blood.stained Posted December 28, 2015 Posted December 28, 2015 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
deadmetaphor Posted December 29, 2015 Author Posted December 29, 2015 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).
Recommended Posts