This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

on-the-fly change of kernel between USB host to USB device

Other Parts Discussed in Thread: OMAPL138

Hello,

I am using DM8148 USB.

As I understand OTG is not supported with it.

Therefore when we use USB device mode, we use the kernel which was build with the menuconfig in usb device mode, and when we use the device in host mode we use the kernel build for host usb.

I would like to ask if there is a way that we can do this on-the-fly, i.e. when we need the device, we somehow work with kernel device mode, and when we need host, we work with kernel host mode.

Thanks for any suggestions.

Ran

  • Hi Ran,

    Could you specify which software release you are using (is it an official TI's release) and which kernel version?

    BR
    Tsvetolin Shulev
  • Hi,

    I am using DVRRDK_04.01.00.02 , with DM8148.
    This is official release.

    Best Regards,
    Ran
  • kernel version:
    Linux dm814x 2.6.37 #32 Wed Jun 3 16:54:29 IDT 2015 armv7l GNU/Linux
  • Hi Ran,

    Option - On-the fly change of kernel.

    I do not think that option will work out... you mean in the u-boot level, you will decide upon whether host or device mode and accordingly you will load the kernel???

    Instead, check whether you can build the host / device driver as a module instead of inbuilt with kernel.
    I mean, inserting the required module when needed. ( Can give it a try!!.. Not too sure about this option... I haven't tried)
  • Hi,
    I don't think it is possible since "device mode" is required "USB ID" pin should be floating and that pin should be grounded for "host mode" (forced) operation.

    Edited:

    You have to reboot your board after "USB-ID" pin get updated.

  • Hi Ran,

    Could you revise the schematics of your board and check whether the USB ID pin is connected. If it is floating it is not possible but if it is connected you should search for software decision about.

    BR
    Tsvetolin Shulev
  • Hi,

    We use DM8148 with the pin float/grounded according to device type connected (host-grounded, device-floating).

    As to the on-the-fily change, Is the boot required becuase the kernel must have this information (device or host) on boot, and can't change it on the fly ?

    What about the idea above to load kernel module on-the-fly , can this solution work ?

    Regards,

    Ran

  • Hi Ran,

    What about the idea above to load kernel module on-the-fly , can this solution work ?

    I think, it may work since you are loading the complete USB driver as module.
    Need to update the USB ID pin before USB enumeration happens in USB driver.

    Could you please try this and update us.
  • Hi Ran,
    Have you tried this ?
  • Hi Titus,

    Thank you for the suggestions, sorry for not replying before.

    No, I haven't yet tried that.

    I know that the device/host configuration in menuconfig is composed of several changes not only one, so I'm not sure as to which feature should be indication as 'M' (module). I need to get back to it and see. But since this feaure  is quite important for our operational software, I will probably need to do this testing soon. I will update here of course as soon as it is done.

    Thank you,

    Ran

  • Hi Ran,

    Thanks.
    Please let us know how it goes.
    If time persists, I will also try it on my OMAPL138 LCDK board and let you know.
  • Thank you very much , Titus.
    This is very helpful.

    Best Regards,
    Ran
  • Hi, I'm also interested in the ability to switch between device and host mode on the fly. Did any of you had any luck?
  • Hi
    I havn't tried it yet, but it is on our Must-TO-DO-List, according to the suggestion made by Titus above.
    If anyone already did it, please share resuls.

    Thanks,
    Ran
  • Hi Titus,

    I began investing if it is possible to change on-the-fly between usb device to host.
    But It seems that there is no device mode capability in the menuconfig, becuase it is always selected, (I can change to host option to module but not the device option )

    Prompt: Driver Mode │
    │ Defined at drivers/usb/musb/Kconfig:196 │
    │ Depends on: USB_SUPPORT [=y] && USB_MUSB_HDRC [=y] │
    │ Location: │
    │ -> Device Drivers │
    │ -> USB support (USB_SUPPORT [=y]) │
    │ Selected by: USB_SUPPORT [=y] && USB_MUSB_HDRC [=y] && m

    Regards,
    Ran
  • Hi Titus,

    Do you think there is anything that can be done here (please check my above post) ?

    Thank you,
    Ran
  • Hi Ran,
    Don't have time to dig further.
    Need to recollect everything when I worked with USB stuff.
    Provide the kernel configurations used when you configured for host and device mode.
  • Hi Titus,

    I have attached kernel configuration file.

    I see in http://processors.wiki.ti.com/index.php/Usbgeneralpage

    and with menuconfig, that there is "driver mode" which is selected automatically as gadget stack or host stack according to the decisions in menuconfig (host or device), which means that even if I select host as module and device as module, there atr this options:

    CONFIG_USB_MUSB_OTG
    CONFIG_USB_MUSB_PERIPHERAL
    CONFIG_USB_MUSB_HOST

    That are selected automatically and are used in initialization time:

    /* initialize usb */
    usb_musb_init(&musb_board_data);

    Thank you very much for the time,

    Ran

    3806.myfile.txt

  • Hi Titus,


    Each mode works on same HW:
    1. boot with usb device
    2. boot with usb host
    As we understand it means that the HW knows how to work with usb device and usb host.
    It seems as if the only gap is that the software will configure the hw correctly when changing between usb host and usb device.

    In case we configure linux kernel to OTG with DM8148 (although it is not supported ....):

    Can we change the registers to tell the kernel to be in host or device on-the-fly ?

    We are struggling to enable the dynamic change between these modes, becuase it is  a MUST.

    Hardware Limitation (Not supported feature) DM814X

    • OTG Support : This limitation is due to the external USB-ID pin from the USB connector is not used for detection of host/device mode. The USB-ID pin (or iddig pin) is made software configurable to configure the controller as host mode (iddig = 0) or device mode (iddig = 1). Hence dynamic iddig pin sensing based on external USB cable connector is not possible.

    >"This limitation is due to the external USB-ID pin from the USB connector is not used for detection of host/device mode."

    If we could configure the driver without this PIN, but by software, if it is device or host, wouldn't is overcome the above limitation ?

    Regards,

    Ran

  • Hi,

    The problem is that the musb driver has a lot of config flags (for perpheral, device, otg and other variants)
    In order to truelly support load/unload we must now convert all this config into variables so that load/unload can be done.....

    Regards,
    Ran

  • Hi,

    We eventually did some patch in usb in order to support dynamic usb-device switch (and vice versa).

    to change to host:
    ====================
    modprobe -r g_ether 
    modprobe -r usb-storage 
    modprobe -r ti81xx
    modprobe ti81xx - validate printing musb-hdrc musb-hdrc.1: USB Host mode"
    modprobe usb-storage - insert disk - does it recognize the disk in /dev/sdX ?


    to change to device: 
    =====================
    modprobe -r g_ether 
    modprobe -r usb-storage 
    modprobe -r ti81xx
    modprobe ti81xx - validate printing "musb-hdrc musb-hdrc.1: USB Peripheral mode"
    modprobe g_ether - check with ifconfig that usb0 is configured

    5635.src.zip

    Regards,

    Ran