{"id":1900,"date":"2021-10-10T11:38:53","date_gmt":"2021-10-10T15:38:53","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=1900"},"modified":"2021-10-10T11:38:53","modified_gmt":"2021-10-10T15:38:53","slug":"openwrt-19-07-to-21-02-0-upgrade","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2021\/openwrt-19-07-to-21-02-0-upgrade\/","title":{"rendered":"OpenWRT 19.07 to 21.02.0 upgrade"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1906\" src=\"https:\/\/lowtek.ca\/roo\/wp-content\/uploads\/2021\/10\/logo_owrt.png\" alt=\"\" width=\"386\" height=\"98\" \/><\/p>\n<p>I&#8217;ve long been a fan of open firmware for my home routers. Way back I started with <a href=\"https:\/\/lowtek.ca\/roo\/2012\/how-to-dd-wrt-on-the-netgear-wnr3500l\/\">DD-WRT<\/a>, but more recently I&#8217;ve moved to <a href=\"https:\/\/openwrt.org\/\">OpenWRT<\/a> paired with <a href=\"https:\/\/openwrt.org\/toh\/tp-link\/archer_c7\">TP-Link Archer C7<\/a> hardware. I actually have two, one as my main gateway and a second configured as a <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/network\/wifi\/dumbap\">dumb AP <\/a>(access point). Running two WiFi access points means I get great coverage from the basement, to the second floor.<\/p>\n<p>While I have two, they are not quite identical. One is a v5, and the other is a v2. Still, for hardware you can pick up for <a href=\"https:\/\/www.canadacomputers.com\/product_info.php?cPath=27_1046_365&amp;item_id=063780\">under $100<\/a> it fits into my sweet spot for hardware. I picked up both of mine used, for less than half the price of new hardware. The other benefit to having two which run the same software stack (OpenWRT 19.07), means I can swap hardware for the main gateway if I have a compatibility problem.<\/p>\n<p>Recently the latest version (21.02) has been declared stable. It&#8217;s well past time to <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/installation\/generic.sysupgrade\">upgrade<\/a>. With the hardware I have, OpenWRT has recently done a transition from <a class=\"wikilink1\" title=\"docs:techref:targets:ar71xx\" href=\"https:\/\/openwrt.org\/docs\/techref\/targets\/ar71xx\" data-wiki-id=\"docs:techref:targets:ar71xx\">ar71xx<\/a> to <a class=\"wikilink1\" title=\"docs:techref:targets:ath79\" href=\"https:\/\/openwrt.org\/docs\/techref\/targets\/ath79\" data-wiki-id=\"docs:techref:targets:ath79\">ath79<\/a>. Thankfully In my setup with 19.07 I&#8217;d already moved to ath79.<\/p>\n<p>You can check the <code>TARGET<\/code> that you are running by ssh&#8217;ing into the router and looking at the <code>\/etc\/openwrt-release<\/code> file<\/p>\n<pre class=\"lang:default decode:true \"># cat \/etc\/openwrt_release  | grep TARGET\r\nDISTRIB_TARGET='ath79\/generic'<\/pre>\n<p>It is a good idea to start with the <a href=\"https:\/\/openwrt.org\/releases\/21.02\/notes-21.02.0\">release notes<\/a>. The upgrade process is 3 parts.<\/p>\n<ol>\n<li id=\"part_1_-_prepare\">Prepare<\/li>\n<li>Upgrade<\/li>\n<li>Post Install Configuration, Setup or Restore<\/li>\n<\/ol>\n<div class=\"level4\">\n<div class=\"level4\"><\/div>\n<\/div>\n<p>We&#8217;ve already started the <strong>Prepare<\/strong> step since we have looked at the release notes and made sure we have the ath79 version running. Since we&#8217;re already on ath79 we can use the normal sysupgrade process. OpenWRT is also moving to <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/network\/dsa\/start\">DSA Networking<\/a>, but the hardware I&#8217;m using hasn&#8217;t switched over yet &#8211; the upgrade process will detect this and refuse to upgrade if you have a problem.<\/p>\n<p>I&#8217;ve got a full rsync backup of my router configuration, so if something goes really wrong I at least have the files.<\/p>\n<p>Next I need to figure out which packages I have installed on the router(s). <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/installation\/generic.sysupgrade#script_by_tboege\">This script<\/a> seems to work well, I&#8217;ll duplicate the script here.<\/p>\n<pre class=\"lang:default decode:true \">cat &lt;&lt; \"EOF\" &gt; \/tmp\/listuserpackages.awk\r\n#!\/usr\/bin\/awk -f\r\nBEGIN {\r\n    ARGV[ARGC++] = \"\/usr\/lib\/opkg\/status\"\r\n    cmd=\"opkg info busybox | grep '^Installed-Time: '\"\r\n    cmd | getline FLASH_TIME\r\n    close(cmd)\r\n    FLASH_TIME=substr(FLASH_TIME,17)\r\n}\r\n\/^Package:\/{PKG= $2}\r\n\/^Installed-Time:\/{\r\n    INSTALLED_TIME= $2\r\n    # Find all packages installed after FLASH_TIME\r\n    if ( INSTALLED_TIME &gt; FLASH_TIME ) {\r\n        cmd=\"opkg whatdepends \" PKG \" | wc -l\"\r\n        cmd | getline WHATDEPENDS\r\n        close(cmd)\r\n        # If nothing depends on the package, it is installed by user\r\n        if ( WHATDEPENDS == 3 ) print PKG\r\n    }\r\n}\r\nEOF\r\n \r\n# Run the script\r\nchmod +x \/tmp\/listuserpackages.awk\r\n\/tmp\/listuserpackages.awk<\/pre>\n<p>This will dump out the list of packages that you have installed beyond the stock configuration. I&#8217;ve got <code>rsync<\/code> installed (of course) along with the <code>prometheus<\/code> packages. The upgrade will not automatically install these packages, so having the list of them helps us get back to the configuration we are used to.<\/p>\n<p>We should now be ready to <strong>Upgrade<\/strong>. I found the easiest way to get the right sysupgrade package was using the <a href=\"https:\/\/firmware-selector.openwrt.org\/\">Firmware Selector<\/a> web tool. Since I have slightly different versions, I needed to make two downloads.<\/p>\n<p>It is always a good idea to check the hash (sha256sum) of the files you download to make sure you have a good download. I&#8217;ve been burned only a handful of times by this, but once should be enough to teach you the lesson.<\/p>\n<p>Using the Web UI to upgrade can be found in the menu system: <strong>LuCI \u2192 System \u2192 Backup \/ Flash Firmware \u2192 Actions: Flash new firmware image<\/strong>.<\/p>\n<p>Time for a deep breath, and double check we have a backup. Time to flash, also double checking we push the right version to the right device.<\/p>\n<p>After flashing the 1st device, I noted two things. The &#8220;flashing&#8221; screen seemed to get stuck &#8211; well past when the device has refreshed. Using a second browser window, I think I figured out why things got stuck. The <a href=\"https:\/\/openwrt.org\/docs\/techref\/luci\">LuCI web UI<\/a> now redirects you to https:\/\/ with a self signed certificate. I think the browser on the flash screen got stuck because of the change in protocol (and the bad cert).<\/p>\n<p>It&#8217;s good that the web UI is now hosted using https because now when you log in, you&#8217;re not sending your passwords in the clear. Sure it&#8217;s your own network, but I think I&#8217;d rather have to deal with clicking through the advanced screens to tell my browser to accept the self signed certificate than not have a secure connection.<\/p>\n<p>For the <strong>Post Install Configuration, Setup or Restore <\/strong>step\u00a0it&#8217;s a matter of going through the packages I&#8217;d identified above and re-installing them. As a second check, I also re-installed an re-ran the listuserpackages.awk script and got the same list back once I&#8217;d installed all the packages.<\/p>\n<p>I can also verify that all of the configuration files made it by testing the functions these additional packages had. All was good, at least with my dumb AP.<\/p>\n<p>My main gateway router was a bit scarier &#8211; it&#8217;s got a few more packages installed than the dumb AP and when I update it, I take an internet outage. Also, I ran into trouble trying to update some of the modules:<\/p>\n<ul>\n<li>kmod-usb-storage<\/li>\n<li>kmod-usb3<\/li>\n<\/ul>\n<p>Both of these are related to my use of a USB drive as storage for the vnStat package. This appears to be <a href=\"https:\/\/bugs.openwrt.org\/index.php?do=details&amp;task_id=4006&amp;order=dateopened&amp;sort=desc\">a bug in the web UI<\/a> &#8211; either way, using the cli worked fine to install things. It also looks like a fix is coming in the next patch.<\/p>\n<p>The cli was happy to find the package<\/p>\n<pre class=\"lang:default decode:true \"># opkg list | grep usb-storage\r\nkmod-usb-storage - 5.4.143-1 - Kernel support for USB Mass Storage devices\r\nkmod-usb-storage-extras - 5.4.143-1 - Say Y here if you want to have some more drivers, such as for SmartMedia card readers\r\n<\/pre>\n<p>Where the web UI simply failed to located it.<\/p>\n<p>In the end all was well, and a reboot to make sure things all came back just fine got me back to a fully working state but on the latest version. This was much easier than I had expected and I shouldn&#8217;t have stalled doing this so long.<\/p>\n<p>A few housekeeping details to work through post install \/ basic check out. The upgrade procedure will create <code>*-opkg<\/code> files in <code>\/etc\/config<\/code> when you install the new packages. Be safe and do a quick diff and review of what has or has not changed (you may need to install the diffutils package, or move the files off the device to a machine that can diff things).<\/p>\n<p>In my case &#8211; the <a href=\"https:\/\/openwrt.org\/docs\/guide-user\/network\/traffic-shaping\/sqm\">sqm package<\/a> seems to have changed at least some of the options. My setup still works, but I should probably rebase my config file.<\/p>\n<p>Other stuff I have to fiddle with. <a href=\"https:\/\/openwrt.org\/releases\/21.02\/notes-21.02.0#wpa3_support_included_by_default\">WPA3<\/a> &#8211; now\u00a0 mainline for OpenWRT I need to figure out how to run with this new protocol (while not breaking the world). A quick look around makes it seem like WPA3 is still a bit on the bleeding edge.<\/p>\n<p>There is also <a href=\"https:\/\/openwrt.org\/releases\/21.02\/notes-21.02.0#new_network_configuration_syntax_and_boardjson_change\">New network configuration syntax and board.json change<\/a> which means some changes in <code>\/etc\/config\/network<\/code> which I should probably make sure I migrate to (the current build has some backwards compatibility &#8211; so my old file is fine for now).<\/p>\n<p>Doing a planned migration \/ upgrade was way better than my usual emergency restore \/ rebuild. The last time I was messing with the router firmware I&#8217;d accidentally run an rsync backup and gotten the source \/ target the wrong way around &#8211; successfully sync&#8217;ing a blank directly onto my operating access point. Doh.<\/p>\n<p>Anyways, hopefully this article helps me (or someone else) upgrade smoothly in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve long been a fan of open firmware for my home routers. Way back I started with DD-WRT, but more recently I&#8217;ve moved to OpenWRT paired with TP-Link Archer C7 hardware. I actually have two, one as my main gateway and a second configured as a dumb AP (access point). Running two WiFi access points &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2021\/openwrt-19-07-to-21-02-0-upgrade\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;OpenWRT 19.07 to 21.02.0 upgrade&#8221;<\/span><\/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,21],"tags":[],"class_list":["post-1900","post","type-post","status-publish","format-standard","hentry","category-computing","category-network"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=1900"}],"version-history":[{"count":6,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1900\/revisions"}],"predecessor-version":[{"id":1907,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/1900\/revisions\/1907"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=1900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=1900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=1900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}