Install r8152 module driver

It happens that I’d need a second ethernet port. So I bought an usb RTL8152 Fast Ethernet Adapter.
But it seems that in the image I built from Fenix some days ago for Vim3 board that driver is not available:
lsmod | grep r8152 returns nothing and I don’t see any network interface added.

Building the sources downloaded from Realtek returns an error:
khadas@Khadas:~/tools/r8152-2.13.0$ make
find: ‘/lib/modules/4.9.224/kernel/drivers/net/usb’: No such file or directory
make -C /lib/modules/4.9.224/build M=/home/khadas/tools/r8152-2.13.0 modules
make[1]: Entering directory ‘/usr/src/linux-headers-4.9.224’
CC [M] /home/khadas/tools/r8152-2.13.0/r8152.o
In file included from ./include/linux/irqflags.h:15,
from ./include/linux/spinlock.h:53,
from ./include/linux/mmzone.h:7,
from ./include/linux/gfp.h:5,
from ./include/linux/slab.h:14,
from /home/khadas/tools/r8152-2.13.0/r8152.c:13:
./arch/arm64/include/asm/irqflags.h:24:10: fatal error: …/drivers/amlogic/debug/irqflags_debug_arm64.h: No such file or directory
24 | #include <…/drivers/amlogic/debug/irqflags_debug_arm64.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:341: /home/khadas/tools/r8152-2.13.0/r8152.o] Error 1
make[1]: *** [Makefile:1653: module/home/khadas/tools/r8152-2.13.0] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-4.9.224’
make: *** [Makefile:24: modules] Error 2

Seeking for advices
Thanks
F

Seems irqflags_debug_arm64.h is missing, can you copy it from linux source code to the board and try again?

1 Like

@numbqq

Once placed the missing header file I was able to build r8152.ko

> modinfo ./r8152.ko
filename:       /home/khadas/tools/r8152-2.13.0/./r8152.ko
version:        v2.13.0 (2020/04/20)
license:        GPL
description:    Realtek RTL8152/RTL8153 Based USB Ethernet Adapters
author:         Realtek nic sw <nic_swsd@realtek.com>
srcversion:     B118870984E2E7F4366524E
...

Then I ran ‘sudo make install’ getting the following error:

khadas@Khadas:~/tools/r8152-2.13.0$ sudo make install
find: ‘/lib/modules/4.9.224/kernel/drivers/net/usb’: No such file or directory
make -C /lib/modules/4.9.224/build M=/home/khadas/tools/r8152-2.13.0 INSTALL_MOD_DIR=kernel/drivers/net/usb modules_install
make[1]: Entering directory '/usr/src/linux-headers-4.9.224'
  INSTALL /home/khadas/tools/r8152-2.13.0/r8152.ko
  DEPMOD  4.9.224
make[1]: Leaving directory '/usr/src/linux-headers-4.9.224'
modprobe r8152
modprobe: FATAL: Module r8152 not found in directory /lib/modules/4.9.224
make: *** [Makefile:42: install] Error 1

Do I have to rebuild the kernel including the missing module?

Regards
F

wait,
running ‘sudo depmod -a’ fixed it

Yes, it works!
I successfully created a new network interface eth1:

khadas@Khadas:~/tools/r8152-2.13.0$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.181  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::8f43:5286:cbb3:c60d  prefixlen 64  scopeid 0x20<link>
        ether c8:63:14:70:53:97  txqueuelen 1000  (Ethernet)
        RX packets 2269  bytes 510323 (510.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2414  bytes 487004 (487.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 14  

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::e736:a87d:3953:bc22  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:4e:3a:4b:5a  txqueuelen 1000  (Ethernet)
        RX packets 182  bytes 8372 (8.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 51  bytes 7594 (7.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Thank you @numbqq

3 Likes