[beagleboard] Re: How to: UART Angstrom

Hi

I'm also trying to get this working at the moment...

Program the pinmux. You can do this in U-boot or Linux. There seems be a
problem with the current kernel pinmux setup code. But if you want to see
what's that involve with doing it the kernel method, I have a write up. But
note that this does seem to work with the current kernel (2.628/2.6.29).

Did you mean that, or did you mean that it does not work with the current kernel?

I changed the mux to Type 1 for Tx and Rx and set the Rx pin to Input in my 2.6.28 kernel. I still can't get anything out of the UART. If anyone is using the expansion UART on 2.6.28 I'd love to hear what was needed - we're supposedly showing a product that uses this on Monday :slight_smile:

Thanks!

Rob

Hi

I'm also trying to get this working at the moment...

> Program the pinmux. You can do this in U-boot or Linux. There seems be a
> problem with the current kernel pinmux setup code. But if you want to see
> what's that involve with doing it the kernel method, I have a write up. But
> note that this does seem to work with the current kernel (2.628/2.6.29).

Did you mean that, or did you mean that it does not work with the current kernel?

Sorry, bad typo. It does _NOT_ work. If you don't want to fix it in the
kernel, use U-boot changes.

I changed the mux to Type 1 for Tx and Rx and set the Rx pin to Input in my 2.6.28 kernel. I still can't get anything out of the UART. If anyone is using the expansion UART on 2.6.28 I'd love to hear what was needed - we're supposedly showing a product that uses this on Monday :slight_smile:

I have that UART working just fine in a 2.6.29 snapshot right now.
2.6.24 was the last version I attempted it. I just redid U-boot
to setup the pin mux. TX should just work. RX may have issues.

Could anyone please post specific instructions on how to get the UART
working on the expansion header. I have ready the hy-research article
and am still confused, along with not being able to find the files
they specify in my OE system.

All I need to do is send data at 250kbps from the TX on the expansion
header. Ive been trying for weeks and cant get anywhere?

Thanks so much,
Dan

Hi everyone, I am also having trouble getting the UART up and running.

I have downloaded U-boot and I have all the files. What do I need to
edit in U-boot before I build it to be able to get the UART header
pins up and running?

Above Rob has uploaded a patch of some kind for UART. What exactly
does it do and how would one use it?

My apologies for what may appear to be silly questions, I am very much
a newbie to all of this.

King regards,

Rob

hi everyone,

I'm having much trouble understanding how to get the UART up and
running on my beagleboard.

I have now managed to download a copy of the U-boot files, but I am
very unsure what I need to edit to get the UART up and running. Can
anyone please offer me any assistance on how to do this?

A previous message from Rob has a UART patch attached to it. What
exactly does this do and how would one use this?

Thank you for your time, Kind regards,

Rob

A previous message from Rob has a UART patch attached to it. What
exactly does this do and how would one use this?

Ok I think I have this solved. I have to edit the file /u-boot/board/
omap3/beagle/beagle.h and replace the lines of code as shown in the
patch file.

I have now done this and compiled a new u-boot.bin file.

How would one now read/write (Rx/Tx) data and set the baud rate etc
from within a C program?

Any assistance would be greatly appreciated. Once I get this up and
running I will compile a document for those behind me to help them get
the UART and and running in no time.

A previous message from Rob has a UART patch attached to it. What
exactly does this do and how would one use this?

Ok I think I have this solved. I have to edit the file /u-boot/board/
omap3/beagle/beagle.h and replace the lines of code as shown in the
patch file.

I have now done this and compiled a new u-boot.bin file.

How would one now read/write (Rx/Tx) data and set the baud rate etc
from within a C program?

Any assistance would be greatly appreciated. Once I get this up and
running I will compile a document for those behind me to help them get
the UART and and running in no time.

Hi all, I followed the directions in:
http://www.hy-research.com/omap3_pinmux.html

compiled the new version and loaded it on my beagle board. How do I
now send UART data to the pin from the console and in C?

Where does UART2 map to in linux tty??

Thanks,Dan

Ok everyone, I'm still having no luck getting the UART to work.

I am at a loss whether it's my C program or my U-boot.bin that I
built. In this message I will post the lines of code I edited in u-
boot-main/board/omap3/beagle/beagle.h for mux config and my C program.
Any advice would be greatly appreciated.

If someone has a working UART version of U-boot.bin could you possibly
share it so I could try it on my SD card?

