Configuring and customizing a Raspberry Pi
Most of these instuctions are issued using the command line. To open a terminal window, open LXTerminal from the desktop.To edit files, nano is a typical editor that is already installed in many Linux distributions. Ctrl-o is used to save changes and Ctrl-x to exit nano.
Steps:
Install/configure Linux environment
- download and install SD card image
- configure Ethernet/Wi-Fi
- expand filesystem
- update distribution
- configure country, time/date, time zone and keyboard
- configure GPIO serial port for DV hardware
Install/configure G4KLX software
- klxupdate scripts
- configure scripts for autostart
- DL5DI installer
- build G4KLX software
- installing Python and GPIO packages
Install/configure Arduino software
- download and install Arduino development environment
- patching the Arduino serial library
- installing the Arduino DTR (reset) patch
- running/configuring Arduino software
- programming the Arduino 328 bootloader
- download and install Arduino firmware
- mounting the DV boards on the Pi
- backup SD card
Download SD card image
The folks at Western DStar have put together SD card image files with all of the G4KLX software installed and mostly configured. This means all you have to do is to download the image file, copy it to your SD card and make some minor configuration changes. Look for "‘Autostart’ Raspberry PI image for D-StarRepeater". The other associated applications such as DVAPRepater, GMSKRepeater and DVRepater are being retired and have been replaced by DStarRepeater. The changes needed to support the RasPi DV and DV for Arduino boards are already included in the current DStarRepeater software. For Windows users, copy the image file to the SD card using Win32DiskImager. Have a look at the Quick Start Guide for more information.-or-
Download the "New Out of Box Software - NOOBS" (offline and network install) image from Pi Downloads and copy it to your SD card. Follow the instructions on the download page. It is HIGHLY recommended that you use the "offline" version instead of the "network" version because of all the extra manual steps that are required.
Once you have copied the image to the SD card, insert it into your Pi and boot.
If you have chosen the NOOBS install method, you may notice that Wolfram has also been installed. It takes a lot of space on the SD card. If you want to unintall it, use the following command:
sudo apt-get purge wolfram-engine
Ethernet/Wi-Fi setup
If you are hooking up Ethernet directly to you Pi, then you can skip these steps. If you are configuring Wi-Fi for the first time, there are two options; configuring via the command line and configuring via the GUI.Expand file system on SD Card
The SD card image is sized for a 2 GB card. So, if you are using an SD card with a greater capacity, you may find that only 2 GB is available. If this is the case, then to gain more free space, the partitions must be resized. The Fedora Remix and the BerryBoot will automatically resize the partitions on the mounted card during the first boot. The Debian , OpenSuSe and Rasbian images won't, so you'll have to do it manually. The easiest way is to use the tool RPi raspi-config.
sudo raspi-config
select "Expand Filesystem" option.Updating the operating system
The software installed on the Pi needs to be updated.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo apt-get dist-upgrade
Configuring keyboard for country
The Western DStar images are set up for the UK by default. If you don't live in the UK you may find that the key mapping is incorrect and the characters display don't match what you expect. To fix this you can either use the GUI tool, or you can manually edit the configuration file.To change the configuration via the command line edit the /etc/default/keyboard file:
sudo nano /etc/default/keyboard
and find this line:
XKBLAYOUT=”gb”
then change the gb to us (this assumes you want a us mapping, if not replace the gb with the two letter code for your country)
and reboot your machine.If it pauses for a long time during the keyboard mapping stage, enter the following at the command line:
sudo setupcon
Your next reboot should be much faster.Updating time zone
The timezone can be updated via the dpkg-reconfigure tool. Select your appropriate timezone from the menus.
sudo dpkg-reconfigure tzdata
Reconfiguring the GPIO serial port
By default the GPIO serial port is configured as tty console port. This means you can use it to log into the Pi much like opening a terminal window when running the GUI. To allow applications to use the serial port, getty must be disabled (the program that displays login screen) and the tty port must not be configured.To disable getty, edit the file /etc/inittab
sudo nano /etc/inittab
and find this line:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
then comment it out by adding # in front of it.
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
To prevent the Raspberry Pi from sending out data to the serial ports when it boots, edit the /boot/cmdline.txt
sudo nano /boot/cmdline.txt
and find the string "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
then delete just that string so the line looks like this. Leave the rest of the file untouched.
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Installing/updating DStarRepeater and ircDDBGateway via klxupdate scripts
Download the scripts written by Brian GW6WTK from Western D-Star.
wget http://www.westerndstar.co.uk/KLXstuff/klxupdate
sudo install -g bin -o root -m 0775 ./klxupdate "/usr/local/bin"
sudo install -g bin -o root -m 0775 ./klxupdate "/usr/local/bin"
Once you have successfully completed these steps you can delete the install files, so:
sudo rm klxupdate
The updater should now be installed. To update/install the DStarRepeater application:
sudo klxupdate repeater
To update/install the ircDDB Gateway application.
sudo klxupdate gateway
To configure the DStarRepeater application:
sudo dstarrepeaterconfig
To configure the ircDDB Gateway application.
sudo ircddbgatewayconfig
The basic settings that need to be configured can be found here.
Installing/updating DStarRepeater and ircDDBGateway via DL5DI installer
Learn about the builds maintained by Hans DL5DI from here.Next, download and run the installer with this series of commands.
sudo curl ftp://141.75.245.226:8021/raspbian/opendv.list -o /etc/apt/sources.list.d/opendv.list
cd /tmp
sudo curl -O -L ftp://141.75.245.226:8021/debian/dl5di.pk
sudo apt-key add dl5di.pk
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install repeater
sudo apt-get install ircddbgateway
sudo ircddbgw_conf
sudo repeater_conf
The last two commands run the configuration tools. Answer all the questions and the script will save the configuration files.cd /tmp
sudo curl -O -L ftp://141.75.245.226:8021/debian/dl5di.pk
sudo apt-key add dl5di.pk
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install repeater
sudo apt-get install ircddbgateway
sudo ircddbgw_conf
sudo repeater_conf
Have a look here for an example of how to answer the questions during the configuration.
Autostart ircDDBGateway/DStarRepeater
Some of the installers automatically set up the applications to run when the Pi boots. If the installer you chose does not set the apps up to automatically start when the Pi is booted, there are two files to be created. In each file there is a link to an icon to be used for the applications on the desktop. Look in the /usr/share/pixmaps folder to find one that is available for you to use. The openbox.xpm file is just an example file and may not be available on your machine.If it doesn't already exist, create a folder called /home/pi/.config/autostart
sudo mkdir /home/pi/.config/autostart
Create a new ircDDBGateway autostart file:
sudo nano /home/pi/.config/autostart/start_gateway.desktop
It assumed that the ircddbgateway executable is installed on the machine in a folder covered by the search path. If not, you may have to add the full path to the executable. Copy/paste this code into the file:
[Desktop Entry]
Name=start_gateway
Type=Application
Icon=/usr/share/pixmaps/openbox.xpm
Exec=sudo ircddbgateway -gui
Name=start_gateway
Type=Application
Icon=/usr/share/pixmaps/openbox.xpm
Exec=sudo ircddbgateway -gui
Create a new DStarRepeater autostart file:
sudo nano /home/pi/.config/autostart/start_modem.desktop
It assumed that the dstarrepeater executable is installed on the machine in a folder covered by the search path. If not, you may have to add the full path to the executable. Copy/paste this code into the file:
[Desktop Entry]
Name=start_modem
Type=Application
Icon=/usr/share/pixmaps/openbox.xpm
Exec=sudo dstarrepeater -gui
Name=start_modem
Type=Application
Icon=/usr/share/pixmaps/openbox.xpm
Exec=sudo dstarrepeater -gui
Add shortcuts on desktop
Copy the new files from .config/autostart into Desktop folder
cp /home/pi/.config/autostart/start_gateway.desktop /home/pi/Desktop/start_gateway.desktop
cp /home/pi/.config/autostart/start_repeater.desktop /home/pi/Desktop/start_repeater.desktop
cp /home/pi/.config/autostart/start_repeater.desktop /home/pi/Desktop/start_repeater.desktop
Building G4KLX software DStarRepeater & ircDDBGateway
The G4KLX software can be compiled using source code from either the SVN server or from the releases posted in the pcrepeatercontroller and ircDDBGateway Yahoo groups in the "Files" section under "Beta".There is another version of build instructions on the dstar101.com website. There are minor issues with these instructions when building for Linux on the Pi, so it might be easier to use the following instructions.
The build instructions from G4KLX can be found on the SVN server: BUILD.txt
First, the libraries wxGTK, libusb, wiringPi and PortAudio need to be installed.
Install wxGTK and libusb-1.0
sudo apt-get install libwxgtk2.8-dev libwxgtk2.8-dbg
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libusb-1.0-0-dev
To install wxGTK and libusb from scratch, you need to follow the instuctions at: wxGTK and libusb-1.0.
Install the PortAudio libraries. The two apt-get calls need to be done separately and can't be combined into a single step.
sudo apt-get install libportaudio-dev
sudo apt-get install portaudio19-dev
sudo apt-get install portaudio19-dev
Alternatively, Portaudio can be compiled from scratch. Download, build and install the latest stable PortAudio from www.portaudio.com
cd /home/pi/g4klx
curl -O -L http://portaudio.com/archives/pa_stable_v19_20140130.tgz
gzip -d pa_stable_v19_20140130.tgz
tar -xvfz pa_stable_v19_20140130.tar
cd portaudio
sudo ./configure
sudo make
sudo make install
curl -O -L http://portaudio.com/archives/pa_stable_v19_20140130.tgz
gzip -d pa_stable_v19_20140130.tgz
tar -xvfz pa_stable_v19_20140130.tar
cd portaudio
sudo ./configure
sudo make
sudo make install
Download, build and install the wiringPi GPIO library.
cd /home/pi/g4klx
git clone git://git.drogon.net/wiringPi
cd /home/pi/g4klx/wiringPi
./build
git clone git://git.drogon.net/wiringPi
cd /home/pi/g4klx/wiringPi
./build
To check out the source code, the SVN application needs to be installed.
apt-get install subversion
Now, download and build DStarRepeater and ircDDBGateway executables.
sudo mkdir /home/pi/g4klx
cd /home/pi/g4klx
sudo svn checkout svn://svn.berlios.de/opendv/trunk/ircDDBGateway
cd /home/pi/g4klx/ircDDBGateway
sudo make
sudo make install
cd /home/pi/g4klx
sudo svn checkout svn://svn.berlios.de/opendv/trunk/DStarRepeater
cd /home/pi/g4klx/DStarRepeater
sudo make
sudo make install
cd /home/pi/g4klx
sudo svn checkout svn://svn.berlios.de/opendv/trunk/ircDDBGateway
cd /home/pi/g4klx/ircDDBGateway
sudo make
sudo make install
cd /home/pi/g4klx
sudo svn checkout svn://svn.berlios.de/opendv/trunk/DStarRepeater
cd /home/pi/g4klx/DStarRepeater
sudo make
sudo make install
Installing Python and GPIO packages
In order for some of the other configuration steps to work, Python needs to be installed if it has not been already. The Python GPIO drivers also need to be installed.
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
sudo apt-get install python-rpi.gpio
Installing the Arduino software development environment
First start by installing the standard Arduino IDE:
sudo apt-get install arduino
There is a video on Youtube that shows the basics of installing the Arudino software.
Patching the Arduino serial library
DStar audio data coming over the Internet to the G4KLX software tends to have widely varying latency. In the cases when the data comes earlier than expected, the serial port FIFOs fill more quickly. When the data comes later than expected, the FIFOs empty more quickly. Based on limited experiments, the Arduino default FIFO size of 64 bytes is not large enough to prevent overflows. The FIFO size needs to be expanded to 128 bytes. Instructions on how to change the buffer size are based on instructions on the Hobbytronics website.To change the buffer size, edit the HardwareSerial.cpp file
sudo nano /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp
and find this line
#define SERIAL_BUFFER_SIZE 64
then modify the buffer size to 128.
#define SERIAL_BUFFER_SIZE 128
Installing the Arduino DTR (reset) patch
A normal Adruino board includes the pieces of hardware needed to put the Atmel chip into bootloader mode. This is done by toggling the RESET line of the chip and then starting the programming mode within a short amount of time. If the bootloader doesn't see the programming commands on the serial pin, then it exits boot mode and starts running the normal code programmed on the chip. One of the most common ways of signaling the reset from the host computer is to use the DTR pin on the serial port. The Pi's serial port on the GPIO ping doesn't have a DTR signal so another trick has to be used. In this case any spare GPIO pin is used to behave something like a DTR.To avoid having to patch the AVRDUDE (software Arduino uses to program chip) program, a patch can be installed to watch for the AVRDUDE trying to toggle the non-existant pin and then force the GPIO pin to toggle. A lot more details can be found here and here and here and here and here and here.
wget https://raw.github.com/SpellFoundry/avrdude-rpi/master/autoreset
wget https://raw.github.com/SpellFoundry/avrdude-rpi/master/avrdude-autoreset
wget https://raw.github.com/SpellFoundry/avrdude-rpi/master/avrdude-autoreset
The autoreset script needs to be modified to use the pin that is used on the RasPi DV board for reset.
sudo nano autoreset
find the line specifying the mode
GPIO.setmode(GPIO.BCM)
and change the mode to BOARD so that the pin numbers match the standard Raspberry Pi pin numbers instead of having to translate using the BCM chip pin numbers.
GPIO.setmode(GPIO.BOARD)
find the line defining the pin number
pin = 22
and change the pin number to 23.
pin = 23
Next the new patched files need to be installed using the following commands.
sudo cp autoreset /usr/bin
sudo cp avrdude-autoreset /usr/bin
sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
sudo chmod 755 /usr/bin/avrdude-autoreset
sudo chmod 755 /usr/bin/autoreset
sudo cp avrdude-autoreset /usr/bin
sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
sudo chmod 755 /usr/bin/avrdude-autoreset
sudo chmod 755 /usr/bin/autoreset
Once these patches have been installed, the Arduino software will think it is running the original avrdude software but instead will be running a script which forces the GPIO pin to toggle and then runs the original avrdude.
Running/configuring Arduino software
The RasPi DV board using an Atmega 328 chip on board to talk to the GMSK chip. The design is based on the UNO version of the Arduino board. The Arduino software needs to be configured to the correct type of board and for the correct serial port. Run the Arduino software and use the menus to configure the board.
sudo arduino
Under Tools->Board select "Arduino UNO"
Under Tools->Serial Port select /dev/ttyACM0
Programming the Arduino 328 bootloader
Before you can upload programs to the Arduino 328 chip, a bootloader has to be installed. The 6 pin ISP header on the RasPi DV board is used for this programming. By far the easiest way to program the bootloader is to use a USBasp board. These boards are available from many online stores including eBay for as little as $3 including shipping. For more information on the boards visit the main USBASP website.Since programming the bootloader works best under Windows, you will need to load the device drivers. This Protostack website has the complete instructions on how to load the drivers.
If you reall want to try the USBasp board on the Pi, you will need to set up udev rules for the board before plugging it into the USB port.
sudo nano /etc/udev/rules.d/50-embedded_devices.rules
copy and paste the following two lines into the new rules file
# USBasp Programmer rules http://www.fischl.de/usbasp/
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="users", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="users", MODE="0666"
save and quit. reboot the pi, switch the pi off and on, unplug the programmer and plug it back in again, and restart udev for luck:
sudo /etc/init.d/udev restart
Once the Windows drivers/Linux udev rules are installed, run the Arduino software.
Under Tools->Programmer select "USBasp"
Then under Tools->Board select UNO
Under Tools select Burn Bootloader
Programming the Arduino 328 chip
The Adruino software is used to program the firmware onto the 328 chip. Download the dvmega source code from Guus PE1PLM's websiteand unzip the files into a folder called "dvmega"
Next, run the Arduino software
sudo arduino
Then under Tools->Open select the dvmega.ino file
Then under Tools->Board select UNO
Then under Tools->Programmer select AVRISP mkII
Then under Tools->Port select the serial port where the Arduino is installed
More information about programming the Arduino can be found here.
Next, click on the upload button (round right arrow button) to compile and upload the project to the chip.
Mounting GMSK board to Pi
The boards plugged into the GPIO connector should be reinforced using the mounting holes. A non-conductive nylon standoff and nylon nut/screw should be used. It is a bad idea to use conductive materials for the standoff. The standoff needs to be about 7/16" tall. Here is an example of a 1/2" nylon standoff from Frys. It would need only a small amount of trimming to get it down to the 7/16" height. Here are examples of a nylon screw and nylon locknut also from Frys.Backup SD card
It is a very good idea to backup your configuration before expanding the file system to fit the card. It has taken a lot of time to get to this point and it is aways good to have a backup. The SD card can be backed up on a separate Windows or Linux machine.Linux - confirm the device name for your storage and edit the line accordingly
dd if=/dev/sda of=/dev/usbxxx/backup.bin
Windows
When using Windows, the win32diskimager software works best. It needs to be run as administrator.
- select image file name to store backup
- select sd card drive letter
- select "Read"
- When it is done then select "Exit"
All text and images on ki6zum.com are copyright (c) 2010-2014 and may not be reproduced in any form without written permission.