[Solved] Need Help Installing Driver

I am running DietPi on an Allo Sparky and am trying to load a driver for the Anker USB 3.0 to Gigabit adapter because it did not link up after plugging into my network. Anker provided a link to Realtek and got a set of files from them. I put them in the /mnt/dietpi_userdata directory:

50-usb-realtek-net.rules compatibility.h Makefile r8152.c ReadMe.txt

After a little research about makefiles, I realized I needed to install ‘make’. I managed to install ‘make’ after downloading this package: make_4.1-9.1_armhf.deb

After running the command ‘make’, I get the following:

make -C /lib/modules/3.10.38/build SUBDIRS=/mnt/dietpi_userdata/r8152-2.11.0 modules
make[1]: *** /lib/modules/3.10.38/build: No such file or directory. Stop.
Makefile:19: recipe for target ‘modules’ failed
make: *** [modules] Error 2

At this point and my limited amount of Linux knowledge, I ask for help.

Thanks,
Steve

A little bit more info. I changed to the /lib/modules/3.10.38 directory and found this (in red font) after ls -al:

lrwxrwxrwx 1 root root 66 Dec 11 2017 build → /imxhdd/opt/1301TAG/sparky_volumio/owl/out/sparky_sd_ubuntu/kernel

sledwards
Btw.: You should install make from the APT repo:

apt install make

You need the kernel headers to build the kernel module.

There seems to be an obsolete symlink in place (build → /imxhdd/opt/1301TAG/sparky_volumio/owl/out/sparky_sd_ubuntu/kernel) that was most likely used to build the image from scratch, which the actual kernel headers on an external drive.

Here is how to do install them freshly on SparkySBC: https://github.com/sparkysbc/Module_build

I adjusted the steps a bid to work around the not required Git client:

cd /usr/src
wget https://github.com/sparkysbc/Linux/archive/master.zip
unzip master.zip
rm master.zip
mv Linux-master Linux
rm -R /lib/modules/$(uname -r)/build
rm -R /lib/modules/$(uname -r)/source
ln -s /usr/src/Linux /lib/modules/$(uname -r)/build
cd Linux
make mrproper
wget https://raw.githubusercontent.com/sparkysbc/Module_build/master/Module.symvers
make modules_prepare

Then retry to build your driver module according to it’s ReadMe.txt.

MichaIng

I ran all the commands you gave me, and when I ran the last line, I got these errors:

/usr/src/Linux/scripts/kconfig/Makefile:36: recipe for target ‘silentoldconfig’ failed
make[2]: *** [silentoldconfig] Error 1
/usr/src/Linux/Makefile:519: recipe for target ‘silentoldconfig’ failed
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target ‘modules_prepare’. Stop.


Steve

MichaIng

I forgot this warning:

scripts/kconfig/conf --silentoldconfig Kconfig


*** Configuration file “.config” not found!


*** Please run some configurator (e.g. “make oldconfig” or
*** “make menuconfig” or “make xconfig”).


Do you have the output of make mrproper still there? That should create the requested .config file, if I understood correctly.

But perhaps this is not even required, please retry the make command within your Ethernet driver dir, before going on with below.

Check find /boot -name ‘.config’ if the boot dir has the currently active .config file. Not sure how this is on Sparky SBC, this is just what I got from the instructions.

The instructions from the link above suggest to otherwise download the default .config file (from within the Linux source dir):

cd /usr/src/Linux
wget https://raw.githubusercontent.com/sparkysbc/Module_build/master/.config

MichaIng

I started from scratch from a clean DietPi install. I added the .config file and the make modules_prepare got a lot farther along until this:

include/linux/compiler-gcc.h:103:30: fatal error: linux/compiler-gcc6.h: No such file or directory
#include gcc_header(GNUC)
^
compilation terminated.
/usr/src/Linux/./Kbuild:35: recipe for target ‘kernel/bounds.s’ failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:851: recipe for target ‘prepare0’ failed
make: *** [prepare0] Error 2

Steve

MichaIng

I found this in a Readme file for the driver instructions of another device using the same ax88179 chipset:

Prepare to build the driver, you need the Linux kernel sources installed on the
build machine, and make sure that the version of the running kernel must match
the installed kernel sources. If you don’t have the kernel sources, you can get
it from www.kernel.org or contact to your Linux distributor. If you don’t know
how to do, please refer to KERNEL-HOWTO.

Note: Please make sure the kernel is built with one of the “Support for
Host-side, EHCI, OHCI, or UHCI” option support.

MichaIng

