In this post, I'll be talking about three things in general:

  • Getting a new image, updating it and fixing things that are broken.
  • Installing RTL-SDR which will be used for receiving FM transmissions and others.
  • Testing the installation by streaming raw audio over the network.


System Setup

I spent around a week playing around with the components, got myself a micro HDMI to HDMI adapter and basically tried to see what the system can do. I like starting projects with a brand new OS so that there are no weird software collisions. For Windows people, there is a Getting Started guide which also covers how to update, there is no need to cover it again. If you are using Linux, steps are as following (if you don't know them already):

  • Download the latest Beaglebone Black eMMC flasher Angstrom image from - latest-images.
  • Unzip it by using unxz BBB-eMMC-flasher-2013.09.04.img.xz. You will get a file with .img extension only. If xz-utils are not installed, you have to install them.
  • Insert SD card to your machine and run dmesg to find the device filename of your SD card. Mine is almost always sdb, but it's nice to be sure and on the safe side.
  • Depending on the system, your system may have mounted the partition automatically. SD cards have just a single partition if you're using a brand new card. But it may have more if you used the same SD card in another embedded system. dmesg output usually contains something like sdb1 at the end in this case. Use sudo umount /dev/sdb1 to unmount it. If there are sdb1 and sdb2, you can use sudo umount /dev/sdb{1,2} to unmount both of them.
  • Now you can write the image file to the SD card. Use dd for this. In my case, the command was sudo dd if=BBB-eMMC-flasher-2013.09.04.img of=/dev/sdb. Remember, you are not writing to the partition but to the entire card! Image file actually contains more than one partitions.
  • Eject the card, plug it to your Beaglebone Black. Then hold down the USER/BOOT button and plug in the 5V adapter. LEDs will start flashing, wait until all 4 USER LEDs are lit solid. This will take a while, so do something productive. Or not productive.
  • When all 4 USER LEDs are lit, unplug the adapter, remove SD card and power it back up again. It's ready to use.

After this, you have a brand new system. It even works with the LCD4 cape out of the box. But If you look at the image name, it is a pretty old image and there are packages need upgrading. For this, I plug in the Ethernet cable in and power it up. I can see it got a IP from my router, so I SSH into it by using the username root and no password. Angstrom uses opkg as it's package manager so you just run

opkg update
opkg upgrade


You have to wait a while again as it upgrades many packages. Again "This will take a while, so do something productive. Or not productive." After it's done, you can reboot your system. Connect to it again via SSH. If you have an LCD4 cape attached, you'll see that the autologin is disabled. Basically you'll see the login screen asking you to select a user.



This is something you may want to fix. You have to open /etc/gdm/custom.conf with vi and insert the following under [daemon]



This will login as root after you reboot your system.

You may also notice the date and time is not correct. Upgrade procedure sets up the ntp client so we get a recent time but if your location is not set correctly, it may be off a few hours. I live in Tokyo, so I issued the following commands to set up the timezone

root@beaglebone:~# cd /etc/
root@beaglebone:/etc# rm localtime
root@beaglebone:/etc# ln -s /usr/share/zoneinfo/Asia/Tokyo localtime
root@beaglebone:/etc# ls -al localtime
lrwxrwxrwx 1 root root 30 Mar  6 19:50 localtime -> /usr/share/zoneinfo/Asia/Tokyo


Now date command gives you the correct time. List /usr/share/zoneinfo and it's subdirectories to find a suitable timezone. Your system is now set.


Install RTL-SDR

For this, I followed the guide at RTL-SDR wiki. You need to install cmake and libusb-1.0-dev packages. You can do this with

root@beaglebone:~# opkg update
root@beaglebone:~# opkg install cmake libusb-1.0-dev


After this just run the following commands to install RTL-SDR

root@beaglebone:~# git clone git://
root@beaglebone:~# cd rtl-sdr/
root@beaglebone:~/rtl-sdr# mkdir build
root@beaglebone:~/rtl-sdr# cd build/
root@beaglebone:~/rtl-sdr/build# cmake ../
root@beaglebone:~/rtl-sdr/build# make
root@beaglebone:~/rtl-sdr/build# make install
root@beaglebone:~/rtl-sdr/build# ldconfig


After this plug in your SDR dongle and test it with rtl_test

root@beaglebone:~# lsusb
Bus 001 Device 002: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@beaglebone:~# rtl_test
rtl_test: error while loading shared libraries: cannot open shared object file: No such file or directory


OOOPS! What is it? Apparently in Angstrom the library path for librtlsdr is not set properly during install so ldconfig does nothing. You have two solutions, one is to run

export LD_LIBRARY_PATH=/usr/local/lib/

each time you login or you can run

echo "/usr/local/lib/" > /etc/

which sets up the library path during each boottime. I went with the second choice. Now if I run rtl_test

root@beaglebone:~# rtl_test
Found 1 device(s):
  0:  Realtek, RTL2841UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
lost at least 4 bytes
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 0
rtlsdr_demod_write_reg failed with -1
Segmentation fault


I stopped it with CTRL-C combo, that's the reason for the entries after line 15. Now we are set to test our FM streaming.


Receive and Stream with RTL-SDR

rtl_fm comes with RTL-SDR and can put the data on STDOUT at a given sample rate. Also there is a real nice program called netcat which can be used for many many things, including writing client-server type applications on the shell. So first install netcat

root@beaglebone:~# opkg install netcat


I use rtl_fm to tune to a certain frequency, then pipe it to netcat. netcat is in listen mode so it'll wait for incoming connections and if a client is connected, it'll push the data. NHK radio is on 82.5 MHz so I tune to it.

root@beaglebone:~# rtl_fm -f 82.5M -s 44.1k - | netcat -l -p 8080
Found 1 device(s):
  0:  Realtek, RTL2841UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 82753575 Hz.
Oversampling input by: 23x.
Oversampling output by: 1x.
Buffer size: 8.08ms
Exact sample rate is: 1014300.020041 Hz
Sampling at 1014300 S/s.
Output at 44100 Hz.


8080 is the port I chose for streaming it, you can change it as you wish. On my laptop with netcat and aplay installed, I can listen to some Japanese radio.

tayken@tayken-labtop:~$ netcat 8080 | aplay -r 44.1k -t raw -c 1 -f S16_LE
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 44000 Hz, Mono
^CAborted by signal Interrupt...


One word of warning is the server will quit if you terminate the client connection with CTRL-C as the messages are sent both ways on netcat. One workaround is to put the server in a while loop so that each time the client sends the exit signal, it starts again. You can do this with

root@beaglebone:~# while true; do rtl_fm -f 82.5M -s 44.1k - | netcat -l -p 8080; done


You'll have to send rapid a few interrupt signals on the server shell to stop it. Here is a network diagram explaining this system. I'm putting it here as I'll be adding another server to this chain for streaming purposes.




In the next post I'll be adding another machine with ffserver running to stream the audio. It'll also have a basic webpage so that I'll get the audio when I click the link.