{"id":1443,"date":"2017-12-30T16:33:30","date_gmt":"2017-12-30T21:33:30","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=1443"},"modified":"2017-12-30T16:33:30","modified_gmt":"2017-12-30T21:33:30","slug":"downgrade-raspberry-pi-kernel","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=1443","title":{"rendered":"Downgrade Raspberry Pi kernel"},"content":{"rendered":"<p>So I upgraded my <a href=\"http:\/\/dietpi.com\/\" target=\"_blank\">DietPi<\/a> <a href=\"https:\/\/www.kernel.org\/\" target=\"_blank\">kernel<\/a> the other day and noticed there was no driver for Realtek 8188 driver for that kernel version. After playing around trying to compile the driver for the newest kernel I decided to downgrade the kernel. Thought it was difficult, but it&#8217;s quite easy. Only choose the kernel version you want to downgrade to from <a href=\"https:\/\/github.com\/Hexxeh\/rpi-firmware\" target=\"_blank\">here<\/a>, copy the hash and run rpi-update.<\/p>\n<pre id=\"terminal\">rpi-update  48cfa89779408ecd69db4eb793b846fb7fe40c4b\r\n<\/pre>\n<p>Hash above corresponds to kernel 4.4.11-v7+, with that kernel I was able to download the driver for my USB wifi using the script below:<br \/>\n[bash]<br \/>\n#!\/bin\/bash<br \/>\nset -e<\/p>\n<p>TOPIC_URL=&#8221;http:\/\/www.raspberrypi.org\/phpBB3\/viewtopic.php?p=462982&#8243;<\/p>\n<p># Download and install rpi driver for 8188eu-based wifi dongles<br \/>\n# from MrEngman&#8217;s dropbox.<br \/>\n#<br \/>\n# Version information is fetched from TOPIC_URL and appears as:<br \/>\n#<br \/>\n#   3.6.11+ #371 up to #520 inclusive    &#8211; 8188eu-20130209.tar.gz<br \/>\n#   3.6.11+ #524, #528, #532             &#8211; 8188eu-20130815.tar.gz<br \/>\n#   &#8230;<br \/>\n# then is matched against local kernel release and version numbers<br \/>\n# to select proper driver tarball.  Kernel build number can be overriden<br \/>\n# with command line option -k, in case no exact match is found.<\/p>\n<p>fetch_versions() {<br \/>\n\tcurl -s &#8220;$TOPIC_URL&#8221; \\<br \/>\n\t| sed &#8216;s:<code>\\|<\/code>\\|<br \/>:\\n:g&#8217; \\<br \/>\n\t| sed &#8216;s:&nbsp;: :g ; s:gz.*:gz:&#8217; \\<br \/>\n\t| grep -E &#8216;^[0-9.]+.*tar\\.gz&#8217;<br \/>\n}<\/p>\n<p>case &#8220;$1&#8221; in<br \/>\n\t-k|&#8211;kernel)<br \/>\n\t\tbuild=$2<br \/>\n\t\t;;<br \/>\n\t-l|&#8211;list)<br \/>\n\t\tfetch_versions<br \/>\n\t\texit 0<br \/>\n\t\t;;<br \/>\n\t-h|&#8211;help)<br \/>\n\t\techo &#8220;usage: `basename $0`&#8221; \\<br \/>\n\t\t\t&#8220;[-k|&#8211;kernel <kernel build>]&#8221; \\<br \/>\n\t\t\t&#8220;[-l|&#8211;list]&#8221;<br \/>\n\t\texit 0<br \/>\n\t\t;;<br \/>\n\t&#8220;&#8221;)<br \/>\n\t\t;; # proceed to install<br \/>\n\t*)<br \/>\n\t\techo &#8220;unknown command: $1&#8221; >&#038;2<br \/>\n\t\t$0 &#8211;help<br \/>\n\t\texit 1<br \/>\n\t\t;;<br \/>\nesac<\/p>\n<p>kernel=$(uname -r)<br \/>\nbuild=${build:-$(uname -v | awk &#8216;{print $1}&#8217; | tr -d &#8216;#&#8217;)}<\/p>\n<p>if [ $kernel = &#8220;3.6.11+&#8221; ] &#038;&#038; [ $build -gt 370 ] &#038;&#038; [ $build -lt 521 ] ; then<br \/>\n\ttarfile=8188eu-20130209.tar.gz<br \/>\nelse<br \/>\n\ttarfile=$(fetch_versions \\<br \/>\n\t\t| grep -e &#8220;^$kernel &#8221; \\<br \/>\n\t\t| grep -E &#8220;#$build[, ]&#8221; \\<br \/>\n\t\t| awk &#8216;{print $NF}&#8217;)<br \/>\nfi<\/p>\n<p>if [ ! &#8220;$tarfile&#8221; ] ; then<br \/>\n\techo &#8220;cannot match kernel: $kernel #$build&#8221;<br \/>\n\techo &#8220;please check news at $TOPIC_URL&#8221;<br \/>\n\techo &#8220;or try closest compatible version with -k <kernel build>&#8221;<br \/>\n\texit 1<br \/>\nfi<\/p>\n<p>tmpdir=$(mktemp -d)<br \/>\ntrap &#8220;\\rm -rf $tmpdir&#8221; EXIT<br \/>\ncd $tmpdir<\/p>\n<p>echo &#8220;downloading $tarfile (kernel $kernel #$build)&#8221;<br \/>\ncurl -s https:\/\/dl.dropboxusercontent.com\/u\/80256631\/$tarfile | tar xz<\/p>\n<p>module_bin=&#8221;8188eu.ko&#8221;<br \/>\nmodule_dir=&#8221;\/lib\/modules\/$kernel\/kernel\/drivers\/net\/wireless&#8221;<br \/>\nfirmware_bin=&#8221;rtl8188eufw.bin&#8221;<br \/>\nfirmware_dir=&#8221;\/lib\/firmware\/rtlwifi&#8221;<\/p>\n<p>if [ -f $firmware_bin ] ; then<br \/>\n\techo &#8220;installing firmware $firmware_bin&#8221;<br \/>\n\tsudo install -p -m 644 $firmware_bin $firmware_dir<br \/>\nfi<\/p>\n<p>echo &#8220;installing kernel module $module_bin&#8221;<br \/>\nsudo install -p -m 644 $module_bin $module_dir<br \/>\nsudo depmod -a<br \/>\n#sudo modprobe -r 8188eu || true # cannot currently be removed (&#8220;permanent&#8221;)<br \/>\nsudo modprobe -i 8188eu<br \/>\nlsmod | grep -q 8188eu || echo &#8220;error: module not loaded&#8221;<br \/>\n[\/bash]<\/p>\n<p>As per latest <a href=\"https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?p=462982#p462982\" target=\"_blank\">update<\/a> dl.dropboxusercontent.com is no longer valid and should be substituted by http:\/\/www.fars-robotics.net\/, but dl.dropboxusercontent.com worked for me. Now my wifi is working.<\/p>\n<pre id=\"terminal\">uname -a&#59; ifconfig wlan0&#59; lsmod | grep 8188&#59; lsusb\r\nLinux DietPi 4.4.11-v7+ #886 SMP Thu May 19 15:20:49 BST 2016 armv7l GNU\/Linux\r\nwlan0     Link encap:Ethernet  HWaddr 00:e0:4c:81:89:01  \r\n          inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0\r\n          inet6 addr: fe80::2e0:4cff:fe81:8901\/64 Scope:Link\r\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\r\n          RX packets:2262 errors:0 dropped:10 overruns:0 frame:0\r\n          TX packets:1659 errors:0 dropped:3 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:1000 \r\n          RX bytes:463049 (452.1 KiB)  TX bytes:274451 (268.0 KiB)\r\n8188eu                859474  0 \r\ncfg80211              427855  1 8188eu\r\nBus 001 Device 004: ID 0bda:8179 Realtek Semiconductor Corp. \r\nBus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512\/9514 Fast Ethernet Adapter\r\nBus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. \r\nBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\r\n<\/pre>\n<p>And below are my available kernels.<\/p>\n<pre id=\"terminal\">ls -ltr \/lib\/modules\r\ntotal 28\r\ndrwxr-xr-x 3 root root 4096 Mar 18  2016 4.1.18-v7+\r\ndrwxr-xr-x 3 root root 4096 Nov 17 23:58 4.9.62+\r\ndrwxr-xr-x 3 root root 4096 Dec 30 12:36 4.9.35+\r\ndrwxr-xr-x 3 root root 4096 Dec 30 12:36 4.9.35-v7+\r\ndrwxr-xr-x 3 root root 4096 Dec 30 14:52 4.9.62-v7+\r\ndrwxr-xr-x 3 root root 4096 Dec 30 19:49 4.4.11+\r\ndrwxr-xr-x 3 root root 4096 Dec 30 20:03 4.4.11-v7+\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>So I upgraded my DietPi kernel the other day and noticed there was no driver for Realtek 8188 driver for that kernel version. After playing around trying to compile the driver for the newest kernel I decided to downgrade the kernel. Thought it was difficult, but it&#8217;s quite easy. Only choose the kernel version you [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[87,6,88],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-nh","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1443"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1443"}],"version-history":[{"count":7,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1443\/revisions"}],"predecessor-version":[{"id":1450,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1443\/revisions\/1450"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}