{"id":967,"date":"2016-06-14T15:50:27","date_gmt":"2016-06-14T21:50:27","guid":{"rendered":"http:\/\/www.jedge.com\/wordpress\/?p=967"},"modified":"2016-06-14T16:00:00","modified_gmt":"2016-06-14T22:00:00","slug":"wr703n-with-gps-module","status":"publish","type":"post","link":"https:\/\/www.jedge.com\/wordpress\/2016\/06\/wr703n-with-gps-module\/","title":{"rendered":"WR703N with GPS Module"},"content":{"rendered":"<p><strong>WR703N with GPS Module<\/strong><br \/>\nThis tutorial uses the WR703N serial port with a u-blox REYAX RY836AI GNSS receiver module for a super-portable War-Walking \/ War-Driving device.<br \/>\n<!--more--><\/p>\n<p><strong>Obtaining Openwrt<\/strong><br \/>\n*Note: Everything is done from the latest version of Ubuntu LTS (14.04).<\/p>\n<p>For this tutorial we will work out of your home directory. We will download the latest code for Openwrt Barrier Breaker 14.07 (BB).  We are using BB since gpsd will compile.  I haven&#8217;t gotten it to work in Chaos Calmer 15.05 yet. <\/p>\n<p>Make sure your environment has the software required.<br \/>\n<pre><code>$ sudo apt-get update\n$ sudo apt-get install git-core build-essential libssl-dev subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex gettext quilt xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip\n<\/code><\/pre><\/p>\n<p>Get the latest code for Barrier Breaker<br \/>\n<pre><code>$ cd ~\/\n$ git clone git:\/\/git.openwrt.org\/14.07\/openwrt.git barrier_breaker\nCloning into &#039;barrier_breaker&#039;...\nremote: Counting objects: 10545, done.\nremote: Compressing objects: 100% (7917\/7917), done.\nremote: Total 10545 (delta 3667), reused 8061 (delta 2033)\nReceiving objects: 100% (10545\/10545), 12.92 MiB | 2.24 MiB\/s, done.\nResolving deltas: 100% (3667\/3667), done.\nChecking connectivity... done.\n<\/code><\/pre><\/p>\n<p>Download and install all available &#8220;feeds&#8221;, create our configuration file to build what we need.<br \/>\n<pre><code>$ cd ~\/barrier_breaker\n~\/barrier_breaker$ .\/scripts\/feeds update -a\n~\/barrier_breaker$ .\/scripts\/feeds install -a\n~\/barrier_breaker$ make menuconfig<\/code><\/pre><\/p>\n<p>Go forth and select all of these packages to be included in the image and not as a modules (asterisk (*) instead of (M)).<\/p>\n<p>Target System (Atheros AR7xxx\/AR9xxx)<br \/>\nTarget Profile (TP-LINK TL-WR703N)<\/p>\n<p>[*] Build the OpenWrt Image Builder<br \/>\n[*] Build the OpenWrt SDK<br \/>\n[*] Build the OpenWrt based Toolchain<\/p>\n<p>Network \u2014> (gpsd &#038; gpsd-clients)<br \/>\nNetwork \u2014>wireless (kismet-server)<br \/>\nUtilities \u2014>coreutils \u2014> coreutils-stty<br \/>\nThe pre-requisite libraries and support packages will automatically be selected for gpsd and kismet.<\/p>\n<p>You may also want support for USB storage especially if you also plan on capturing the wireless network traffic.<\/p>\n<p>Kernel modules \u2014>Filesystems (kmod-fs-ext4, kmod-fs-ntfs &#038; kmod-fs-vfat)<br \/>\nKernel modules \u2014>USB Support (kmod-usb-ohci, kmod-usb-uhci, kmod-usb2, kmod-usb-storage, kmod-usb-storage-extras)<br \/>\nKernel modules \u2014>Native Language Support (kmod-nls-cp437, kmod-nls-base &#038; kmod-nls-iso8859-1)<\/p>\n<p>I also like to add support for my USB Wireless Devices including my Alfa AWUS036H, Alfa AWUS036EW, and TP-LINK TL-WN722N<\/p>\n<p>Kernel modules \u2014>Wireless Drivers \u2014>kmod-ath9k-htc &#038; kmod-rtl8187<\/p>\n<p><strong>Terminate console on serial port (UART)<\/strong><br \/>\nWe can&#8217;t have our kernel spitting error messages to the serial port.  Nor can we allow the console to interact with it.  You can visit the OpenWrt Wiki page at <a href=\"http:\/\/wiki.openwrt.org\/doc\/recipes\/terminate.console.on.serial title=\"How to terminate console on serial port (UART)\" target=\"_blank\">here<\/a>.<br \/>\n<pre><code>~\/barrier_breaker$ grep -n CONFIG_CMDLINE target\/linux\/ar71xx\/config-3.10\n138:CONFIG_CMDLINE=&quot;rootfstype=squashfs,jffs2 noinitrd&quot;\n139:CONFIG_CMDLINE_BOOL=y\n140:# CONFIG_CMDLINE_OVERRIDE is not set\n<\/code><\/pre>Line 138 it is!  Modify <em>rootfstype=squashfs,jffs2 noinitrd<\/em> to <em>rootfstype=squashfs,jffs2 noinitrd console=null<\/em><br \/>\n<pre><code>~\/barrier_breaker$ sed -i &#039;138s\/.*\/CONFIG_CMDLINE=&quot;rootfstype=squashfs,jffs2 noinitrd console=null&quot;\/&#039; target\/linux\/ar71xx\/config-3.10\n<\/code><\/pre><\/p>\n<p><strong>Custom Files<\/strong><br \/>\nThe best place to learn about adding custom files to your image build is the OpenWrt Wiki, specifically <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/build\" title=\"Build Howto - Custom Files\" target=\"_blank\">here<\/a>.<\/p>\n<p><em>Create Directories to Store Out Custom Files<\/em><br \/>\n<pre><code>$ mkdir -p ~\/barrier_breaker\/files\/etc\/init.d\n$ mkdir -p ~\/barrier_breaker\/files\/etc\/config\n$ mkdir -p ~\/barrier_breaker\/files\/etc\/rc.d\n$ mkdir -p ~\/barrier_breaker\/files\/etc\/kismet\n<\/code><\/pre><\/p>\n<p><em>Disable Console on serial port<\/em><br \/>\nI know we disabled the console by editing the kernel but I want to be sure&#8230;or maybe you don&#8217;t want to modify the console via the kernel.  You can visit the OpenWrt Wiki page at <a href=\"http:\/\/wiki.openwrt.org\/doc\/recipes\/terminate.console.on.serial title=\"How to terminate console on serial port (UART)\" target=\"_blank\">here<\/a>.<br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/inittab\n<\/code><\/pre><pre><code>::sysinit:\/etc\/init.d\/rcS S boot\n::shutdown:\/etc\/init.d\/rcS K shutdown\n#::askconsole:\/bin\/ash --login\n<\/code><\/pre><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/sysctl.conf\n<\/code><\/pre><pre><code>kernel.printk = 0 4 1 7\nkernel.panic=3\nnet.ipv4.conf.default.arp_ignore=1\nnet.ipv4.conf.all.arp_ignore=1\nnet.ipv4.ip_forward=1\nnet.ipv4.icmp_echo_ignore_broadcasts=1\nnet.ipv4.icmp_ignore_bogus_error_responses=1\nnet.ipv4.igmp_max_memberships=100\nnet.ipv4.tcp_ecn=0\nnet.ipv4.tcp_fin_timeout=30\nnet.ipv4.tcp_keepalive_time=120\nnet.ipv4.tcp_syncookies=1\nnet.ipv4.tcp_timestamps=1\nnet.ipv4.tcp_sack=1\nnet.ipv4.tcp_dsack=1\n\nnet.ipv6.conf.default.forwarding=1\nnet.ipv6.conf.all.forwarding=1\n\nnet.netfilter.nf_conntrack_acct=1\nnet.netfilter.nf_conntrack_checksum=0\nnet.netfilter.nf_conntrack_max=16384\nnet.netfilter.nf_conntrack_tcp_timeout_established=7440\nnet.netfilter.nf_conntrack_udp_timeout=60\nnet.netfilter.nf_conntrack_udp_timeout_stream=180\n\n# disable bridge firewalling by default\nnet.bridge.bridge-nf-call-arptables=0\nnet.bridge.bridge-nf-call-ip6tables=0\nnet.bridge.bridge-nf-call-iptables=0\n<\/code><\/pre><br \/>\n<em>Custom Wireless Configuration Files<\/em><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/config\/wireless\n<\/code><\/pre><pre><code>config wifi-device&nbsp;&nbsp;radio0\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option type&nbsp;&nbsp;&nbsp;&nbsp; mac80211\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option channel&nbsp;&nbsp;11\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option hwmode&nbsp;&nbsp; 11g\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option path&nbsp;&nbsp;&nbsp;&nbsp; &#039;platform\/ar933x_wmac&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option htmode&nbsp;&nbsp; HT20\n\nconfig wifi-iface\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option device&nbsp;&nbsp; radio0\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option network&nbsp;&nbsp;lan\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option mode&nbsp;&nbsp;&nbsp;&nbsp; ap\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option ssid&nbsp;&nbsp;&nbsp;&nbsp; warmachine #or whatever you want to call it\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option encryption psk2\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;mysupersecretPassWord&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option hidden&nbsp;&nbsp; 1\n<\/code><\/pre><br \/>\n<em>Custom Network Configuration Files<\/em><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/config\/network\n<\/code><\/pre><pre><code>config interface &#039;loopback&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option ifname &#039;lo&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option proto &#039;static&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option ipaddr &#039;127.0.0.1&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option netmask &#039;255.0.0.0&#039;\n\nconfig interface &#039;lan&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option ifname &#039;eth0&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option force_link &#039;1&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option type &#039;bridge&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option proto &#039;static&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option ipaddr &#039;192.168.1.225&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option netmask &#039;255.255.255.0&#039;\n<\/code><\/pre><br \/>\n<em>Custom System Configuration Files<\/em><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/config\/system\n<\/code><\/pre><pre><code>config system\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option hostname KisWrt #or whatever you want to call it\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option timezone UTC\n<\/code><\/pre><br \/>\n<em>Setup Serial Port<\/em><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/rc.local\n<\/code><\/pre><pre><code># Put your custom commands here that should be executed once\n# the system init finished. By default this file does nothing.\nstty -F \/dev\/ttyATH0 9600 sane\nexit 0<\/code><\/pre><br \/>\n<em>gpsd Configuration File<\/em><br \/>\n<pre><code>$ vim ~\/barrier_breaker\/files\/etc\/config\/gpsd\n<\/code><\/pre><pre><code>config gpsd core\n&nbsp;&nbsp;&nbsp;&nbsp;option device&nbsp;&nbsp;&nbsp;&nbsp;&quot;\/dev\/ttyATH0&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;option port&nbsp;&nbsp;&nbsp;&nbsp;&quot;2947&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;option listen_globally&nbsp;&nbsp;&nbsp;&nbsp;&quot;false&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;option enabled&nbsp;&nbsp;&nbsp;&nbsp;&quot;true&quot;<\/code><\/pre><\/p>\n<p>Now for the kismet.conf file.  I&#8217;m not going to list the entire file for this tutorial.  Below are the options I change in \/etc\/kismet\/kismet.conf.  Then I show you how to just download the file with the changes already made.<br \/>\n<em>Modify These Variables<\/em><br \/>\nservername=KisWrt<br \/>\nlogprefix=\/tmp<br \/>\nncsource=wlan0<br \/>\nlisten=tcp:\/\/0.0.0.0:2501<br \/>\nallowedhosts=127.0.0.1,192.168.1.0\/24<br \/>\ngps=true<br \/>\ngpstype=gpsd<br \/>\ngpsreconnect=true<br \/>\nlogtypes=gpsxml,netxml<br \/>\n<pre><code>cd ~\/barrier_breaker\/files\/etc\/kismet\n~\/barrier_breaker\/files\/etc$ wget http:\/\/www.jedge.com\/code\/wr703n.kismet.conf -O kismet.conf<\/code><\/pre><\/p>\n<p><em>Kismet Startup Script<\/em><br \/>\nThis script includes code to pull the date and time from our GPS before starting Kismet.<br \/>\n<pre><code>vim ~\/barrier_breaker\/files\/etc\/init.d\/kismet\n<\/code><\/pre><pre><code>#!\/bin\/sh \/etc\/rc.common\n \nSTART=99\nSTOP=10\n \nstart() {\n&nbsp;&nbsp;&nbsp;&nbsp;date -s &#039;2015-01-01 00:00:01&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;sleep 1\n&nbsp;&nbsp;&nbsp;&nbsp;killall ntpd \n&nbsp;&nbsp;&nbsp;&nbsp;sleep 30 #wait for gps to get a lock\n&nbsp;&nbsp;&nbsp;&nbsp;GPSDATE=`gpspipe -w | head -10 | grep TPV | sed -r &#039;s\/.*&quot;time&quot;:&quot;([^&quot;]*)&quot;.*\/\\1\/&#039; | head -1 |sed -r &#039;s\/T\/ \/g&#039; | awk -F&quot;.&quot; &#039;{print $1}&#039;`\n&nbsp;&nbsp;&nbsp;&nbsp;date -s &quot;$GPSDATE&quot;\n&nbsp;&nbsp;&nbsp;&nbsp;\/usr\/sbin\/ntpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kismet_server --config-file \/etc\/kismet\/kismet.conf --daemonize --silent\n}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n \nstop() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; killall kismet_server\n&nbsp;&nbsp;&nbsp;&nbsp; \n}<\/code><\/pre><br \/>\nCreate a symlink so kismet_server and gpsd start when the device boots.<br \/>\n<pre><code>$ cd ~\/barrier_breaker\/files\/etc\/rc.d\n~\/barrier_breaker\/files\/etc\/rc.d$ ln -s ..\/init.d\/gpsd S50gpsd\n~\/barrier_breaker\/files\/etc\/rc.d$ ln -s ..\/init.d\/gpsd K20gpsd\n~\/barrier_breaker\/files\/etc\/rc.d$ ln -s ..\/init.d\/kismet S95kismet\n~\/barrier_breaker\/files\/etc\/rc.d$ ln -s ..\/init.d\/kismet K10kismet\n<\/code><\/pre><\/p>\n<p>Why set your root password after the first boot?  Why not set it in your image before you install it?<br \/>\n<pre><code>echo &quot;yoursecret&quot; | makepasswd --clearfrom=- --crypt-md5 |awk &#039;{print $2}&#039;\n$1$uZ9fJ7OE$A8KGOGcOR4fP3\/XEsxQaa0<\/code><\/pre><pre><code>$ vim ~\/barrier_breaker\/files\/etc\/shadow\n<\/code><\/pre><pre><code>root:$1$uZ9fJ7OE$A8KGOGcOR4fP3\/XEsxQaa0:0:0:99999:7:::\ndaemon:*:0:0:99999:7:::\nftp:*:0:0:99999:7:::\nnetwork:*:0:0:99999:7:::\nnobody:*:0:0:99999:7:::\n<\/code><\/pre><\/p>\n<p>Now we can compile our image.  Once complete your image will be find in <kbd>~\/barrier_breaker\/bin\/ar71xx<\/kbd> called <kbd>openwrt-ar71xx-generic-gl-inet-6416A-v1-squashfs-factory.bin<\/kbd><br \/>\n<pre><code>cd ~\/barrier_breaker\n~\/barrier_breaker$ make target\/linux\/{clean,prepare} V=s QUILT=1\n~\/barrier_breaker$ make V=99<\/code><\/pre><\/p>\n<p>Documenting how to upgrade (or downgrade) the firmware of your wr703n is tricky as I don\u2019t know what version you are running or what state it currently is in.  I&#8217;ll leave this to you.  Just follow the instructions from the OpenWrt wiki <a href=\"https:\/\/wiki.openwrt.org\/toh\/tp-link\/tl-wr703n\">https:\/\/wiki.openwrt.org\/toh\/tp-link\/tl-wr703n<\/a><\/p>\n<p><strong>References<\/strong><br \/>\n<a href=\"http:\/\/blog.petrilopia.net\/linux\/raspberry-pi-set-time-gps-dongle\/\">http:\/\/blog.petrilopia.net\/linux\/raspberry-pi-set-time-gps-dongle\/<\/a><br \/>\n<a href=\"http:\/\/wiki.openwrt.org\/doc\/techref\/initscripts\">http:\/\/wiki.openwrt.org\/doc\/techref\/initscripts<\/a><br \/>\n<a href=\"http:\/\/wiki.openwrt.org\/doc\/recipes\/serialbaudratespeed\">http:\/\/wiki.openwrt.org\/doc\/recipes\/serialbaudratespeed<\/a><br \/>\n<a href=\"http:\/\/wiki.openwrt.org\/doc\/hardware\/port.serial\">http:\/\/wiki.openwrt.org\/doc\/hardware\/port.serial<\/a><br \/>\n<a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/networked.gps\">http:\/\/wiki.openwrt.org\/doc\/howto\/networked.gps<\/a><br \/>\n<a href=\"http:\/\/wiki.openwrt.org\/doc\/recipes\/terminate.console.on.serial\">http:\/\/wiki.openwrt.org\/doc\/recipes\/terminate.console.on.serial\/<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>WR703N with GPS Module This tutorial uses the WR703N serial port with a u-blox REYAX RY836AI GNSS receiver module for a super-portable War-Walking \/ War-Driving device.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[113,114],"tags":[43,123,119],"class_list":["post-967","post","type-post","status-publish","format-standard","hentry","category-compiling","category-hardware-hacking","tag-kismet","tag-openwrt","tag-wr703n"],"_links":{"self":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/posts\/967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/comments?post=967"}],"version-history":[{"count":11,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/posts\/967\/revisions"}],"predecessor-version":[{"id":995,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/posts\/967\/revisions\/995"}],"wp:attachment":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/media?parent=967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/categories?post=967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/tags?post=967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}