Reading a uart on the command line of Angstrom and a BeagleBone

Hello everyone. I posted earlier about something and everyone was so helpful I thought I would give it another go.

I am trying to setup my first uart connections to the beagle bone. A GPS sensor for reading out GPS sentences from the device. I have confirmed it works with other micro controllers and my windows PC. However, I have no experience with the command line tools in linux to read this stuff. Which is the first step I want to take before writing software around it.

I have read a bunch of stuff about stty, setserial and other tools to read a uart, but have had just plain NO LUCK.

I have attached my GPS Tx line to my P9, pin 26 (UART1_RXD). As far as I have read, this should be the correct pin for this. I have also used the power and ground lines from the BeagleBone into a bread board. Confirmed it is Tx’ing data at 9600 with an external serial connection (via windows) and my oscilloscope. I would like todo the following:

  1. Setup the uart connection.
  • Does this require setting a mode on the pin for muxing?
  • How do I read the data?

I have found several articles on talking to a serial device, but none that are clear to me on how to read.

Thanks in advanced.

Cheers,

Gregg

man stty? Maby

I did, (via google as man isn’t on angstrom)… the data confused me… However, I did just find this thread which explained setting the muxing settings:

http://groups.google.com/group/beagleboard/browse_thread/thread/7f3ef67362bfda71/bff6ba02dffcbf0f?#bff6ba02dffcbf0f

However, it’s in python and I don’t know how todo it via the command line still, but working on it now.

More info:

I have started to figure out setting the mux mode correctly. However, I am trying to write mode 0 with input. Which I think is 32 based on converting 0x00100000 to a binary number so I us:

echo 32 > /sys/kernel/debug/omap_mux/uart1_rxd

and I then cat the file with the result:

root@beaglebone:/sys/kernel/debug/omap_mux# cat uart1_rxd
name: uart1_rxd.d_can1_tx (0x44e10980/0x980 = 0x0032), b NA, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE2
signals: uart1_rxd | mmc1_sdwp | d_can1_tx | NA | NA | NA | NA | NA

So it sets it to mode 2 with an output setting… So confused…

Again any help is apprciated. I will post a working set of steps here when I am done with this.

Ok again, more info:

echo 0x20 > /sys/kernel/debug/omap_mux/uart1_rxd

is now setting the mode correctly, but not the pin direction, everything I have read so far says this should be working correclty. Again the cat output of the pin:

root@beaglebone:/sys/kernel/debug/omap_mux# cat uart1_rxd
name: uart1_rxd.uart1_rxd (0x44e10980/0x980 = 0x0000), b NA, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
signals: uart1_rxd | mmc1_sdwp | d_can1_tx | NA | NA | NA | NA | NA

I bolded the part that seams to be incorrect to me.

Gregg hi. Have you re-tried reading from the port? 20 is the correct value to write. I just checked on a board that’s actively reading (a gps in fact) from uart1, and when I cat /sys/kernel/debug/omap_mux/uart1_rxd it seems to indicate that the pin is an output, just like yours does. I wonder if this is just a bug? I usually use minicom to check whether a port is receiving data or not so I don’t have to worry about making any mistakes setting up the port. In your case (uart1, 9600b), minicom -b9600 -o -D/dev/ttyO1 should do what you want.

Steve

I had not, but I just tried it and it just sits there. I also found another little file that I think should be showing the uart port with

root@beaglebone:/sys/kernel/debug/omap_mux# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:unknown port:00000000 irq:0
1: uart:unknown port:00000000 irq:0
2: uart:unknown port:00000000 irq:0
3: uart:unknown port:00000000 irq:0

But it says unknown. Maybe I need to configure with setserial now or something?!?

I just noticed I tried the wrong command, I tried it with /dev/tty1 and not 01

When I tried

minicom -b9600 -o -D/dev/tty01

The program simply returned to the command line. Other ones it went into a screen where I could hit ctrl+A and then Z and do various things. Not sure what’s going on here, I did hook up my oscope and see that the voltage is only getting to 2.97V could it be that the 3.3 trigger isn’t getting hit. My thought is anything about 1.8 should be good, but I am a code by profession not a EE guy.

Thanks for the help

Gregg

I just noticed I tried the wrong command, I tried it with /dev/tty1 and not 01