The lines of code I edited for u-boot mux are:

  /*Bluetooth*/\
+ MUX_VAL(CP(MCBSP3_DX), (IEN | PTU | EN | M1)) /*UART2_CTS*/\
+ MUX_VAL(CP(MCBSP3_DR), (IDIS | PTD | DIS | M1)) /*UART2_TX*/\
+ MUX_VAL(CP(MCBSP3_CLKX), (IDIS | PTD | DIS | M1)) /*UART2_RTS*/\
+ MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1)) /*UART2_RX*/\
+ MUX_VAL(CP(UART2_CTS), (IDIS | PTD | DIS | M4)) /*GPIO_144*/\
+ MUX_VAL(CP(UART2_RTS), (IDIS | PTD | DIS | M4)) /*GPIO_145*/\
+ MUX_VAL(CP(UART2_TX), (IDIS | PTD | DIS | M4)) /*GPIO_146*/\
+ MUX_VAL(CP(UART2_RX), (IDIS | PTD | DIS | M4)) /*GPIO_147*/\

My C test program is:

#include <stdio.h>

#include <stdlib.h>

#include <fcntl.h>

#include <termios.h>

void tty_putchar (char);
int tty_init (void);
char tty_getchar (void);

int fd; // File descriptor for the tty

int main (void)
{
  char UART_get_return; //UART read variable
  int UART_init_return; //UART init returned value. If 0 then failed
to open ttyS1

  UART_init_return = tty_init(); //Initalize UART
  if (UART_init_return == 0) //If no file descriptor was returned in
tty_init()
    printf("Failed to open Port ttyS1. No file descriptor.\n");
  else //If there was a file descriptor retunred in tty_init()
    tty_putchar('R'); //Send ASCII R to UART
    UART_get_return = tty_getchar(); //Read Char from UART
      if (UART_get_return == 0) // 0 = No data found on Rx
        printf("No data waiting\n"); //No data waiting on UART Rx
      else //Else 1 = data found
        printf("UART read: %c\n", UART_get_return); //Print value read in
on UART
}

// Initialize UART
int tty_init (void)

{

  struct termios tio;

  // Open the comms device

  fd=open("/dev/ttyS1",O_RDWR | O_NONBLOCK | O_NOCTTY); //Open ttyS1
port

  if(!fd)
    return 0; //If no file descriptor return 0 error

  else
    printf("File Descriptor: %d\n", fd); //Print value of file
descriptor

     // Set port parameters

    tio.c_cflag = B115200 | CS8 | CREAD | CLOCAL; //Set baud, no. of
bits,

    tio.c_iflag = IGNPAR; //Ignore parity

    tio.c_oflag = 0;

    tio.c_lflag = 0;

    tio.c_cc[VMIN] = 1;

    tio.c_cc[VTIME] = 0;

    tcflush(fd, TCIFLUSH);

    tcsetattr(fd,TCSANOW,&tio);

    return 1; //Return to main function with no error

}

//Send char to UART
void tty_putchar (char c)

{

  char s[1];

  s[0]=c;

  write(fd, s, 1); //Write char to UART Tx

}

//Read Char from UART
char tty_getchar (void)

{

  char s[1];

  if(read(fd, s, 1) != 1)

    return 0; // No data waiting - if your data stream could include 0s
then

                   // you probably want to do something different about
this

    else

      return s[0]; //If no error then return the value read by UART

}

Thank you for your time. Any assistance is greatly appreciated.

Rob

/*Bluetooth*/\
+ MUX_VAL(CP(MCBSP3_DX), (IEN | PTU | EN | M1)) /*UART2_CTS*/\
+ MUX_VAL(CP(MCBSP3_DR), (IDIS | PTD | DIS | M1)) /*UART2_TX*/\
+ MUX_VAL(CP(MCBSP3_CLKX), (IDIS | PTD | DIS | M1)) /*UART2_RTS*/\
+ MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1)) /*UART2_RX*/\
+ MUX_VAL(CP(UART2_CTS), (IDIS | PTD | DIS | M4)) /*GPIO_144*/\
+ MUX_VAL(CP(UART2_RTS), (IDIS | PTD | DIS | M4)) /*GPIO_145*/\
+ MUX_VAL(CP(UART2_TX), (IDIS | PTD | DIS | M4)) /*GPIO_146*/\
+ MUX_VAL(CP(UART2_RX), (IDIS | PTD | DIS | M4)) /*GPIO_147*/\

