Ubuntu – Can’t install driver for TP-Link T1U USB on Ubuntu 18.04 (kernel 4.15.0-36-generic)

18.04realtek-wirelesstp-link

I'm trying to install a Tp-Link T1U USB adapter on my machine.
I'm currently running Ubuntu 18.04 with a 4.15.0-36-generic kernel.
I've been looking at a few solutions for a couple of days, namely:
https://github.com/ashaffer/rt3573sta
https://github.com/lixz789/mt7610u_wifi_sta_v3002_dpo_20130916/pull/1

This is what I'm doing to install, following the README I downloaded and the suggested patch in the second link I posted:

sudo apt-get install git build-essential
$ mkdir ~/src
$ cd ~/src
$ git clone https://github.com/Myria-de/mt7610u_wifi_sta_v3002_dpo_20130916.git
$ git clone https://github.com/lixz789/mt7610u_wifi_sta_v3002_dpo_20130916.git
$ cd mt7610u_wifi_sta_v3002_dpo_20130916
$ make

This is what I get back:

make -C tools
make[1]: Entering directory '/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/tools'
gcc -g bin2h.c -o bin2h
make[1]: Leaving directory '/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/tools'
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/tools/bin2h
chipset = mt7610u
cp -f os/linux/Makefile.6 /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/Makefile
make -C /lib/modules/4.15.0-36-generic/build SUBDIRS=/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-36-generic'
Makefile:975: "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
CC [M]  /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.o
In file included from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_os.h:44:0,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_comm.h:75,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rt_config.h:33,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:28:
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/os/rt_linux.h:77:0: warning: "EXT_BUILD_CHANNEL_LIST" redefined
#define EXT_BUILD_CHANNEL_LIST  /* must define with CRDA */

<command-line>:0:0: note: this is the location of the previous definition
In file included from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/os/rt_linux.h:98:0,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_os.h:44,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_comm.h:75,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rt_config.h:33,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:28:
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/cfg80211.h:35:49: error: 'IEEE80211_NUM_BANDS' undeclared here (not in a function); did you mean 'IEEE80211_NUM_ACS'?
struct ieee80211_supported_band Cfg80211_bands[IEEE80211_NUM_BANDS];
                                             ^~~~~~~~~~~~~~~~~~~
                                             IEEE80211_NUM_ACS
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c: In function 'announce_802_3_packet':
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:341:16: warning: unused variable 'pAd' [-Wunused-variable]
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)pAdSrc;
            ^~~
In file included from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_os.h:44:0,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rtmp_comm.h:75,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/rt_config.h:33,
             from /home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:28:
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c: In function 'STA_MonPktSend':
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:450:35: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
     DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
                               ^                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/include/os/rt_linux.h:669:16: note: in definition of macro 'DBGPRINT_RAW'
     printk Fmt;               \
            ^~~
/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.c:450:9: note: in expansion of macro 'DBGPRINT'
     DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
     ^~~~~~~~
scripts/Makefile.build:332: recipe for target '/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.o' failed
make[2]: *** [/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/../../os/linux/rt_profile.o] Error 1
Makefile:1551: recipe for target '_module_/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux' failed
make[1]: *** [_module_/home/momissimi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-36-generic'
Makefile:403: recipe for target 'LINUX' failed
make: *** [LINUX] Error 2

I'm in no shape or form, capable of translating all that and have no idea how to move forward.

Any help would be great.

NB: I hope I haven't made a mistake posting anything. I did try following the guidelines, but I'm not all that familiar.

Best Answer

Ahhhh! The always tricky, never straightforward mt7610u!

This driver has a difficult history with later Linux kernels, for example, here: https://ubuntuforums.org/showthread.php?t=2367163&highlight=mt7610u You might be interested in my post #18.

However, post #4 here claims that it is now working! https://ubuntuforums.org/showthread.php?t=2375919 We shall soon find out.

With a working internet connection by ethernet, tethering or whatever means possible, open a terminal and do:

sudo apt update
sudo apt install git
git clone https://github.com/ulli-kroll/mt7610u.git
cd mt7610u
make
sudo make installfw
sudo insmod mt7610u.ko

Before we proceed with further needed steps, tell us if a wireless interface is created:

iwconfig

...and if you can connect, pull web pages, etc., without difficulty.

EDIT: Let's be sure you have the 'master' branch. First, remove the possibly faulty file:

cd /home/momissimi
sudo rm -r mt7610u
git clone -b master https://github.com/ulli-kroll/mt7610u.git
cd mt7610u
make
sudo make installfw
sudo insmod mt7610u.ko

Any improvement?