{"id":1302,"date":"2015-06-17T00:17:09","date_gmt":"2015-06-17T00:17:09","guid":{"rendered":"http:\/\/www.dnclabs.com\/?p=1302"},"modified":"2015-06-17T00:17:09","modified_gmt":"2015-06-17T00:17:09","slug":"step-2-install-openwrt","status":"publish","type":"post","link":"http:\/\/www.dnclabs.com\/?p=1302","title":{"rendered":"Step 2 Install Openwrt"},"content":{"rendered":"<style>\n<!--\n \/* Font Definitions *\/\n @font-face\n\t{font-family:\"Cambria Math\";\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\n@font-face\n\t{font-family:Cambria;\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\n@font-face\n\t{font-family:Calibri;\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\n@font-face\n\t{font-family:Tahoma;\n\tpanose-1:2 11 6 4 3 5 4 4 2 4;}\n@font-face\n\t{font-family:Courier New;\n\tpanose-1:2 11 6 4 3 5 4 4 2 4;}\n \/* Style Definitions *\/\nfixed\n\t{margin-top:0in;\n\tmargin-right:0in;\n\tmargin-bottom:10.0pt;\n\tmargin-left:0in;\n\tline-height:115%;\n\tfont-size:11.0pt;\n\tfont-family:\"Courier New\",\"monospace\";}\n p.MsoNormal, li.MsoNormal, div.MsoNormal\n\t{margin-top:0in;\n\tmargin-right:0in;\n\tmargin-bottom:10.0pt;\n\tmargin-left:0in;\n\tline-height:115%;\n\tfont-size:11.0pt;\n\tfont-family:\"Calibri\",\"sans-serif\";}\nh1\n\t{mso-style-link:\"Heading 1 Char\";\n\tmargin-top:24.0pt;\n\tmargin-right:0in;\n\tmargin-bottom:0in;\n\tmargin-left:0in;\n\tmargin-bottom:.0001pt;\n\tline-height:115%;\n\tpage-break-after:avoid;\n\tfont-size:14.0pt;\n\tfont-family:\"Cambria\",\"serif\";\n\tcolor:#365F91;}\nh2\n\t{mso-style-link:\"Heading 2 Char\";\n\tmargin-top:10.0pt;\n\tmargin-right:0in;\n\tmargin-bottom:0in;\n\tmargin-left:0in;\n\tmargin-bottom:.0001pt;\n\tline-height:115%;\n\tpage-break-after:avoid;\n\tfont-size:13.0pt;\n\tfont-family:\"Cambria\",\"serif\";\n\tcolor:#4F81BD;}\n-->\n<\/style>\n<p>It has been a long time coming but we are finally ready to install OpenWRT. I have provided a pre-built image for this. Using the Uboot loader we can install a new Linux image on our module. This only takes a few minutes so let&#8217;s get started. Once you have completed this step you can remotely access and control the HLK-RM04 module.<\/p>\n<p>Wire the module by plugging in the USB mini B connector that provides power and a serial debug port. Next plug an Ethernet cable into the module and your home router. Copy the <a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/dnclabs-sysupgrade.txt\">dnclabs-sysupgrade<\/a> file to the TFTP directory.<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/Tftpd64.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/Tftpd64.png\" alt=\"Tftpd64\" width=\"402\" height=\"336\" class=\"alignleft size-full wp-image-1300\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/Tftpd64.png 402w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/Tftpd64-300x251.png 300w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/a><\/p>\n<p>Boot the module with a 57600bps console connected and select option &#8220;2&#8221; when Uboot prompts you.  Start the Tftpd server on your host PC. I use Tftpd64.exe (by Ph. Jounin)on my Windows machine.<br \/>\nThe server uses the address of your home computer in my case 192.168.2.100 which I configured on my router. You also need to setup a static route to your HLK-RM04 module which is set to 192.168.2.120 on my router so that the module is given a predictable address. If you only use DHCP the address will change and you&#8217;ll have to keep track of this. Instead I map the modules MAC address to a know IP address on my network. This is the address that I setup in my Uboot environment variables from the previous post.<\/p>\n<p>I then set the IP address of the input device to 192.168.2.120 and the input server IP address to 192.168.2.100. The default device and server IP addresses were setup when I configured the Uboot environment variables. The file with the new Linux image is <strong>dnclabs-sysupgrade.bin<\/strong><\/p>\n<pre>\r\n2: System Load Linux Kernel then write to Flash via TFTP.\r\n Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y\/N)\r\n Please Input new ones \/or Ctrl-C to discard\r\n        Input device IP (192.168.2.120) ==:192.168.2.120\r\n        Input server IP (192.168.2.100) ==:192.168.2.100\r\n        Input Linux Kernel filename (dnclabs-sysupgrade.bin) ==:dnclabs-sysupgrade.bin\r\n<\/pre>\n<h2>Initial configuration<\/h2>\n<p>When you first boot the HLK module a serial port connected to the USB mini-B connector will display the boot progress. Let the module boot and wait for all of the log messages to be displayed. Eventually you will be presented with a banner text and command prompt. The first system boot is slow since Linux has to prepare a file system; subsequent boots are much faster. Once you get the command prompt you will want to set a new password so that you can remotely access the module. At the command prompt type &#8220;passwd&#8221; and enter your new password twice.<\/p>\n<p>Next we need to get  our module connected to your home network. This involves modifying two configuration files. In a later post I will show you how to install these changes as part of the Linux build process but for now manual configuration is adequate. It is very unlikely that the network defaults I have chosen will work on your network so we need to customize your setup. Initially we want to get the Ethernet link up and running.<\/p>\n<h2>Ethernet configuration<\/h2>\n<p>The default \u201cnetwork\u201d configuration file should work without modification. It does expect that your hope router will provide an IP address in response to a DHCP request. The file is located at <strong>\/etc\/config\/network<\/strong>.<\/p>\n<pre>\r\nconfig interface 'loopback'\r\n        option ifname 'lo'\r\n        option proto 'static'\r\n        option ipaddr '127.0.0.1'\r\n        option netmask '255.0.0.0'\r\n\r\nconfig interface 'lan'\r\n        option ifname 'eth0.1'\r\n        option force_link '1'\r\n        option type 'bridge'\r\n        option proto 'dhcp'\r\n# REMOVE THIS LINE TO ENABLE WIFI:\r\n#       option disabled 1\r\n\r\nconfig interface wwan\r\n        option proto 'dhcp'\r\n\r\nconfig switch\r\n        option name 'switch0'\r\n        option reset '1'\r\n        option enable_vlan '1'\r\n\r\nconfig switch_vlan\r\n        option device 'switch0'\r\n        option vlan '1'\r\n        option ports '0 4 6t'\r\n<\/pre>\n<p>Type &#8220;<strong>ifconfig<\/strong>&#8221; and you should see that the Ethernet port has been assigned to your IP address. Ping your host computer to test the connectivity of your wired lan. <\/p>\n<pre>\r\nroot@OpenWrt:\/# ifconfig\r\nbr-lan    Link encap:Ethernet  HWaddr 44:33:4C:CE:AC:32\r\n          inet addr:192.168.2.130  Bcast:192.168.2.255  Mask:255.255.255.0\r\n          inet6 addr: fe80::4633:4cff:fece:ac32\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:145 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:142 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:10493 (10.2 KiB)  TX bytes:12372 (12.0 KiB)\r\n\r\neth0      Link encap:Ethernet  HWaddr 44:33:4C:CE:AC:32\r\n          inet6 addr: fe80::4633:4cff:fece:ac32\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:156 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:157 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:16323 (15.9 KiB)  TX bytes:15363 (15.0 KiB)\r\n          Interrupt:5\r\n\r\neth0.1    Link encap:Ethernet  HWaddr 44:33:4C:CE:AC:32\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:156 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:142 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:13515 (13.1 KiB)  TX bytes:13209 (12.8 KiB)\r\n\r\nlo        Link encap:Local Loopback\r\n          inet addr:127.0.0.1  Mask:255.0.0.0\r\n          inet6 addr: ::1\/128 Scope:Host\r\n          UP LOOPBACK RUNNING  MTU:65536  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n\r\nwlan0     Link encap:Ethernet  HWaddr 44:33:4C:CE:AC:32\r\n          UP BROADCAST MULTICAST  MTU:1500  Metric:1\r\n          RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)\r\n\r\nroot@OpenWrt:\/# ping 192.168.2.100\r\nPING 192.168.2.100 (192.168.2.100): 56 data bytes\r\n64 bytes from 192.168.2.100: seq=0 ttl=128 time=1.440 ms\r\n64 bytes from 192.168.2.100: seq=1 ttl=128 time=0.760 ms\r\n\r\n--- 192.168.2.100 ping statistics ---\r\n2 packets transmitted, 2 packets received, 0% packet loss\r\nround-trip min\/avg\/max = 0.760\/1.100\/1.440 ms\r\nroot@OpenWrt:\/#\r\n\r\n<\/pre>\n<h2>Wifi configuration<\/h2>\n<p>From the command prompt we need to modify the \u201cwireless\u201d configuration file so it looks like this. I use The VI editor and there is a quick cheat sheet at the end of the post. The minimal configuration is as follows:<\/p>\n<pre>\r\nroot@OpenWrt:\/# <strong>cd \/etc\/config<\/strong>\r\nroot@OpenWrt:\/etc\/config#\r\nroot@OpenWrt:\/etc\/config# <strong>vi wireless<\/strong>\r\n\r\nconfig wifi-device  'radio0'\r\n        option type     'mac80211'\r\n        option channel  'auto'\r\n        option path     '10180000.wmac'\r\n\r\nconfig wifi-iface\r\n        option device   'radio0'\r\n        option network  'wwan'\r\n        option mode     'sta'\r\n        option proto    'dhcp'\r\n        option encryption 'psk2'\r\n\r\n        option ssid     'enter your netork SSID here'     \r\n        option key      'enter your network password here'\r\n<\/pre>\n<p>After changing the wireless file, power the module off and on again to force a re-boot. Again wait for the module to boot to the command prompt. Type &#8220;ifconfig&#8221; and you should see that the wireless port has been assigned to your IP address. Ping you the internet ie)google.com to test the connectivity. <\/p>\n<pre>\r\nroot@OpenWrt:\/# ifconfig\r\n.\r\n.\r\n.\r\nwlan0     Link encap:Ethernet  HWaddr 44:33:4C:CE:AC:32\r\n          inet addr:192.168.1.130  Bcast:192.168.255.255  Mask:255.255.0.0\r\n          inet6 addr: fe80::4633:4cff:fece:ac32\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:14 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000\r\n          RX bytes:4047 (3.9 KiB)  TX bytes:1576 (1.5 KiB)\r\nroot@OpenWrt:\/# ping google.com\r\nPING google.com (66.185.84.158): 56 data bytes\r\n64 bytes from 66.185.84.158: seq=0 ttl=57 time=20.760 ms\r\n<\/pre>\n<h2>Remote Access<\/h2>\n<p>Once you have set a password you can use SSH to securely log into the module. On a Windows machine I use PuTTY.exe. The network access can be wired or wireless depending on which network interface you have setup. To access the module with SSH you need use the IP address assigned to the module which is 192.168.2.130 port 22 for my wired network.<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Configuration.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Configuration-300x286.png\" alt=\"PuTTY Configuration\" width=\"300\" height=\"286\" class=\"aligncenter size-medium wp-image-1296\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Configuration-300x286.png 300w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Configuration.png 451w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>When PuTTY tries to connect to your home router a security notice will pop up because you are creating a secure connection. Accept the notice by pressing Yes. Note that you will only need to verify this when you first establish a connection. Future logons will use these credentials.<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Security-Alert.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Security-Alert-300x187.png\" alt=\"PuTTY Security Alert\" width=\"300\" height=\"187\" class=\"aligncenter size-medium wp-image-1298\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Security-Alert-300x187.png 300w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY-Security-Alert.png 405w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>To actually login your user name is root and your password is whatever you typed in earlier. The result is that you have connected to your module over Etherent<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY_login.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY_login-300x132.png\" alt=\"PuTTY_login\" width=\"300\" height=\"132\" class=\"aligncenter size-medium wp-image-1297\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY_login-300x132.png 300w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/PuTTY_login.png 593w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Just for fun I also logged into the module at 192.168.1.130 wirelessly from my Linux computer as follows.<br \/>\n<a href=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/SSH_Wireless.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/SSH_Wireless-300x147.png\" alt=\"SSH_Wireless\" width=\"300\" height=\"147\" class=\"aligncenter size-medium wp-image-1299\" srcset=\"http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/SSH_Wireless-300x147.png 300w, http:\/\/www.dnclabs.com\/wp-content\/uploads\/2015\/06\/SSH_Wireless.png 712w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>VI commands<\/h2>\n<p>The default configurations of openWRT provides a minimal editor in the form of VI. This is a short list of some of the more useful commands that I use to edit configuration files on the module.<\/p>\n<h3>General Startup<\/h3>\n<pre>\r\n\tTo use vi: vi filename\r\n\tTo exit vi and save changes: ZZ   or  :wq\r\n\tTo exit vi without saving changes: :q!\r\n\tTo enter vi command mode: [esc]\r\n<\/pre>\n<h3>Inserting<\/h3>\n<pre>\r\n     \t r        replace character under cursor with next character typed\r\n      \t R        keep replacing character until [esc] is hit\r\n      \t i        insert before cursor\r\n      \t a        append after cursor\r\n      \t A        append at end of line\r\n       \t O        open line above cursor and enter append mode\r\n<\/pre>\n<h3>Deleting<\/h3>\n<pre>\r\n\tx       delete character under cursor\r\n\tdd      delete line under cursor\r\n\tdw      delete word under cursor\r\n\tdb      delete word before cursor\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>It has been a long time coming but we are finally ready to install OpenWRT. I have provided a pre-built image for this. Using the Uboot loader we can install a new Linux image on our module. This only takes&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.dnclabs.com\/?p=1302\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1302","post","type-post","status-publish","format-standard","hentry","category-embedded-linux"],"_links":{"self":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1302"}],"version-history":[{"count":10,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1302\/revisions"}],"predecessor-version":[{"id":1319,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=\/wp\/v2\/posts\/1302\/revisions\/1319"}],"wp:attachment":[{"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1302"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dnclabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}