USB OTG (CN3) as USB HOST in Linux

Discussion in 'Troubleshooting' started by stickman, Oct 14, 2014.

  1. stickman

    stickman New Member

    Joined:
    Oct 14, 2014
    Messages:
    3
    Likes Received:
    0
    I'm trying to connect an external device (in this case a USB pendrive) to the UDOO to take advantage of the USB OTG bus in Linux

    I've issued the commands that toggle the GPIO values so the port is connected to the imx6, but it doesn't work:
    Code:
    echo 0 > /sys/class/gpio/gpio203/value
    echo 0 > /sys/class/gpio/gpio128/value
    
    The pendrive is attached but it isn't recognized by the OS.

    Is there anything else that needs to be done?
     
  2. stickman

    stickman New Member

    Joined:
    Oct 14, 2014
    Messages:
    3
    Likes Received:
    0
    Bump!

    Is there anyone from the UDOO team that could confirm the OTG port works in host mode?
     
  3. delba

    delba Administrator Staff Member

    Joined:
    May 8, 2013
    Messages:
    1,064
    Likes Received:
    9
    There are no drivers ARM for the OTG port under Linux. The OTG works properly in host mode with Android!
     
  4. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    Here are patches to force the OTG port into Host mode despite its nonfunctional/unconnected ID pin. I'm using the daisy-chain mux at IOMUXC_GPR1 bit 13 to move the ID function to unbonded i.MX6 pad ENET_RX_ER (so as not to interfere with GPIO1, the other supported target), setting that pad's local mux to the proper mode, then applying an internal 100k pulldown rather than the usual pull-up so the OTG state-machine sees a grounded ID pin.

    Apply each from /usr/src/linux/arch/arm/mach-mx6/ with patch -p1 <patchfilename
    Code:
    --- x/board-mx6qd_seco_UDOO.h   2015-01-11 14:41:44.009511750 -0500
    +++ y/board-mx6qd_seco_UDOO.h   2015-01-11 14:19:26.000000000 -0500
    @@ -6,9 +6,15 @@
     *       CUSTOM MACRO DEFINITION
     *
     *    IOMUXPAD explanation
    -*       (mux address, pad address, mux, 0x0000, 0, pad values)
    +*     (padctrl address!, mux address!, mux value, 0x0000, 0, pad values)
     ******************************************************************/
     
    +// daisy-chain mux change also required in board-mx6_seco_UDOO.c
    +#define MX6Q_PAD_ENET_RX_ER__USB_OTG_ID__PULLDOWN \
    +               (IOMUX_PAD(0x04EC, 0x01D8, 0, 0x0000, 0, (PAD_CTL_PKE | PAD_CTL_PUE | \
    +                PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
    +                PAD_CTL_SRE_FAST | PAD_CTL_HYS)))
    +
     // SAM3X erase
     #define MX6Q_PAD_DISP0_DAT0__GPIO_4_21_PULLDOWN        \
                    (IOMUX_PAD(0x0484, 0x0170, 5, 0x0000, 0, 0x30B1))
    @@ -118,6 +125,8 @@
     
     static iomux_v3_cfg_t mx6qd_seco_UDOO_pads[] = {
     
    +       MX6Q_PAD_ENET_RX_ER__USB_OTG_ID__PULLDOWN,      // pull down to force OTG HOST mode
    +
            /* AUDMUX */
            MX6Q_PAD_DI0_PIN2__AUDMUX_AUD6_TXD,             // for AUDIO AUDMUX port 6
            MX6Q_PAD_DI0_PIN3__AUDMUX_AUD6_TXFS,            // for AUDIO AUDMUX port 6
    
    Code:
    --- x/board-mx6_seco_UDOO.c     2015-01-11 14:47:29.385725778 -0500
    +++ y/board-mx6_seco_UDOO.c     2015-01-11 13:49:51.000000000 -0500
    @@ -308,10 +322,11 @@
     static void __init imx6q_seco_UDOO_init_usb(void) {
     
            imx_otg_base = MX6_IO_ADDRESS(MX6Q_USB_OTG_BASE_ADDR);
    -       /* disable external charger detect,
    -        * or it will affect signal quality at dp .
    +       /* -jnh-
    +        * set GPR1 daisy-chain mux: USB_OTG_ID == ENET_RX_ER
    +        * this is has nothing to do with charger detection!
             */
    -       mxc_iomux_set_gpr_register(1, 13, 1, 1);
    +       mxc_iomux_set_gpr_register(1, 13, 1, 0);
     
            mx6_set_otghost_vbus_func(imx6q_seco_UDOO_usbotg_vbus);
     //     mx6_usb_dr_init();
    
     
  5. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    I forgot to mention that I also disabled kernel drivers for "USB OTG" and "USB Gadget support" (both under Device Drivers -> USB), in addition to making the above pinmuxing change. If you leave those in place, the kernel may see spurious interrupts when a device is first plugged in, causing IRQ #75 to be disabled and taking the port out of service. Since removing them, I haven't had any further trouble -- the CN3 connector, with a simple passive adapter in place is rock solid, working the same as all other USB Host ports, with the advantage of being on its own dedicated EHCI controller.

    Dropping these drivers isn't enough to lock the port into Host mode, though -- you stil have to do the pinmuxing change to force that ID signal low.

    It's curious that host mode would apparently "just work" on Android despite the missing ID signal. I wonder why that is? Maybe the supplied Android image already contains a similar hack?
     

Share This Page