I managed to resolve the latest error by creating a symlink :

ln -s compiler-gcc4.h compiler-gcc6.h (created it in the linux directory /usr/src/Linux/include/linux)

The make modules_prepare worked, and I was able to create the driver file r8152.ko without errors. When I try to install it using these commands:

modprob usbnet
insmod r8152.ko

This error comes back:

insmod: ERROR: could not insert module r8152.ko: Unknown symbol in module

At this point I am clueless on how to proceed, Your help so far has been great.

Steve

Does the readme contain some pre-req modules? I found a similar error, where another module needed to be enabled first to resolve it: https://github.com/kuba-moo/mt7601u/issues/2

Perhaps modinfo r8152.ko also gives a clue.

Ahh, type dmesg directly after trying insmod r8152.ko and copy paste the last lines which should contain the Unknown symbol error(s).

MichaIng

There was no pre-req files listed in my driver package. I found this link which I thought would be the solution:

https://www.pcsuggest.com/install-rtl8153-driver-linux/

Went thru all the steps, and at when I tried my USB 3.0 to Gigabit dongle, it did not work. Unfortunately, the ethernet port was also disabled and I had no way back into the machine via ssh (no monitor or keyboard). So I started over with a fresh install of dietpi. My gut feeling is this would be plug and play if dietpi for Sparky used a newer kernel (4.x).

Anyways, I did do a dmesg after insmod and got a very generic warning message within. I will need to repeat the whole procedure again to give you a better answer. Maybe if you take a look at the link I provided it will shed some light as to whats going on.

Steve

MichaIng

Following that new procedure again with fresh install of dietpi, I get this:

root@Office:/Downloads# sudo apt-get install libelf-dev build-essential linux-headers-uname -r
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package linux-headers-3.10.38
E: Couldn’t find any package by glob ‘linux-headers-3.10.38’
E: Couldn’t find any package by regex ‘linux-headers-3.10.38’

I am guessing I really need those linux-headers for my install? Any suggestions?

The Linux headers for Sparky SBC are not available on APT repo. Check my first answer again about the steps to download and place the headers manually.

A newer kernel would be great, but the official upstream kernel is still on v3.10.38: https://github.com/sparkysbc/Linux
Also ARMbian does not have an image for it. They usually have updated own build kernels, but Sparky SBC is not in their portfolio.

MichaIng

Here is the dmesg error after insmod:

r8152: Unknown symbol GLOBAL_OFFSET_TABLE (err 0)

Again little web search attempt:
Can you edit the Makefile in the drivers directory, find the line starting with MODFLAGS or CFLAGS_MODULE and append -fno-pic (with leading white space)?
Then rerun make and retry to enable the module.

MichaIng

I can not find those commands. Here is the entire Makefile:

ifneq ($(KERNELRELEASE),)
obj-m := r8152.o

EXTRA_CFLAGS += -DRTL8152_S5_WOL

EXTRA_CFLAGS += -DRTL8152_DEBUG

else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
TARGET_PATH := kernel/drivers/net/usb
INBOXDRIVER := $(shell find $(subst build,$(TARGET_PATH),$(KERNELDIR)) -name r8152.ko.* -type f)
RULEFILE = 50-usb-realtek-net.rules
RULEDIR = /etc/udev/rules.d/

.PHONY: modules
modules:
$(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules

.PHONY: all
all: clean modules install

.PHONY: clean
clean:
$(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) clean

.PHONY: install
install:
ifneq ($(shell lsmod | grep r8152),)
rmmod r8152
endif
ifneq ($(INBOXDRIVER),)
rm -f $(INBOXDRIVER)
endif
$(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) INSTALL_MOD_DIR=$(TARGET_PATH) modules_install
modprobe r8152

.PHONY: install_rules
install_rules:
install --group=root --owner=root --mode=0644 $(RULEFILE) $(RULEDIR)

endif

Okay then add the line: CFLAGS_MODULE = -fno-pic directly after the three # at the top.

MichaIng

Well, new errors:

After insmod:

ERROR: could not insert module r8152.ko: Device or resource busy

dmesg reads:

Error: Driver ‘r8152’ is already registered, aborting…

If I do an ‘lsmod’, I do not see the driver

Module Size Used by
nls_cp437 5150 1
ethernet 64021 0
spidev 6636 0
atc260x_cap_gauge 27668 0
atc260x_irkeypad 12310 0
autofs4 29844 0

MichaIng

Thanks for all of the help. I am purchasing a new adapter that has been reported to work with the Sparky USBridge.