Sorry my ../beagle.h mux file doesn't include the '+' symbols. Please
ignore them in this message, my build didn't include them.

Im having the same problems. If anyone can answer on how to get this
working, or had a pre built version of u-boot with these changes,
please share. I have been working for weeks trying to get this to
work, and I need to have it working in 3 days, and so far no luck.

Any help would be greatly appreciated. PS, im using open embedded and
bit bake.

Thanks,
Dan

I tried making this work with the 2.6.27 kernel, and patched mux
config using the latest u-boot from GIT. The best I could do was see
RTS get asserted when I wrote to the Com port. Looping RTS and CTS
did not help. I was using a logic analyzer to monitor the data lines.

I'd also appreciate some insight into this if anyone figures it out.

-Howard

Please indicate which Rev of the board you are using. The
RevC and RevB boards use different physical balls for the
connector UART pins which means the U-boot config will have
to be different.

I tried this several weeks ago with Rev B5. I believe I had the mux
correctly set up for that board.

Since then, i've received several Rev C boards, but haven't tried
changing the mux, or running the second UART on them yet.

-Howard

If you use a u-boot built from the most recent sources in the
omap3-dev branch, the pinmux changes for uart2 on rev B and rev C are
handled automatically.

If you don't want to build it yourself, you can find pre-built u-boot
images in my "daily" builds:

http://www.sakoman.com/feeds/omap3/glibc/images/beagleboard/

Steve

> Please indicate which Rev of the board you are using. The
> RevC and RevB boards use different physical balls for the
> connector UART pins which means the U-boot config will have
> to be different.

Hi, there I'm usuing Rev B5 and I'm having a hell of a time trying to
configure the UART2 mux :-p.

I downloaded U-boot-main and tried to edit the pin mux as shown below.

  /*Bluetooth*/\
+ MUX_VAL(CP(MCBSP3_DX), (IEN | PTU | EN | M1)) /*UART2_CTS*/\
+ MUX_VAL(CP(MCBSP3_DR), (IDIS | PTD | DIS | M1)) /*UART2_TX*/\
+ MUX_VAL(CP(MCBSP3_CLKX), (IDIS | PTD | DIS | M1)) /*UART2_RTS*/\
+ MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1)) /*UART2_RX*/\
+ MUX_VAL(CP(UART2_CTS), (IDIS | PTD | DIS | M4)) /*GPIO_144*/\
+ MUX_VAL(CP(UART2_RTS), (IDIS | PTD | DIS | M4)) /*GPIO_145*/\
+ MUX_VAL(CP(UART2_TX), (IDIS | PTD | DIS | M4)) /*GPIO_146*/\
+ MUX_VAL(CP(UART2_RX), (IDIS | PTD | DIS | M4)) /*GPIO_147*/\

My board revision is B5. I know there is a revision C out now, so does
this effect anything with regards to the u-boot?
I guess the version of u-boot-main I downloaded is the latest version
as I only downloaded it a week or 2 ago.
Is there any difference with u-boot with regards to the B and C
version of the board?

Thank you,

rob

Ok, I've discovered my problem. Silly me! I have been trying to set it
up to the configurations of a Rec C board and not my B5 board.

Opps.

Another question sorry.

Well I've worked out where I've been going wrong. I have been using a
u-boot example for RevC.

I'm trying to edit the lines of code in .../beagle.h but I'm unsure
what some of the definitions mean.

For example;

MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1)) /*UART2_RX*/\

What does M1 refer to? The beagle.h files just says 'M0 = Mode 0'.
This doesn't really explain much to newbie like myself.
Does it refer to Mux 1?

Another question sorry.

Well I've worked out where I've been going wrong. I have been using a
u-boot example for RevC.

I'm trying to edit the lines of code in .../beagle.h but I'm unsure
what some of the definitions mean.

For example;

> MUX_VAL(CP(MCBSP3_FSX), (IEN | PTD | DIS | M1))
/*UART2_RX*/\

What does M1 refer to? The beagle.h files just says 'M0 = Mode 0'.
This doesn't really explain much to newbie like myself.
Does it refer to Mux 1?

You are right - It refer to Mux mode 0-7 - Definitions on the different
muxing modes can be found in the TRM (spruf98b.pdf) chapter 7 "System
Control Module"...

Best regards - Good luck
  Søren