Tenderlove Making

Enabling ttyO1 on BeagleBone

I’m really just making this post because I will eventually forget how to do this, and maybe it will come in handy to others as well.

Hardware

I’ve got an MSP430 reading temperature and humidity information from an RHT03 sensor. It sends the data over a serial port, and I’d like to read that data on my BeagleBone.

I have P1.1 and P1.2 on the launchpad connected to pin 24 and 26 on the BeagleBone. Pin 24 and 26 map to UART1, so I need to enable UART1 on the BeagleBone so it will show up in /dev.

Software

The BeagleBone is running Angstrom v2012.12, and I believe this is the same version that is on the BeagleBone Black, so it should work there as well:

root@beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Tue Jun 18 02:11:09 EDT 2013 armv7l GNU/Linux
root@beaglebone:~# cat /etc/version 
Angstrom v2012.12
root@beaglebone:~#

Configuration

To enable the UART, you just need to do this:

root@beaglebone:~# echo BB-UART1 > /sys/devices/bone_capemgr.*/slots

After running that, there should be a message in dmesg about enabling the UART, and /dev/ttyO1 should be available.

Where does BB-UART1 come from?

“BB-UART1” is the name of a device cape, and it seems Angstrom already ships with a bunch of these. If you look under /lib/firmware, there will be a bunch of them. “BB-UART1” came from the file /lib/firmware/BB-UART1-00A0.dts. If you don’t have that file, then echoing to the slots file will not work.

Enabling at boot

I want the tty to be available every time I boot the machine. Angstrom doesn’t use normal System V init scripts, so you have to do something different. You need two files, and a symbolic link.

First I created /usr/local/bin/enable_uart1, and it looks like this:

root@beaglebone:/# cat /usr/local/bin/enable_uart1 
#!/bin/sh

echo BB-UART1 > /sys/devices/bone_capemgr.7/slots

root@beaglebone:/#

(make sure enable_uart1 is executable).

Then I created /lib/systemd/enable_uart1.service, and it looks like this:

root@beaglebone:/# cat /lib/systemd/enable_uart1.service
[Unit]
Description=Enable UART1
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/enable_uart1

[Install]
WantedBy=multi-user.target
root@beaglebone:/#

Then I created a symbolic link:

root@beaglebone:/# cd /etc/systemd/system/
root@beaglebone:/# ln /lib/systemd/enable_uart1.service enable_uart1.service

Then I loaded and enabled the service:

root@beaglebone:/# systemctl daemon-reload
root@beaglebone:/# systemctl start enable_uart1.service
root@beaglebone:/# systemctl enable enable_uart1.service

After running these commands, /dev/ttyO1 should be available even after rebooting the machine.

(Most of this systemd information came from this blog post)

Finish

Next I need to get wifi working, and my BeagleBone will be perfect for real-time monitoring of Sausage Box One.

« go back