I am trying to enable Arduino-like serial output for my BeagleBone Rev5.
From what I understand the UART mapping is like this: UART0 <=> /dev/ttyO0
I am running the latest Angstrom distro: http://downloads.angstrom-distribution.org/demo/beaglebone/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img.xz
I have disabled the Angstrom default getty on /dev/ttyO0 by modifying this file:
/etc/systemd/system/getty.target.wants/serial-gett@ttyO0.service
(gleaned from this question: Automatic login on Angstrom Linux)
I commented everything out which I believe should stop getty from starting on that port. Once done I rebooted the board and am no longer able to connect via serial console so that seemed to work.
But I now cannot find any reliable information on how to configure that UART so I can transmit data. I have looked extensively but all the documentation refers to older versions of Angstrom that don't seem to reflect the most recent release.
For example they all say to exec a command like this:
root@beaglebone:~# cat /sys/kernel/debug/omap_mux/uart1_rxd
(http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/)
But when I try that, there's nothing there:
root@beaglebone:/sys/kernel/debug# ls
asoc gpio musb-hdrc.0.auto regulator usb
atmel_mxt_ts hid musb-hdrc.1.auto sched_features wakeup_sources
bdi iio pinctrl suspend_stats
bluetooth kprobes pm_debug tracing
dri memblock pwm ubi
f2fs mmc0 regmap ubifs
root@beaglebone:/sys/kernel/debug#
The latest release of Angstrom seems to be from April 2013 which is much newer than most of the blog posts I've seen regarding this. It seems that the new version of Angstrom does things differently than the old versions. Does anyone have any idea how to actually USE the various hardware on the new versions of Angstrom/BeagleBone?
root@beaglebone:/sys/kernel/debug# uname -a
Linux beaglebone 3.8.6 #1 SMP Sat Apr 13 09:10:52 CEST 2013 armv7l GNU/Linux
root@beaglebone:/sys/kernel/debug#
I'd love a specific answer but would be quite satisfied with any information I can get regarding how things work in the newer versions of Angstrom.
EDIT: Turns out I just didn't try hard enough. I plugged the BeagleBone into the network and did
opkg update
opkg install python-pyserial
Once that was done I was able to write a small program that would dump out over the built-in serial/USB port (/dev/ttyO0) at whatever data rate I want.
With getty for serial disabled I can write as much as I'd like without issue. If the getty is turned back on it'll interrupt my connection whenever it detects something is happening at a slower speed, at that slower speed.
Thanks for all the help. I especially appreciate the information about how nothing is figured out re:device tree since that's a problem I'm going to face myself as I try and use a BeagleBone for other projects.
The command you showed has nothing to do with baud rate, it controls pin muxing. Many microcontrollers have many more peripheral functions than I/O pins, so the I/O pins need to be mapped to peripherals, and not all connections are possible. For your case, you need to designate particular pins as UART transmit and receive.
I haven't done it myself, but I found a considerable amount of documentation describing that control of pin muxing via sysctl and the proc filesystem was recently replaced with a new system based on Device-Tree. And that as a result virtually all existing examples are broken. Worse, there may not even be a working device-tree-based equivalent for some commands.
As far as setting the baudrate, you would normally use cfsetispeed()
and cfsetospeed()
from termios.h
, as described in the Unix specification.