[SOLVED] iMX6 <-> SAM3x USB communication

Discussion in 'UDOO QUAD' started by Robert Voinea, Jun 14, 2016.

  1. Robert Voinea

    Robert Voinea New Member

    Joined:
    Jun 14, 2016
    Messages:
    3
    Likes Received:
    2
    Hi

    My goal is to make tinyG2 work on the UDOO/SAM3x. I am using udoobuntu v2.0.
    Just for the record: TinyG2 is a 6 axis motion control system designed for high-performance on small to mid-sized machines. It works exclusively via the Native USB port of the SAM3x.

    From what I have read so far, this is not possible out of the box (see this thread).
    It seems that someone has succeeded in doing this, but for the 3.0 kernel.

    Has anyone succeeded in making the two (sam3x and imx6) communicate via USB, with the 3.14 kernel and DTBs?

    Any help is greatly appreciated!

    [1] http://www.udoo.org/forum/threads/usb-otg-cn3-as-usb-host-in-linux.1897/
    [2] https://github.com/synthetos/g2/tree/master
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I am not an expert on this but what do you think is the problem? Standard the native usb port of the sam3x is connected to the usb otg of the imx6 so you should be able to communicate with tinyg2 through this port.
    The fix you are referring to is to have the external mini usb port act as an host instead of otg when connecting an external usb device to it. But you don't have to.
    See also http://www.udoo.org/docs/Hardware_&_Accessories/IMX6_And_Sam3X_Communication.html

    Do you have an Udoo or are you just investigating the possibilities?


    Verstuurd vanaf mijn GT-P5210 met Tapatalk
     
  3. Robert Voinea

    Robert Voinea New Member

    Joined:
    Jun 14, 2016
    Messages:
    3
    Likes Received:
    2
    Hi

    I have a board with a 7" LCD. I actually bought it in order to use it as a stand-alone PC+controller for my CNC.

    From what I have found so far, it seems that the OTG port of the iMX6 is configured as a device, NOT as a host (eg: linux gadget).
    There is no difference between the OTG port being used by an external device or by the "internal" Sam3x.
    TinyG2 configures Sam3x as device, so, at the other end, it must have a host.

    This is the actual problem. The OTG port on the iMX6 is not configured as a Host, but as Device.
    The patch the post I have linked to does this exact thing (actually it is a work-around), but for an older kernel (3.0).

    For Android, this works. I mean that the Sam3x is seen as Android Accessory by the iMX6.
    So, why not on Linux? There is no mention in the documentation about this being possible on Linux.
    Also, there is a post on this forum (this one), that states that this configuration is NOT supported (although the poster does not say that it is not possible). I don't know why.

    I have found a post on the nxp (ex-freescale) forums (this one), and one user states that he enabled Host mode for the OTG port by simply disabling the "gadget" modules and enabling another module (for an iMX53 though).

    Daniel Sliwka Feb 18, 2014 9:34 AM
    Solved by kernel configuration:
    CONFIG_MXC_OTG, CONFIG_USB_OTG, CONFIG_USB_GADGET removed
    CONFIG_USB_EHCI_ARC_OTG =y​

    I will try this and see where it goes.

    The other option is some hardware modding (Just connect the Sam3x to the USB Hub)... which I would like to avoid.
     
  4. Robert Voinea

    Robert Voinea New Member

    Joined:
    Jun 14, 2016
    Messages:
    3
    Likes Received:
    2
    Hi again
    I Must say that I never thought it was so simple.
    All I had to do was to recompile the udoo kernel (3.14, udoo_quad_dual_defconfig) with the USB Gadgets removed (USB_GADGET=n) and enable OTG support (USB_OTG=y).
    Install the new kernel and then, set two GPIOs:
    # GPIO 128 = USB_OTG_SEL
    echo 128 > /sys/class/gpio/export
    echo out > /sys/class/gpio/gpio128/direction
    echo 1 > /sys/class/gpio/gpio128/value
    # GPIO 203 = VBUS_EN
    echo 203 > /sys/class/gpio/export
    echo out > /sys/class/gpio/gpio203/direction
    echo 1 > /sys/class/gpio/gpio203/value

    It seems that this is enough to make it work!
    That is all.

    ...and to prove it:
    root@udoo:/etc/init# lsusb
    Bus 002 Device 003: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
    Bus 002 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 002: ID 1d50:606d OpenMoko, Inc.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    root@udoo:/etc/init# dmesg
    [ 54.601078] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
    [ 73.143503] usb 1-1: new high-speed USB device number 2 using ci_hdrc
    [ 73.294176] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x2 has invalid maxpacket 256
    [ 73.294208] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x83 has invalid maxpacket 256
    [ 73.294237] usb 1-1: config 1 interface 3 altsetting 0 bulk endpoint 0x5 has invalid maxpacket 256
    [ 73.294261] usb 1-1: config 1 interface 3 altsetting 0 bulk endpoint 0x86 has invalid maxpacket 256

    [ 73.295289] usb 1-1: New USB device found, idVendor=1d50, idProduct=606d
    [ 73.295315] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 73.295335] usb 1-1: Product: TinyG v2
    [ 73.295352] usb 1-1: Manufacturer: Synthetos
    [ 73.295369] usb 1-1: SerialNumber: 021323356343
    [ 73.320580] cdc_acm 1-1:1.0: ttyACM0: USB ACM device

    [ 73.328954] cdc_acm 1-1:1.2: ttyACM1: USB ACM device
    Edit: You actually have to set two gpios, USB_OTG_SEL and VBUS_EN.
     
    Last edited: Jun 16, 2016
    Andrea Rovai and waltervl like this.

Share This Page