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.

UART0 port setup for receiving and transmitting data dm6446

Hi TI employees,

                             I have been using dvsdk 2.00 and trying to program output uart0 to receive and send the data (same physical hardware port as the one I receive minicom data). I am using NFS+ TFTP method. I first load the kernel image usinng rs232 innterface. After loading the target OS I disconnect rs232 port. Then I use SSH to send and receive commands. Now I want to use the same rs232 physical port to receive and send my own data. I have already written a program for it at API layer. but now it does seem to set the baud rate I want it to be. But I am unable to send or recieve data via it. What am I doing wrong? Do I need kernel hacks? What is the procedure?

Thanks!

  • virgoptrex said:
    I am using NFS+ TFTP method. I first load the kernel image usinng rs232 innterface.

    I am a bit confused by this statement, if you are using TFTP for boot this implies that the kernel image is loaded using the Ethernet interface. When you say you load the kernel image using RS232 are you using a serial boot mode?

    I suspect you need to configure the kernel to no longer use the UART as the default terminal, I have not tried this but I would suspect you could just change console=ttyS0,115200n8 in your bootargs in U-Boot to something else, I don't think you need to make kernel modifications. With that done you should be able to adjust ttyS0 to whatever baud rate and settings you need like you would on any other Linux machine.

  • Hi Bernie,

                   Following are the parameters I enter while I boot. I believe I am using RS232 minicom program just to connect as my target IP is dynamic and later view the boot sequence. I think entire process takes place through ethernet connection. Unless I am wrong, with the paramters I use (see below) I cannot do SSH at first without loading the kernel image and file system since no kernel image is present. Hence to do ssh I need to know the value of 'xxx' in the following like e.g. ssh root@10.2.172.xxx.  To get this value of 'xxx' I use RS232 at first. When I am at 'root' prompt on davinci, I disconnect RS232 ( intend to free hardware for my own program) then I use ssh to carry out further commands like loading cmem, dsplink etc . Now I am bit confused on how to program RS232 which spits out kernel messages on any hyper terminal or minicom to send our own comands? Let me know if I can explain myself better [:)]

    setenv bootcmd 'dhcp;bootm'

    setenv serverip 10.2.172.121

    setenv bootfile uImage

    setenv rootpath /home/user/workdir/filesys

    setenv nfshost 10.2.172.121

    setenv bootargs video=davincifb:vid0=0,2500K:vid1=0,2500K:osd0=720x576x16,2025K davinci_enc_mngr.ch0_output=COMPOSITE davinci_enc_mngr.ch0_mode=$(videostd) console=ttyS0,115200n8 noinitrd rw ip=dhcp root=/dev/nfs nfsroot=$(nfshost):$(rootpath),nolock mem=118M

     

    Does this have to do anything with the last statement "console=ttyS0" . what other options do I have?

  • virgoptrex said:
    I believe I am using RS232 minicom program just to connect as my target IP is dynamic and later view the boot sequence. I think entire process takes place through ethernet connection. Unless I am wrong, with the paramters I use (see below) I cannot do SSH at first without loading the kernel image and file system since no kernel image is present. Hence to do ssh I need to know the value of 'xxx' in the following like e.g. ssh root@10.2.172.xxx.  To get this value of 'xxx' I use RS232 at first. When I am at 'root' prompt on davinci, I disconnect RS232 ( intend to free hardware for my own program) then I use ssh to carry out further commands like loading cmem, dsplink etc . Now I am bit confused on how to program RS232 which spits out kernel messages on any hyper terminal or minicom to send our own comands?

    This clarifies things a bit, so you are loading over Ethernet, and just using the RS232 for checking status on the board, this makes perfect sense. To answer your question I am not sure that you can easily have kernel messages come out of a network interface because of the problem  you describe, you need to have an IP setup to use a network interface.

    virgoptrex said:
    Does this have to do anything with the last statement "console=ttyS0" . what other options do I have?

    If you had other serial ports available you could set it to one of them, though since the ttyS0 port is the only one available at this point of the boot process I am not sure you can set it to anything valid. Is there any way you could use a static IP so that you could disable the kernel console (i.e. console=null)? You may be able to get the IP address by running 'dhcp' in U-Boot to use a dynamic IP even without having the console=ttyS0 for the kernel. I am hoping that using something like console=null will let you get in with SSH and than have the ttyS0 port available for your own use, however I have never tried this so I am not sure if the kernel has ttyS0 bound elsewhere as well, but it is worth a shot.

  • Hi Bernie,

     

                         I wrote a program for serial mode by itself and without mixing POSIX threads (without combining with encodedecode demo) and it worked!!! As you stated I made static IP. (thanks to network engg who told me values of gateway, net mask ,etc)

    In my boot args statement I replaced "ip=dhcp" with "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off" and before this statement did something like "setenv serverip xx.xx.xxx.xxx" "setenv netmask xx.xx.xxx.xxx", etc. Well so when my davinci boots it has DHCP momentarily but changes to static IP immediately as I have this statement.

    Also for ttyS0 I didn't have to change anything with kernel or even play with "console=ttyS0".in boot args I just wrote program which will override the control of serial port to my binary executable. Made my own make file. I just had to provide permission - do something like "chmod wr+o /dev/ttyS0" and thats it, It worked. I was using SSH all the while on loading image file and file system on davinci and now its easier cause I have static IP too. I verified through minicom on ubuntu and hyper terminal on windows[:D]

    This may not be the best way, but it may help others!

  • Thank you for posting the solution, it is good to know that you can take over the ttyS0 port for other uses even if the kernel was using it for the console, this is certainly handy to know and will likely help others.

  • Hi Bernie,

                     Thanks for the complements! Today I made some more progress and now able to run multiple processes (one of which is UART). Next step is using 'fifo_put' and 'fifo_get' for buffer interaction between multiple threads! I was virtually going nowhere for like 30-40 days and all of a sudden some results with the RAW code which I am able to see and experience! [:Y]

  • Hi Bernie,

     

                      Just to update you, I wrote a program to read / write UART0 and it worked great on Ubuntu. Now when I recompiled with davinci gcc (not ubuntu) - made changes in makefile it worked for write only and gave garbage characters for read only! Then realized that ur advise on bootarg "console=null"...bingo that did it..now I cannot see boot process but due to static IP doens't matter as I use SSH...now it reads too!!!

     

                    Thanks!

  • Hi ,

     

    I am new to DaVinci programming and I also want to use serial port. I disabled console as "console=null" in bootarg, i can write to serial port but inside the card but cannot receive anything. Can you send me the c codes for how to configure, read from and write to serial port

     

     

    thanks

  • I believe I went through tutorials on www.tldp.org for programming serial port about 1.5 years back as you see from my post :) . However a general google search should also give you good results! One point to note is: make sure you use blocking read or non blocking read code as appropriate for your application. Also there is concept of "canonical" and "non canonical" which I distinctly remember giving me a hard time to read from serial port. Code snippet would look like.

     

              /*
              IGNPAR  : ignore bytes with parity errors
              ICRNL   : map CR to NL (otherwise a CR input on the other computer
                        will not terminate input)
              otherwise make device raw (no other input processing)
            */
             my_termios.c_iflag = IGNPAR; // | ICRNL;
            //my_termios.c_iflag = IGNPAR | ICRNL;
        
             my_termios.c_oflag = 0;
            
            /* set input mode (canonical, echo,...) */
              my_termios.c_lflag = 0; 
             //my_termios.c_lflag = ICANON;
    
    
             
            //my_termios.c_iflag = IGNPAR | ICRNL;
            //my_termios.c_oflag = 0;
            
            /* set input mode (canonical, echo,...) */
           // my_termios.c_lflag = ICANON;