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.

UART1 Question and Some fuzzy situations

Dear Davinci System Developers,

I want to combine  my EVM board  with a  GPS module.I am using the kernel from DVSDK software. I am preparing a  program's G.U.I which is showing me the information form GPS module. This module is sending the data via rs-232. I want to activate UART1 on my board for getting  these data. How can I activate this UART1 on DM355? I am also very new at linux and davinci platform. I need some simple examples for using device drivers like UART, PWM ,etc. Where can I find these kind of examples?

 

 

Thanks

 

Best Regards

 

Canibek Sağın 

  • First, you need to fix a small bug present in DVSDK 1.30.  (change current lines which access a byte to lines in bold below, which access words)

    File: arch/arm/mach-davinci/serial.c

    static inline unsigned int davinci_serial_in(struct plat_serial8250_port *up,
                                                 int offset)
    {
            offset <<= up->regshift;
            return (unsigned int)__raw_readw(up->membase + offset);
    }

    static inline void davinci_serial_outp(struct plat_serial8250_port *p,
                                           int offset, int value)
    {
            offset <<= p->regshift;
            __raw_writew(value, p->membase + offset);
    }

    Rebuild the kernel after modifying the above file.

    Second, after booting Linux, check to see if /dev/ttyS1 is present.  If so, you can skip step 1 below

    1) mknod /dev/ttyS1 c 4 65

    root@156.117.95.55:~# stty sane 115200 raw -echo crtscts < /dev/ttyS1

    root@156.117.95.55:~# stty -a < /dev/ttyS1
    speed 115200 baud; rows 0; columns 0; line = 0;
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
    lnext = ^V; flush = ^O; min = 1; time = 0;
    -parenb -parodd cs8 hupcl -cstopb cread clocal crtscts
    -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon
    -ixoff -iuclc -ixany -imaxbel
    -opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
    ff0
    -isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
    echoctl echoke

    This confirms that UART1 is configured at 115200 baud rate.


    root@156.117.95.55:~# echo "this is test" > /dev/ttyS1

    This command will not output anything instead on console and will wait for response from other end.

    Now you can hookup scope and see the activity on pins.

  • Dear Juan ,

    I have fixed these  bugs 10 minitues ago. I did try it I saw the message below,

    "stty -a < /dev/ttyS1
    speed 115200 baud; rows 0; columns 0; line = 0;
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
    lnext = ^V; flush = ^O; min = 1; time = 0;
    -parenb -parodd cs8 hupcl -cstopb cread clocal crtscts
    -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon
    -ixoff -iuclc -ixany -imaxbel
    -opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
    ff0
    -isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
    echoctl echoke

    then I tried for see something by scope for this command on console

    " echo "this is test" > /dev/ttyS1"

    but I didn't see anything on scope.   I am not sure about  my kernel version. How can I learn the version of the kernel?

     

  • during the boot process, the kernel version is displayed via UART0.  if you are using the latest DVSDK 1.30, then the kernel version should be 2.6.10

  • My kernel's Linux version is 2.6.10_mvl401. I did all the fixes you mentioned above. Then I checked it by watching my DVEVM's DC3 I/O expansion pin 19 and 21. There is no signal . Just I see high level on 19 and low level on 21.

     

    Best Regards

  • just to elimintae variables, can you try the following after enabling UART1 per previous post

    - check serial driver status

    root@156.117.95.55:~# cat /proc/tty/driver/serial
    serinfo:1.0 driver revision:
    0: uart:16550A mmio:0x01C20000 irq:40 tx:26461 rx:398 RTS|CTS|DTR|DSR
    1: uart:16550A mmio:0x01C20400 irq:41 tx:0 rx:0 CTS|DSR
    2: uart:16550A mmio:0x01E06000 irq:14 tx:0 rx:0 CTS|DSR
    3: uart:unknown port:00000000 irq:0
    root@156.117.95.55:~#

    - Write to UART1 "echo this > /dev/ttyS1

    - check serial driver status

    root@156.117.95.55:~# cat /proc/tty/driver/serial
    serinfo:1.0 driver revision:
    0: uart:16550A mmio:0x01C20000 irq:40 tx:26461 rx:398 RTS|CTS|DTR|DSR
    1: uart:16550A mmio:0x01C20400 irq:41 tx:5 rx:0 CTS|DSR
    2: uart:16550A mmio:0x01E06000 irq:14 tx:0 rx:0 CTS|DSR
    3: uart:unknown port:00000000 irq:0
    root@156.117.95.55:~#

    This shows the driver xmited 5 characters.

  • Thank you Juan ,

    I am checking now,

     

    Best Regards

     

    Happy new year..

  • Dear Juan ,

    After writing    " cat  /proc/tty/driver/serial "

    It shows this console output.

    0: uart:16550A mmio:0x01C20000 irq:40 tx:58149 rx:697 RTS|CTS|DTR|DSR
    1: uart:16550A mmio:0x01C20400 irq:41 tx:5 rx:0 CTS|DSR
    2: uart:16550A mmio:0x01E06000 irq:14 tx:0 rx:0 CTS|DSR
    3: uart:unknown port:00000000 irq:0

    according to this message it sended 5 characters. But I couldn't get it from scope.  Does UART1 pins works on DC3 well? Did you checked it before?May be there is a problem on my scope . I will change it.

    I have a question, that,   Do I have to use these process BELOW for using UART1 ?  

    mknod /dev/ttyS1 c 4 65

    root@156.117.95.55:~# stty sane 115200 raw -echo crtscts < /dev/ttyS1

    root@156.117.95.55:~# stty -a < /dev/ttyS1

     

     


  • Dear Juan ,

    Thank you for your help , I managed to see the data from UART1 TX.

    It was a good new year present  for me.

     

    Best Regards

     

    Canibek Sağın

  • hi Juan,

    I have read the post and you ask to do some bug fixes in  the serial.c file. And by looking at this mailing list email:

    From: Laurent Meyer <laurent.meyer@borea.com>

    > Subject: Re: uart1 on dm355

    > To: hoangviet5012001@yahoo.com

    > Cc: "davinci-linux-open-source" <davinci-linux-open-source@linux.davincidsp.com>

    > Date: Wednesday, September 17, 2008, 9:14 AM

    > Hi Viet Hoang and everyone,

    >

    > Thank you for the so fast response !

    >

    > My turn to share something :)

    >

    > I tried to program UART2 the same way, but i got some

    > clocking issues.

    > Looking on the tms320dm355 shows that it was not on the

    > same

    > cliockdomain as UART0 and UART1.

    >

    > In fact, uart2 like usb is on clockdomain SYSCLK2, which is

    > in my

    > configuration ruts at 108 Mhz

    > So i modified the uart2 click in board-dm355-evm.c:

    >

    > .uartclk = 108000000,

    >

    > Hope it would help someone.

    >

    > Le mardi 16 septembre 2008 à 20:38 -0700, Viet Hoang a

    > écrit :

    >

    > > Hi Laurent and all,

    > > Because many people have sent private mail to

    > me to ask about

    > > using UART1 on DM355. I'd like to re-send the

    > solution to the mailing

    > > list so that in the future, some one will easily find

    > this.

    > > Reagards,

    > > Viet Hoang.

    > >

    > > In order to use UART1 on DM355:

    > > 1. Add some code to function board_init()

    > > ( arch/arm/mach-davinci/board-dm355-evm.c) as below:

    > >

    > > static void board_init(void)

    > > {

    > > volatile int *ptr_pgmgt,*ptr_ier; //Added for

    > UART1

    > >

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_VPSSMSTR, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_VPSSSLV, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_TPCC, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > > DAVINCI_LPSC_TPTC0, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_TPTC1, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_GPIO, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_McBSP1, 1);

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_SPI, 1);

    > >

    > > // Turn on WatchDog timer LPSC. Needed for RESET

    > to work

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_TIMER2, 1);

    > >

    > > // Added for UART1

    > > board_setup_psc(DAVINCI_GPSC_ARMDOMAIN,

    > DAVINCI_LPSC_UART1, 1);

    > > davinci_serial_init(&serial_device);

    > >

    > > davinci_writel(0x56837210, DAVINCI_VPSS_REGS_BASE

    > + 0x810);

    > > davinci_writel(0x7b3c0004, DAVINCI_VPSS_REGS_BASE

    > + 0x814);

    > >

    > > //Enable UART1

    > > ptr_pgmgt = (volatile int

    > *)IO_ADDRESS(DAVINCI_UART1_BASE+0x30) ;

    > > ptr_ier = (volatile int

    > *)IO_ADDRESS(DAVINCI_UART1_BASE+0x4);

    > > *ptr_pgmgt =

    > > 0x0; //reset tx and rx

    > > *ptr_ier = 0x0; //disable int

    > > int del = 0;

    > >

    > > for(del = 0; del < 100000 ; del++) // For

    > delay

    > > *ptr_pgmgt =0x6001;

    > >

    > > // Initialize the clock configurations

    > > davinci_clk_init();

    > > //End UART1

    > > }

    > >

    > > 2. Rebuild the kernel, then you can use /dev/tts/0 or

    > /dev/tts/1 for

    > > UART0 / UART1; Or you can use mknod to create

    > /dev/ttyS1 for your

    > > UART1.


    Here they ask to add some code lines to the board-dm355-evm.c file.


    Can you confirm me .... is this necessary or just doing the bug fixes as you mentioned in your post is enough to make UART1 work?


    Thanks.

  • That may be a different approach toward doing this, not one I particularly like since they are initializing UART in the general board settings when there exists a UART driver (better place to do this in my opinion).  As you can see from this post, the customer above got this working without having to modify board-dm355-evm.c

  • ok great then I will try this one.

    Also one one more thing...the UART1 output is TTL or RS232?

  • Only UART0 is routed to RS232, UART1 is accessed via DC3 connector; see EVM technical reference manual for more details: http://c6000.spectrumdigital.com/evmdm355/revd/

  • Hi,

    I am too having problems accessing UART1 on the DM355 (custom board).

    I have tried both changing the readb by readw and the board-xxx.c changes. I am getting the following at boot:

    Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled

    serial8250.0: ttyS0 at MMIO map 0x1c20000 mem 0xfec20000 (irq = 40) is a 16550A

    serial8250.0: ttyS1 at MMIO map 0x1c20400 mem 0xfec20400 (irq = 41) is a 16550A

    serial8250 serial8250.0: unable to register port at index 2 (IO0 MEM1e06000 IRQ14): -28

     

    Then each time I try to acces the port I get this messages:

    serial8250: too much work for irq41

     

    When I cat /proc/interrupts I have the following:

      4:          0       AINTC  dm644xh3a_af, dm644xh3a_aew

      5:          0       AINTC  dm355_ipipe

      8:      19050       AINTC  davinci_osd

     12:       9040       AINTC  musb_hdrc

     16:          0       AINTC  EDMA Completion

     17:          0       AINTC  EDMA CC Err

     18:          0       AINTC  EDMA TC0 Error

     19:          0       AINTC  EDMA TC1 Error

     32:      38128       AINTC  clockevent

     33:          2       AINTC  free-run counter

     39:        188       AINTC  i2c_davinci

     40:        846       AINTC  serial

     42:          0       AINTC  dm_spi

    Err:          0

     

    UART1 is not registered here... Any idea on how I could correct this problem?

     

    Thanks alot!

    Theodore

  • Theodore,

    As you can see from the following post, the changes to serial.c are the key to fixing this if you are working with dvsdk 1.3: http://e2e.ti.com/forums/p/8010/31144.aspx#31144

  • I try to use both COM1 & COM2 with davinci DM6441

    I make your recommend change.

    But while I run the command : stty sane 115200 raw -echo crtscts < /dev/ttyS1

    I got this error:

    stty: standard input : input/output error

    Any idea?

  • Have you changed your driver source code?

    The original driver doesn't support ttyS1.

  • I think I didn’t.

    where I found the driver change ?

  • which change I need to do to support both UART0 and UART1

  • Eran,

    Do you need to do this for DM355 as well or do you only need DM6446 at this point (based on other posts)?

  • Only for DM6446 at this point.

  • ok, just wanted to clear this up as it may cause confusion to other readers since this in the TMS320DM3x Processors section of our forums.  Let us continue with this discussion on the other thread which is more appropriate for DM644x and hopefully reduce the confusion for everyone who may come across this.