Introduction
After building my OpenElec media box I purchased another Raspberry Pi 2 that I had planned to either turn into an ADS-B receiver or a weather station data logger.
After a bit of thought I decided that a Pi Zero would be more suitable for the weather station logging and the ADS-B receiver would require the setting up of another antenna which I don’t have space for. I have shelved these projects for the time being.
The Plan
To see how small I could build a data mode decoder running flgigi with appliqué sound card and small LCD for portable operation.
Feasibility
A quick google revealed that it should be well within the capabilities of the Pi 2.
An obvious prerequisite for data modes is to have both a microphone/line in input for decoding and a line out output with reasonable fidelity for modulating the transmitter.
The Raspberry Pi on all versions has neither of these features for reasons of cost and simplicity. Any soundcard will therefore be an external device connected either through one of the USB ports or the GPIO pins. To keep things compact I searched for suitable sound card that utilised the GPIO pins.
While there are a number of Hardware Attached on Top (HAT) options for HiFi grade cards for the Pi, the options for such soundcards with a microphone/line in input for the Raspberry Pi are somewhat limited.
The only such card that I found was a Cirrus Logic (formerly Wolfson) device from Element 14. Be warned though; support forums are awash with complaints about how poorly the device is supported and that drivers don’t work properly. However, the very nature of Open Source Software means that there is always someone willing to put in the effort and dedication to make things work and this card is no exception with support being provided by Matthias “Hias” Reichl at http://www.horus.com/~hias/cirrus-driver.html
Encouraged by this level of support I went and purchased the card and will document in subsequent updates my success or otherwise in integrating the card.
Next in the search was an LCD with HDMI input. I very quickly narrowed it down to the two devices from http://www.waveshare.com :
7inch HDMI LCD (C) 1024×600 HDMI USB Not only Pi 165 x 107 Capacitive
10.1inch HDMI LCD (H)1024×600 HDMI USB Not only Pi 257 x 162 Capacitive
With the added bonus of being touch sensitive, I chose the 7″ display as a trade off between compactness and readability. Smaller displays are available but the size and lower resolution may make the relatively “busy” fldigi display difficult to read.
Proposed Architecture
The initially proposed architecture is shown in the diagram below:
Interfacing the Display
Entries for config.txt file
Parameter |
Definition |
max_usb_current=1 |
When adding this line the USB power manager will change its output current limit (for all 4 USB ports combined) from 600mA to double that, 1200mA. |
hdmi_group=2 |
Set monitor mode to DMT |
hdmi_mode=1 |
Set monitor resolution to 640 x 350 85 Hz |
hdmi_mode=87 |
Custom mode defined by the following parameter |
hdmi_cvt =1024 600 60 6 0 0 0 |
Creating custom HDMI Modes: hdmi_cvt=<width> <height> <framerate> <aspect> <margins> <interlace> <rb> width width in pixels height height in pixels framerate framerate in Hz aspect aspect ratio 1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10, 6=15:9 margins 0=margins disabled, 1=margins enabled interlace 0=progressive, 1=interlaced rb 0=normal, 1=reduced blanking |
Provided that you have Rev v2.1 of the LCD this is the most straightforward bit of the entire build. Support for the LCD and the touchscreen are built into the Raspbian Jessie kernel. I’ve no idea whether this is true of Wheezy or not.
- Transfer Raspbian Jessie to microSD card using Win32 disk imager.
- Connect Pi using existing monitor.
- Insert microSD card and boot Pi
- Make changes to /boot/config.txt documented above plus any others that need to be made.
- Save changes to config.txt
- Shutdown Pi.
- Replace existing monitor with 7 inch LCD making necessary connections
- Switch Pi back on and check operation.
Optional step would be to shutdown Pi at this point and backup the SD card.
Interfacing Cirrus Logic Audio Card
Grab the sources from http://www.horus.com/~hias/cirrus-driver.html using
$ cd ~ $ git clone --depth 1 https://github.com/CirrusLogic/rpi-linux $ cd rpi-linux
Now follow instructions on https://www.raspberrypi.org/documentation/linux/kernel/updating.md
It is probably a very good idea to run the following commands first to ensure that the latest firmware and software updates have been applied:
$ sudo rpi-update $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get dist-upgrade
Add missing dependencies
$ sudo apt-get install bc
Type the following commands:
$ KERNEL=kernel7 $ make bcm2709_defconfig $ make -j4 zImage modules dtbs
Go and do something else for a few hours…I left the compile to run overnight and it was complete by the time I checked again in the morning.
Type the following commands:
$ sudo make modules_install $ sudo cp arch/arm/boot/dts/*.dtb /boot/ $ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ $ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ $ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img
Follow the rest of the process documented by Matthias’ excellent website
Edit the /boot/config.txt file
$ sudo nano /boot/config.txt
And add the following lines to enable the Cirrus Logic card driver
dtoverlay=rpi-cirrus-wm5102 dtoverlay=i2s-mmap
Create the file cirrus.conf in /etc/modprobe.d
$ sudo nano /etc/modprobe.d/cirrus.conf
and add the following lines:
softdep arizona-spi pre: arizona-ldo1 softdep spi-bcm2708 pre: fixed softdep spi-bcm2835 pre: fixed
Download and install “usecase” scripts
$ wget http://www.horus.com/~hias/tmp/cirrus/usecase-scripts.tgz $ mkdir bin $ cd bin $ tar zxf ../usecase-scripts.tgz
Note: You have to start the appropriate scripts before you can use the card. For example:
$ ./Reset_paths.sh -q $ ./Playback_to_Lineout.sh -q $ ./SPDIF_playback.sh -q $ ./Record_from_lineIn.sh -q
Connect your headphones to the 3.5 mm headset jack, run the appropriate usecase script and start the music player of your choice. If all is well you should hear HQ audio.
Take snapshot of SD card.
Build Dependencies
Open a terminal window and edit /etc/apt/sources.list
$ sudo nano /etc/apt/sources.list
And delete the “#” at the start of the line deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
Save using ^o and Exit ^x
Update the apt repository data and install The Free Type development library libxft-dev. This library is needed for fldigi (and any other fltk application) to produce nicely rendered fonts on the computer screen.
$ sudo apt-get update $ sudo apt-get install libxft-dev
This will automatically add a number of dependent packages:
libfontconfig1-dev libpthread-stubs0-dev libxdmcp-dev x11proto-input-dev libx11-doc xorg-sgml-doctools x11proto-core-dev x11proto-render-dev libxrender-dev libxau-dev x11proto-kb-dev libxcb1-dev libx11-dev libxft-dev
Other dependencies are required and the easiest way to get them is to run:
$ sudo apt-get build-dep fldigi
This will download a few things that we don’t need and can safely delete as we are going to compile the software separately for better performance.
$ sudo apt-get remove libfltk-forms1.3 $ sudo apt-get remove libfltk-gl1.3 $ sudo apt-get remove libfltk-images1.3 $ sudo apt-get remove libfltk1.3-dev
Removing the above will likely give you a message about “orphaned packages” that are no longer needed. These can be removed with the command:
$ sudo apt-get autoremove
Build fltk from source
$ cd ~ $ wget fltk.org/pub/fltk/1.3.3/fltk-1.3.3-source.tar.gz $ tar zxvf fltk-1.3.3-source.tar.gz $ cd fltk-1.3.3 $ ./configure --enable-xft --enable-threads --enable-x11 --enable-shared $ make -j4 $ sudo make -j4 install $ sudo ldconfig
Note: -j4 switch utilises all four cores of the ARM processor. Don’t use “sudo” on “make”
Build hamlib from source
$ cd ~ $ wget downloads.sourceforge.net/project/hamlib/hamlib/3.0/hamlib-3.0.tar.gz $ tar zxvf hamlib-3.0.tar.gz $ cd hamlib-3.0 $ ./configure $ make -j4 $ sudo make -j4 install
Build portaudio from source
$ cd~ $ wget portaudio.com/archives/pa_stable_v19_20140130.tgz $ tar zxvf pa_stable_v19_20140130.tgz $ cd pa_stable_v19_20140130 $ sudo apt-get install libasound-dev $ ./configure $ make -j4 $ sudo make -j4 install
Note: The sudo apt-get line ensures that ALSA development libs are installed.
Build fldigi from source
$ cd ~ $ wget https://sourceforge.net/projects/fldigi/files/fldigi/fldigi-3.23.14.tar.gz $ tar zxvf fldigi-3.23.14.tar.gz $ cd fldigi-3.23.14 $ ./configure $ make -j4 $ sudo make -j4 install
Build flrig from source
$ cd ~ $ wget https://sourceforge.net/projects/fldigi/files/flrig/flrig-1.3.26.tar.gz $ tar zxvf flrig-1.3.26.tar.gz $ cd flrig-1.3.26 $ ./configure $ make -j4 $ sudo make -j4 install
Final tweaks
Add pulse audio volume control, Tight VNC Server and a virtual keyboard with xvkbd. Set the usecase to permit audio to the LineIn and LineOut connectors
$ sudo apt-get install pavucontrol tightvncserver xvkbd $ pavucontrol --start && tightvncserver $ cd ~/bin $ ./Reset_paths.sh $ ./Playback_to_Lineout.sh $ ./Record_from_lineIn.sh
Now, with the appropriate Tight VNC client for your OS you can control your Raspberry Pi remotely if you want.
fldigi, flrig etc. are accessed from the menu under “Internet”
Footnotes
After compiling the kernel for the audio card support, the remainder of the task should take only another two to three hours to complete.
Although some prior knowledge of Linux and the command line would be useful I don’t think that it is a pre-requisite provided the “recipe” presented above is followed to the letter.
I was pleasantly surprised when I connected the CI-V cable to the USB port and found that the converter was recognised without any problems and flrig controlled the radio without any issues.
Pulse Audio was it’s usual pain in the proverbial and it reminded me why I bin it by default on my Linux installations. Unless you need a sound server capability use Portaudio which just works.
I hadn’t expected to have to install flrig for radio control but I found rig-cat unreliable and hamlib was still beta for the IC-7000, which for a 12 year old radio I found somewhat surprising. It wasn’t that hamlib didn’t work, it did, it just didn’t support control of the filter bandwidth that I could see.
With the standard Raspbain Jessie image and when all the compiling and installation is finished an 8 Gb SD card will be left with about 650 Mb of free space. This may not be enough if you plan to capture audio files for later replay or use the Pi for functions other than a dedicated decoder.
In this case a 16 Gb SD card or greater might be more useful or if you think that you are not going to need the source code any longer you can delete the directories from the home directory to free up some space.
To delete the directory trees run the following command in the required directory:
$ rm -rfv *
Run this command with caution. Above all else be certain that you are in the correct directory when you run it. The command will indiscriminately remove files and directories (rm) recursively (r), force ignore non existent files and arguments without prompting (f) and show you verbosely (v) everything (*) being deleted in the directory.
Progress to date