How to enable USB OTG with Kernel 4.4

0 2969
Edited by packetflow at Jan 08, 2017 14:02

Hi together,

I recently bought an M2 version of the board and installed release 16.04 with kernel 4.4. The Pi is powered through a dedicated power supply.

root@bananapi ~ # uname -a                                                                                                                        
Linux bananapi 4.4.7-bananian #2 SMP Fri Apr 15 16:51:07 UTC 2016 armv7l GNU/Linux

In the release notes of  "14.11 updated" I found the following:
There is only one single change compared to 14.11:
- OTG is now disabled by default.

Searched around the web and found that we can enable it again with "bananian-hardware" tool, but that seems to be not working anymore with 16.04 release.

My goal is to use that port as an emulated storage device with usb gadgets for an other device to boot via mini USB port. The other 2 ports should act as normal host ports.
root@bananapi ~ #modprobe g_mass_storage file=/mnt/os_live_image.img stall=0  

This currently fails with the following messages:
modprobe: ERROR: could not insert 'g_mass_storage': No such device

Seems that no port is OTG enabled and that´s the reason why it fails. The kernel module is in place.
root@bananapi ~ # modinfo g_mass_storage
filename:       /lib/modules/4.4.7-bananian/kernel/drivers/usb/gadget/legacy/g_mass_storage.ko
license:        GPL
author:         Michal Nazarewicz
description:    Mass Storage Gadget
depends:        usb_f_mass_storage,libcomposite
intree:         Y
vermagic:       4.4.7-bananian SMP mod_unload ARMv7 p2v

I spend several hours to figure our the following:

- How do I check that OTG is enabled on the port?
- How to enable it again when it´s disabled.

On the journey I just found the manual. ... 3fDI2Mjd8MTU1Njk%3D

Beginning with page 58 it should be possible to extract the script.bin to a FEX file (bin2fex), edit the FEX to set OTG mode to on and use fex2bin to generate the new bin file. But there´s not script.bin in der mounted partition:

root@bananapi /mnt # mount /dev/mmcblk0p1 /mnt
root@bananapi /mnt # ls -lah /mnt            
total 5.5M
drwxr-xr-x  3 root root  16K Jan  1  1970 .
drwxr-xr-x 21 root root 4.0K Jan  8 01:26 ..
-rwxr-xr-x  1 root root 1.6K Aug 16  2015 boot.cmd
-rwxr-xr-x  1 root root 1.7K Aug 16  2015 boot.scr
drwxr-xr-x  2 root root 8.0K Apr 15  2016 dtb
-rwxr-xr-x  1 root root 5.5M Apr 15  2016 uImage-next

Ok, so far so good. From this perspective have to change the appropriate dtb file. First convert ist to dts. Here we go:

root@bananapi ~ # apt-get install device-tree-compiler
root@bananapi ~ # dtc -I dtb -O dts -o sun6i-a31s-sinovoip-bpi-m2.dts sun6i-a31s-sinovoip-bpi-m2.dtb
root@bananapi ~ # dtc -I dts -O dtb -o sun6i-a31s-sinovoip-bpi-m2.dtb sun6i-a31s-sinovoip-bpi-m2.dts

Boot messages indicate that "sun6i-a31s-sinovoip-bpi-m2.dtb" is used for the board.
Currently no clue what to change in the dts file to make the mini USB to act as OTG port. And also no clue what to check if its already an OTG port.

Thanks & Cheers

You have to log in before you can reply Login | Sign Up

Points Rules