When I tried

minicom -b9600 -o -D/dev/tty01

Make sure this is ttyO1 (OH-one), not tty01 (zero-one)

Ok, so I just tried that as well. ttyO1 (OH-one) is not working either. However, it does open to the minicom screen and not return to the command line. I made sure all the parameters and terminal modes where set correctly. Double checked the GPS documentation to make sure I had the 8N1 part setup right. Still no dice. Is there anything in minicom I have todo after it opens or should it just be spitting out what it is receiving?

Thanks,

Gregg

I've been following along here.... interesting stuff!

I seem to be able to get uart1_txd working. If I do:

# echo >/sys/kernel/debug/omap_mux/uart1_txd 00
# id > /dev/ttyO1

...I can see the data output on pin P9-24 with my scope.

If I then jumper pin P9-24 (uart1_txd) to pin P9-26 (uart1_rxd), then
do:

# echo >/sys/kernel/debug/omap_mux/uart1_rxd 20
# screen /dev/ttyO1

Then I can see characters echoed back to me, and also see them on my
scope.

Interesting. I am not near my BeagleBone currently, but I wonder if I need to get both pins set with the correct mux setting. Maybe it won’t work because the Tx side (which I don’t have hooked up) isn’t in the same mode as the RX pin.

I will try that when I get home, if that doesn’t work I will try and assure that my port is working with the loop back like you are doing. That’s a good idea.

Thanks again everyone for your input. I will keep you guys apprised as to how things are going.

Guys,

I am finally figured it out!

Steps to setup a GPS via uart1 that I needed to take.

  1. Connect the GPS rx pin to the uart1_txd port. (This I didn’t do when I started because I didn’t intend on sending commands to the GPS)
  2. Connect the GPS tx pin to the uart1_rxd port. (This I had done)
  3. Set up each of the pins MUX mode to the correct value. They default to mode 7 and I needed mode 0 for each.

echo 0x20 > /sys/kernel/debug/omap_mux/uart1_rxd
echo 0x00 > /sys/kernel/debug/omap_mux/uart1_txd (this command is optional, however required if you want to xmit)

3a. You can optionally check to see how they are setup via

cat /sys/kernel/debug/omap_mux/uart1_rxd
cat /sys/kernel/debug/omap_mux/uart1_txd

  1. Run the command to monitor the output:

screen /dev/ttyO1 (that is the letter O and not the number 0, for any of you that are new to this stuff like I am)

Daniel thank you for your loopback test which made me think of connecting the GPS rx pin alone with the tx pin.

Gary thank you for setting me straight on the letter vs number in the tty console name.

Steve thank you for letting me know you were getting the same weird output from cat’ting your muxed pin and setting my mind at ease.

Thanks all,

Gregg

I was curious this weekend about why input pins were being reported as outputs when we looked at /sys/kernel/debug/omap_mux/uart1_rxd (for example), even when it has been set as an input. The issue is in omap_mux_decode() in arch/arm/mach-omap2/mux.c. The only thing this code ever does is print the pad properties, so it should be benign. Confusing while debugging though.

Steve

I’ll just leave this “reading from a GPS module with python” tutorial right here: http://www.youtube.com/watch?v=c7_UsgV4Gr8

Thanks, it was good to see a video of other people doing the same thing. It’s interesting how he mentioned the exact problem of needing the Rx and Tx lines hooked up.

I have been able to access it with some CLI tools mentioned above and how some python code. My next challenge, which is seaming quiet difficult is accessing SPI via the processor. I see how to hook it up, but the only thing I can find to work with it is in C and I am trying not to go down that route. Should probably start another thread…

This makes sense. I was having a hard time figuring this out. Thanks for the tidbit!

thanks Gregg, it works like a charm !

xa4

Hi everyone,

I’m new to beaglebone black board.I need to read/write data via UART port in beaglebone board.I can read the data in beaglebone board via UART1 port from PC. But I cant read data in PC from beaglebone board. Can anyone please help me to fix this issue?

I’m struggling in read/write operation in beaglebone board. Only the read operation done correctly If I have used TTL to USB convertor. Only the write operation done correctly if I have used TTL cable alone. I cant understand what will be wrong. Can anyone please help me?