[solved] enabling serial ports

Discussion in 'General Programming Discussion' started by bmti, Jun 2, 2014.

  1. bmti

    bmti New Member

    Joined:
    Apr 23, 2014
    Messages:
    7
    Likes Received:
    0
    Hello,

    I try to enable serial ports (UART1 and UART3) connected to imx6 through external Pins (CSIO_DAT10, CSIO_DAT11, EIM_D24, EIM_D25).
    I follow the example in the starting manual, so I edited the file board-mx6qd_seco_UDOO.h, then I rebuilt the kernel.

    I wrote a simple program with Qt, that display all serial ports, and try to open them:
    Code:
        this->ListInfo = QSerialPortInfo::availablePorts();
        foreach(QSerialPortInfo info, this->ListInfo)
        {
            ui->textEditOutput->append(info.portName());
    
            this->serialPort.setPort(info);
            if(this->serialPort.open(QIODevice::ReadWrite))
            {
                ui->textEditOutput->append("yes");
                this->serialPort.close();
            }
            else
                ui->textEditOutput->append("no");
        }
    
    But there is no difference between the kernel from the SD card image and the new kernel (with UART enable) when I execute this code.

    Did I miss something to enable UART1 and UART3?

    I have a second question:
    Can I test the both UART by linking them together?
    (RX from UART1 connected to TX from UART3, and TX from UART1 connected to RX from UART3)

    Regards,
     
  2. bmti

    bmti New Member

    Joined:
    Apr 23, 2014
    Messages:
    7
    Likes Received:
    0
    Re: enabling serial ports

    I followed the starting manual, so I think the both UART are enabled.
    But they don't show up anywhere!

    Must I change a conf file?
    Must I change the menuconf during kernel built?
     
  3. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: enabling serial ports

    Sorry , but I wouldn`t trust anything which is in the manual about getting the extra serial ports or the i2c working.
    I put in a Support Ticket a month ago about the i2c not working and if I followed the manual all I finish up with is a kernel panic, so don`t hold your breath on getting any support from the udoo tearm.
     
  4. bmti

    bmti New Member

    Joined:
    Apr 23, 2014
    Messages:
    7
    Likes Received:
    0
    Re: enabling serial ports

    It's sad for my project :cry:

    I didn't want to use the duino part of the UDOO on this project, but I think I will, because I really need some UART.
    Can I read and write on serial ports with arduino, and send data from/to the imx6?

    I will search on the "learn->projects" part of the website. Maybe someone uses serial ports in his project.
     
  5. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: enabling serial ports

    Can I read and write on serial ports with arduino, and send data from/to the imx6?

    I would say it`s very easy to do that .

    Arduino side ..

    set the baud rates for both ports , set up buffers etc

    in the main loop use :-

    while ( SerialX.available() > 0 ) // try if or while ..
    {
    char_buffer = SerialX.read()
    SerialY.Write( char_buffer )
    }
    and maybe
    while ( SerialY.available() > 0 ) // try if or while ..
    {
    char_buffer = SerialY.read()
    SerialX.Write( char_buffer )
    }

    change X and Y to the right numbers
     
  6. bmti

    bmti New Member

    Joined:
    Apr 23, 2014
    Messages:
    7
    Likes Received:
    0
    Re: enabling serial ports

    Thank you peter :D
    I never worked on Arduino before, and this sample of code will help me.

    But I don't add [solved] to the title, because my wish is to use serial port without Arduino.
    I can't believe we are only 2 people working on UDOO and using UART.
     
  7. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: enabling serial ports

    It may not be what you asked for , but before I purchased the udoo & cubietruck I was using the sheevaplug which does not have any serial or i2c connections and the only way to expend is via the two usb sockets.
    So one method you may have over look is just get a usb to uart or transceiver pair which as a usb plug on one , and a TTL / 3.3v output on the other.

    The problem is , to every 1000 beginners you have 1 intermediate user , who can do must things , but still needs help from the developers.
    To every 1000 intermediate users you have one good developer , who can make new libraries and driver for the udoo etc .
    The bigger the base of users the more developers you get working on that hardware .
     
  8. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    Re: enabling serial ports

    In addition to changing pin-mux settings in the .h file, you also need to edit "board-mx6_seco_UDOO.c" in the same directory to bind a device driver to any extra UART(s) you want to use. Search this file for "UART" in all capitals to find this labeled section:

    Code:
    /***********************************************************************
     *                                  UART                               *
     ***********************************************************************/
    
    static inline void mx6q_seco_UDOO_init_uart(void) {
            imx6q_add_imx_uart(0, NULL);
            imx6q_add_imx_uart(1, NULL);
        imx6q_add_imx_uart(3, NULL);
    }
    
    The numbering here starts with 0 rather than 1 (same as /dev/ttymxc# numbers), so the lines already present enable UART1, UART2 (used for low-level debugging and serial-console, respectively via the USB-to-serial chip-- jumper J18 controls which one is brought out), and UART4 (internal link to the Arduino side's main TX/RX on pins 0/1). UARTs 3 and 5 are unused and available-- just add them to the list like this, after mapping them to pins: (notice with UART5 you can choose from two sets of pins to use)

    Code:
    static inline void mx6q_seco_UDOO_init_uart(void) {
            imx6q_add_imx_uart(0, NULL);
            imx6q_add_imx_uart(1, NULL);
            imx6q_add_imx_uart(2, NULL);   // added UART3 aka /dev/ttymxc2
        imx6q_add_imx_uart(3, NULL);
        imx6q_add_imx_uart(4, NULL);       // added UART5 aka /dev/ttymxc4
    }
    
    After compiling the new kernel, installing it and rebooting, you should see all five serial ports in /dev:

    Code:
    $ ls -l /dev/ttymxc*
    crw-rw---T 1 root dialout 207, 16 Jun  9 14:15 /dev/ttymxc0    # USB debug
    crw-rw---- 1 root tty     207, 17 Jun  9 14:15 /dev/ttymxc1       # USB console
    crw-rw---T 1 root dialout 207, 18 Jun  9 14:15 /dev/ttymxc2     # new UART3 - pins 47/53
    crw-rw-r-T 1 root dialout 207, 19 Jun  9 14:15 /dev/ttymxc3     # internal link to Arduino side
    crw-rw---T 1 root dialout 207, 20 Jun  9 14:15 /dev/ttymxc4     # new UART5 - pins 16/17 OR 48/49
    
    If you need more than two serial ports on the i.MX6 side, you might be able to take over UART1, 2, and/or 4 by disabling their default functions-- all are brought out on the headers as well-- but I haven't really looked into that.

    Enabling extra SDHC controllers and a lot of other off-by-default funtions requires editing the *UDOO.c file also, in addition to changing pin assignments. The documentation probably isn't clear enough on this.
     
  9. bmti

    bmti New Member

    Joined:
    Apr 23, 2014
    Messages:
    7
    Likes Received:
    0
    Re: enabling serial ports

    Thank you very much fetcher!

    My both UART work perfectly.

    I keep that in mind ;)
     

Share This Page