from rpi Setup dhcp-enabled adhoc dranch@trinnet.net # 06/06/15 - Added link to GPIO to HT schematic # 05/25/15 - added start of Wifi AP mode # 05/20/15 - Added postfix, mailx and logwatch # 11/02/14 - Enable IPv6 # 10/24/14 - Updated logrotated to use bzip2 vs gzip # 10/21/14 - Use logrotate's copytruncate on log files getting redirected output from various processes # - added note on re-enabling the watchdog # 10/19/14 - Added /var/log/auth.log file cleanup # - changed log rotation settings to run daily and also include the packet.log # - increased ram disk from 5m to 20mb # 10/01/14 - ALSA levels and testing the soundcard # 09/28/14 - Added GPSd configuration; Dan tracker section # 04/08/14 - added the changing of the system editor # 03/19/14 - Added rpi-update # 03/10/14 - Added how to update the FBB, FPAC, and AX25 stack from the included scripts # 02/27/14 - Added missing packages section # 09/27/13 - NFS additions; added more URLs on Rpi optimizations # 07/15/13 - Added Additional RAM drive details # 07/08/13 Install image: 1. put blank card to existing working linux machine 2. run dmesg to confirm SD card device - for me, it's /dev/sdb 3. Get The newest F6BVP Rpi image from http://f6bvp.org/AX25_BBS_Node_RaspBerry_Pi_install.html 4. dd if=Rpi_F6BVP_8Go_img of=/dev/sdb bs=2M Add missing packages -- apt-get install rpi-update Update the distro -- apt-get update apt-get dist-upgrade Next, update the RPI's firmware and possibly move to a better, bleeding edge kernel - https://github.com/Hexxeh/rpi-update -- apt-get install rpi-update rpi-update Reboot once complete details are a mix of: http://lcdev.dk/2012/11/18/raspberry-pi-tutorial-connect-to-wifi-or-create-an-encrypted-dhcp-enabled-ad-hoc-network-as-fallback/#comment-640 and http://xmail.selfip.org/wordpress/?p=1 and http://unix.stackexchange.com/questions/44851/setting-up-ad-hoc-in-debian-with-dhcp -- #Setup the RAM Drive per http://blog.a-netz.de/2013/02/ramdisks-for-the-raspberry/ with additions # to make larger virtual drives #ONly use tmpfs when required /etc/fstab -- tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=1m 0 0 tmpfs /var/log tmpfs defaults,noatime,mode=0755,size=20m 0 0 tmpfs /var/lock tmpfs defaults,noatime,mode=0755,size=1m 0 0 - /etc/init.d/prepare-dirs -- #!/bin/bash # ### BEGIN INIT INFO # Provides: prepare-dirs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Required-Start: # Required-Stop: # Short-Description: Create /var/log/nginx directory on tmpfs at startup # Description: Create /var/log/nginx directory on tmpfs at startup ### END INIT INFO DIR=/var/log/lighttp # # main() # case "${1:-''}" in start) # create the /var/log/nginx needed by webserver if [ ! -d ${DIR} ]; then mkdir ${DIR} chmod 755 ${DIR} fi ;; stop) ;; restart) ;; reload|force-reload) ;; status) ;; *) echo "Usage: $SELF start" exit 1 ;; esac -- chmod 755 /etc/init.d/prepare-dirs update-rc.d prepare-dirs defaults 01 99 # --------------------------------------------------------------------------------- # Rpi-based AP Wireless Setup (work in progress): # --------------------------------------------------------------------------------- # Recommended: hostapd and dnsmasq # https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint # Using Hostapd and ISC dhcpd # https://learn.adafruit.com/downloads/pdf/setting-up-a-raspberry-pi-as-a-wifi-access-point.pdf # Confirm your Wifi USB device is seen: dmesg | less -- [667667.424884] usb 1-1.2.1: New USB device found, idVendor=7392, idProduct=7811 [667667.424928] usb 1-1.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [667667.424949] usb 1-1.2.1: Product: 802.11n WLAN Adapter [667667.424968] usb 1-1.2.1: Manufacturer: Realtek [667667.424998] usb 1-1.2.1: SerialNumber: 00e04c000001 [667668.197127] usbcore: registered new interface driver rtl8192cu -- ifconfig wlan0 | less -- wlan0 Link encap:Ethernet HWaddr 80:1F:02:AA:29:CA UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) -- #If you use a Wifi USB dongle using the Realtek RTL8192cu (aka RTL8188CUS) chipset, you need to read this # (tiny Edimax EW-7811n, etc) # http://blog.sip2serve.com/post/38010690418/raspberry-pi-access-point-using-rtl8192cu # # this URL gives a more supportable approach: https://communities.intel.com/thread/60690 # # Specifically, as of 06/07/15, hostapd 1.0-3+deb7u2 is broken for the RTL8192 chip so we need # to update the binary #Install the required software apt-get update apt-get install hostapd #If using a realtek 8192 device, you need an alternative hostapd daemon: sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.orig # this will NOT fit on the Rpi's RAM drive cd /var/tmp wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip #alternatives # wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip # http://willhaley.com/willhaley/blog/raspberry-pi-hotspot-ew7811un-rtl8188cus/ # --> errors with # rtl871x_set_hidden_ssid_ops # ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument # wlan0: Setup of interface done. unzip adafruit_hostapd_14128.zip sudo mv hostapd /usr/sbin sudo chmod 755 /usr/sbin/hostapd rm adafruit_hostapd_14128.zip #Next, confirm it can be interrogated -- sudo iwconfig rose5 no wireless extensions. rose2 no wireless extensions. wlan0 unassociated Nickname:"" Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Encryption key:off Power Management:off Link Quality:0 Signal level:0 Noise level:0 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0 -- # Confirm that your Wifi device can act as an AP (not all can!). If this doesn't # report back with a "0", you need a different Wifi USB device # HW identification # https://help.ubuntu.com/community/WifiDocs/MasterMode -- rpi:/etc/ax25# sudo iwconfig wlan0 mode master rpi:/etc/ax25# echo $? 0 -- #Disable it from starting by default - we want to start this # from rc.local to support the DIP switch setting sudo update-rc.d hostapd disable #Update the SysV config startup script sudo vi /etc/default/hostapdA -- DAEMON_CONF="/etc/hostapd/hostapd.conf" -- #Create and Edit the hostapd config zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz > /etc/hostapd/hostapd.conf vim /etc/hostapd/hostapd.conf -- #Wireless device name interface=wlan0 #Wifi device driver depends on your USB device # I'm using the problem Edimax RTL8192 based device #driver=nl80211 driver=rtl871xdrv #SSID announcement for this device ssid=RPi #Specific country youre in country_code=US #limit frequencies to specified country ieee80211d=1 #allow 802.11b too hw_mode=g #select the least used channel channel=11 #How often to send SSID broadcasts beacon_int=100 #allow WPA/WPA2 only auth_algs=1 #If you want to hide your SSID broadcasts, set this to 1 ignore_broadcast_ssid=0 #enable multi-media prioroty wmm_enabled=1 #disassociate remote sessions that are taking on high errors # enable this for better battery life; disable this to keep the link up at all costs #disassoc_low_ack=1 #enable 802.11n ieee80211n=1 #enable WPA2 only wpa=2 #The WPA2 64 charcter HEX key or 8 to 63 character passphrase for your network #wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef wpa_passphrase=YOURPASSPHASE #Use PSK and not EAP wpa_key_mgmt=WPA-PSK #Use AES encryption rsn_pairwise=CCMP #Support high performance wifi ht_capab=[HT40+][HT40-][SHORT-GI-40][RX-STBC1] #Don't refuse association with remote client if they don't support HT Phy negotiation require_ht=0 -- #Note: This configuration does NOT support routing traffic from the Wifi network to a # wired network. It's easy to add but it doesn't do this today # Next, edit the /etc/network/interfaces file -- auto lo eth0 wlan0 iface wlan0 inet static address 10.10.10.1 netmask 255.255.255.0 #allow-hotplug wlan0 -- #Disable Network-Manager from trying to manage this device - change the MAC address # to match yours as found from above using the ifconfig command # vim /etc/NetworkManager/NetworkManager.conf -- [keyfile] unmanaged-devices=mac:80:1F:02:AA:29:CA -- #If things don't work right, try debugging with: service hostapd stop hostapd -dd /etc/hostapd/hostapd.conf #---------------------------------------------------------------- # Legacy Wifi Ad-Hoc approach (works with Motorola Droid2 running Android GingerBread # (does not work with LG G3 running Android Kitkat or Lolipop # # see /usr/local/sbin/start-wireless-adhoc.sh for all details #---------------------------------------------------------------- apt-get install dnsmasq dnsmasq-base dnsmasq-utils #We only want it to start manually update-rc.d dnsmasq remove vim /etc/dnsmasq.conf -- interface=wlan0 no-dhcp-interface=eth0 domain=rpi-trinnet.net dhcp-range=10.10.10.10,10.10.10.150,255.255.255.0,12h -- #Make the required dnsmask dir if it was removed mkdir /var/run/dnsmasq/ #(OPTIONAL): Disable Bluetooth on the Rpi # update-rc.d -f bluetooth remove sudo nano /etc/network/interfaces -- #if there is any other line that has "auto lo" in it, REMOVE it auto lo eth0 wlan0 iface lo inet loopback iface eth0 inet dhcp #This is intentionally set to manual to support the selection of client or server AP mode iface wlan0 inet manual allow-hotplug wlan0 -- update /etc/hosts add rpi to reflect local wireless address Add addresses to reflect /etc/ax25/ax25ipd.conf 1.1.1.1 f3kt-0 f3kt.dyndns.org 88.149.155.158 iz3lsv-0 1.1.1.1 on4hu-0 on4hu.be 1.1.1.1 k4gbb-0 k4gbb.servftp.com #Update the fbb stuff update the details in /etc/ax25/fbb/beacon0.sys port.sys needs updating too --RESEARCH-- dir /etc/ax25/fbb needs sed search/replace for all CAPS F6BVP #Update the default editor update-alternatives --config editor # ---------------- Enable IPv6 upon booting edit the /etc/modprobe.d/ipv6.conf file and # out the line: alias net-pf-10 off # ---------------- #Now configure your primary Wifi interface ifconfig wlan0 down sudo wpa_cli # Note: if this program won't start, pull out the USB Wireless device and put it back in again # that should re-prod NetworkManager to get it running #Now, get the name of any pre-configured wireless devices and put them into the start-adhoc script wpa_cli --> scan --> scan-results --> add_network --> set_network 0 ssid "enter-your-previously-shown-BSSID-here" --> set_network 0 psk "enter-your-wpa2-key-here" --> enable_network 0 --> save_config Get a copy of /usr/local/sbin/start-adhoc.sh chmod 700 /usr/local/sbin/start-adhoc.sh #All other VE7FET AX.25 sources /usr/local/src/ #--- # cat /usr/src/archive/mount-hampacket2-nfs.sh #!/bin/bash if [ ! -d /mnt/nfs ]; then mkdir /mnt/nfs fi mount -t nfs hampacket2:/usr/src/archive/RPi /mnt/nfs mount -t nfs hampacket2:/usr/src/archive/RPi/tmp /mnt/nfs # -- If you're using an HT, make sure that you disable the RX power saver and the Automatic power off # -- Check out http://dantracker.tk/tracker.html for more RPi optimizations, etc #------------------- #Install postfix, logwatch, etc apt-get install postfix logwatch bsd-mailx # when prompted, configure postfix to be "Internet with Smarthost" #update the /etc/aliases file to point root to a known user root: dranch@trinnet.net newaliases #------------------- #Make sure logrotate is installed apt-get install logrotate #edit the /etc/logrotate.conf file to enable bzip compression - just below the "compress" line -- # use bzip2 whith higher compression than gzip compresscmd /bin/bzip2 uncompresscmd /bin/bunzip2 compressoptions -9 compressext .bz2 -- #It's key to use the "copytruncate" command for some logs as these files are getting #appended from various Unix redirects and NOT syslog. Since you cannot send say #SIGUSR1 to re-evaluate their new file handle for the newly created file # add log rotation for ax25-listen log /etc/logrotate.d/ax25-listen -- /var/log/ax25-listen.log { daily rotate 10 missingok notifempty compress copytruncate } -- # add log rotation for packet.log /etc/logrotate.d/packet -- /var/log/packet.log { daily rotate 10 missingok notifempty compress copytruncate } -- # --------------------------------------------------------------- #Supress 1000s of cron lines like the following in /var/log/auth.log # # Jan 30 18:49:01 ota3 CRON[14054]: pam_unix(cron:session): session opened for user zzz by (uid=0) # Jan 30 18:49:03 ota3 CRON[13055]: pam_unix(cron:session): session closed for user root edit /etc/pam.d/common-session-noninteractive At the end of the file, find the line: session required pam_unix.so and now add the following line ABOVE it session [success=1 default=ignore] pam_succeed_if.so service in cron quiet use_uid # --------------------------------------------------------------- # The Rpi's HW watchdog is disabled by default though the init script runs (stupid) If you want to use the watchdog to keep your system up though it might be constantly rebooting (and/or corrupting the SD card), edit the /etc/init.d/watchdog script # --------------------------------------------------------------- You can update the various F6BVP code, AX25 stack, etc. from the included scripts: cd /usr/local/src/ Instax25.new updAX25 updfbb updfpac ---------------- Other needed programs apt-get install tcpdump apt-get install lsof apt-get install gpm #Get GPM but only run it when needed update-rc.d gpm remove apt-get install xastir apt-get install minicom #if /boot gets corrupt, you can fix it #Wheezy version of dosfstools is busted # http://www.raspberrypi.org/forums/viewtopic.php?p=495156 # apt-get install dosfstools --- http://raspberrypi.stackexchange.com/questions/5367/how-do-i-change-the-editor-used-by-visudo #Update the system wide editor update-alternatives --set editor /usr/bin/vim.tiny ------------------------------------------------------------------------ Setting up the Sound Card Level set - Yaesu FT-415 HT - SQL : 0 VOL : 2.9 alsamixer - F6 to select right sound card - F3 playback speaker at 19:19 and selected (that's 00) Mic at 52 and selected (that's 00) [this one doesn't matter] Auto Gaim control - selected (that's 00) - F4 Capture 31 and Capture (spacebar) #save the levels alsactl store #Integrate in startup script alsactl restore Test the soundcard arecord -l arecord -D hw:1,0 -t wav -f S16_LE -r 48000 -d 10 /tmp/test.wav aplay /tmp/test.wav # Record real time and playback to Rpi's headphone jack arecord -D hw:1,0 -t wav -f S16_LE -r 48000 -d 10 - | aplay - # Identify native sampling rates lsusb -vv | grep -e Audio -e tSamFreq | grep -v -e Descriptor -e bInterfaceClass ---------------- Setup Direwolf [ Read Direwolf User-Guide.PDF for configuration ] On Rpi, I'm using a GPIO pin for PTT and this circuit: http://www.dunmire.org/projects/DigitalCommCenter/soundmodem/mySoundCardInterface.png When Direwolf is running, there are two key things to monitor in /var/log/packet.log: 1. The sampling rate matches the configured rate. If it deviates beyond the expected rate too much, things won't work at all. 4,412,205 is ok Past 100 seconds, 4410000 audio samples, 0 errors. 2. Direwolf reported audio levels is roughly around a level of 50 on average for various heard remote stations Digipeater WR6ABD audio level = 53 [NONE] --- Setting up the GPS Dantracker currently does NOT support gpsd and - only supports GPSes on /dev/ttyUSB* - only supports NEMA GPSes - does not initialize SiRF GPSes to send NEMA - does support for setting the time via GPS once a day concerns: - even if I disable dantracker GPS & gpsd and just run "cat /dev/ttyUSB0 > /dev/null", the impact hits direwolf where it under-samples and then fails to do decodes: Past 100 seconds, 4275495 audio samples, 0 errors. see http://astrobeano.blogspot.com/2012/10/pharosmicrosoft-gps-360-on-raspberry-pi.html for details #Plugin in the USB based GPS and figure out what device it gets dmesg #now find it's serial device ls /dev/serial/by-id #For me, it's ls -la usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 #Install the required software apt-get install gpsd gpsd-clients #now configure gpsd to use - /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 sudo dpkg-reconfigure gpsd # NOTE: you might need to specify "-n" as an optional parameter for your specific GPS #Test it for a single run - FOREGROUND killall gpsd sudo gpsd -N -D3 -n /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 #Test #2 - set to NEMA mode and display the raw output gpsctl -f -n /dev/ttyUSB0 #If setting to NEMA mode fails, try: gpsmon -n /dev/ttyUSB0 #If that's working, now try this to see if it will work all the time sudo /etc/rc3.d/S04gpsd start #Now try out a gpsd client with either gpsmon or gpsmon -n or cgps # You also might like cgps # Until DanTracker supports gpsd, disable it from starting update-rc.d gpsd disable #disable gpsd from auto-starting when connected to the USB bus dpkg-reconfigure -plow gpsd ------------------------- Enable ntpd to get time from gpsd #Ok, get ntp to support it sudo cp /etc/ntp.conf /etc/Old/ntp.conf-092814 sudo vim /etc/ntp.conf -- server 127.127.28.0 minpoll 4 maxpoll 4 fudge 127.127.28.0 time1 0.000 refid SHM stratum 15 -- old try was -- server 127.127.28.0 fudge 127.127.28.0 time1 0.420 refid GPS server 127.127.28.1 prefer udge 127.127.28.1 refid GPS1 -- or -- -- #In troubleshooting, there might be an issue with the GPS being accessed by gpsd sudo usermod -aG dialout nobody #THere could be problems where it's not polling very often (notice the 71m delay) # Seems if another program is running like cgps, then ntpd works. Hmmm $ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== +carbon.neersigh 200.98.196.212 2 u 172 256 373 85.801 0.216 22.702 +jarvis.arlen.io 164.244.221.197 2 u 46 256 377 48.269 1.420 21.650 -time01.muskegon 204.9.54.119 2 u 100 256 377 74.713 6.046 53.822 *time.tritn.com 66.220.9.122 2 u 182 256 377 20.031 -0.125 0.134 SHM(0) .GPS. 0 l 71m 64 0 0.000 399.598 0.000 SHM(1) .GPS1. 0 l - 64 0 0.000 0.000 0.000 ------ Dan tracker Need to integrate hampacket2:/usr/src/archive/RPi/n7nix-udrtracker-install.txt #Update the config - Dantracker currently ONLY supports devices like ttyUSB0 (not /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0 ) vi /etc/tracker/aprs_tracker.ini -- port = /dev/ttyUSB0 -- #You have to get the GPS running in NEMA mode first sudo gpsd -N -D3 -n /dev/ttyUSB0 /etc/tracker/tracker-up To view the current system, use: http://192.168.0.10:8080/tracker.html or http://192.168.0.10:8081/spy.html