Thursday 2 April 2020

Ubuntu WiFi problem resolved

If you have recently updated from any other operating system to Ubuntu or you have dual OS in your laptop then you might face the wifi problem, your laptop is having the wifi adapter but OS will show one message like you do not have the wifi adapter :



In this case you need to figure out that which wifi hardware is being used in you laptop,  "lspci" and "lshw" are two commands to find out the name of it,  follow the below snapshot




Now you know very well that your laptop have the wireless hardware but missing thing is the relative software of it, this kind of special software is known as the hardware drivers, these drivers are used to function the hardwares, you can google if you want to know the software drivers in details, basically software drivers are special software program which runs inside the operating system's kernel, each computer peripheral devices are having the relative drivers to perform the read/write operations, in my laptop the wireless hardware is provided by "Mediatek Corp..", i found the software in github i.e https://github.com/neurobin/MT7630E.git , you need to search the software in internet and then need to build it, i used the below steps to clone, build and install the wireless driver:

sudo apt-get install git build-essential
git clone https://github.com/neurobin/MT7630E.git
cd MT7630E/
chmod +x install test uninstall
sudo ./install
sudo reboot

Here the "install" script itself compiles and install the program in your computer, below are the content of the install script
#!/bin/bash
set -e
BASEDIR="$(dirname "$BASH_SOURCE")"
cd "$BASEDIR"
if (( $EUID != 0 )); then
    printf "\n-----Sorry! Run with root privilege (for example with 'sudo ./install')\n\n"
    exit 1
fi
KERNEL=${1-$(uname -r)}
make KERNEL=$KERNEL
make install KERNEL=$KERNEL
modprobe mt7630e -S $KERNEL
modprobe mt76xx -S $KERNEL
echo "
The driver has been successfully installed.
If you don't have wifi yet, try to reboot.
If bluetooth doesn't work, read the bluetooth
section in README.md file and follow through.
"
You can see above that the source code is compiled on the basis of current kernel architecture to generate the appropriate binary,  once kernel module is geing generated it is being inserted into the linux kernel.
For learning perspective you can also execute the makefile instead of executing the install script, makefile will have below kind of content inside that:
.PHONY: all clean install uninstall

KERNEL ?= `uname -r`
KDIR ?= /lib/modules/$(KERNEL)/build
DST_DIR ?= /lib/modules/$(KERNEL)/kernel/drivers/net/wireless/
PKG_VER ?= `sed -n 's/^[[:blank:]]*PACKAGE_VERSION=\([^[:blank:]]*\).*/\1/p' dkms.conf`

all:
        $(MAKE) -C $(KDIR) M=$(CURDIR)/rt2x00 modules
        $(MAKE) -C $(KDIR) M=$(CURDIR)/btloader modules

clean:
        $(MAKE) -C $(KDIR) M=$(CURDIR)/rt2x00 clean
        $(MAKE) -C $(KDIR) M=$(CURDIR)/btloader clean

install:
        cp -v firmware/*/* /lib/firmware/
        cp rt2x00/mt7630e.ko $(DST_DIR)
        cp btloader/mt76xx.ko $(DST_DIR)
        depmod $(KERNEL)

uninstall:
        rm -vf /lib/firmware/mt76x0.bin /lib/firmware/MT7650E234.bin
        rm -vf $(DST_DIR)/mt7630e.ko
        rm -vf $(DST_DIR)/mt76xx.ko
        depmod $(KERNEL)

dkms:
        cp -v firmware/*/* /lib/firmware/
        cp -R . /usr/src/mt7630e-$(PKG_VER)
        dkms add -m mt7630e -v $(PKG_VER)
        dkms build -m mt7630e -v $(PKG_VER) -k $(KERNEL)
        dkms install -m mt7630e -v $(PKG_VER) -k $(KERNEL)

"make" simply compile your source code and build the kernel module ( .ko file) for you, after that you can simply insert the module in ubuntu's kernel by mannual "insmod" commad, my makefile compilation terminal logs are below:
jeet@jeet-X200LA:~/Downloads/wifi-Driver-Ubuntu/MT7630E$ sudo make
make -C /lib/modules/`uname -r`/build M=/home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00 modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-91-generic'
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00dev.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00mac.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00config.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00queue.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00link.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/mt_linux.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00crypto.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00firmware.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00leds.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00mmio.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2800pci.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2800lib.o
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/rt2x00pci.o
  LD [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/mt7630e.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/mt7630e.mod.o
  LD [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/rt2x00/mt7630e.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-91-generic'
make -C /lib/modules/`uname -r`/build M=/home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/btloader modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-91-generic'
  CC [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/btloader/mt76xx.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/btloader/mt76xx.mod.o
  LD [M]  /home/jeet/Downloads/wifi-Driver-Ubuntu/MT7630E/btloader/mt76xx.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-91-generic'

Now kernel module is generated and ready to be inserted into the kernel, i ran the below command to insert:
jeet@jeet-X200LA:~/Downloads/wifi-Driver-Ubuntu/MT7630E$ sudo insmod rt2x00/mt7630e.ko 
insmod: ERROR: could not insert module rt2x00/mt7630e.ko: File exists
jeet@jeet-X200LA:~/Downloads/wifi-Driver-Ubuntu/MT7630E$ 

I already inserted therefore it is showing "File exists", below is the description:
jeet@jeet-X200LA:~/Downloads/wifi-Driver-Ubuntu/MT7630E$ lsmod | grep mt76
mt76xx                 20480  0
mt7630e               180224  0
mac80211              786432  1 mt7630e
cfg80211              622592  2 mt7630e,mac80211
eeprom_93cx6           16384  1 mt7630e

Now you must be able to find the wifi devices, go to setting and turn on the wifi, you must be able to see the wireless devices



The conclusion of the above story is that you need to find out the wireless hardware name then only you will able to find the driver, for almost all the mediatek devices to to https://www.mediatek.com/products/broadbandWifi/mt7630 link and read the appropriate information to resolve you issue.

If you need more help related to your wireless hardware then please comment i will try to resolve your all issues.





Follow me on instagram: Click Here ( Instagram Account)
Subscribe my Youtube channel: Click Here ( Youtube Channel)
Facebook account: Click Here ( Facebook Account)
Linkedin Account: Clicke Here ( Linkedin Account)
My Books:
    India Tourism: India Tourism EBook
    Love story of an engineer: Love Story of an Engineer Ebook






No comments:

Post a Comment

Nirmit Camp Life & Came back to Gurgaon

D ear readers, You knew that I have reached the Naukuchiatal in my previous blog, As everyone knows that the entire Uttarakhand is the place...