porting rtl8111g driver error

I used LAN chip - rtl8111g in my custom board, while Tegra TK1 board used rtl8111gs.
The models of these two chips are not the same. Thus, I must have to port driver.

I’m compiling r8168 version of linux driver source

I try to adding these lines in src/makefile by using the cross-platform compiler.

export ARCH=arm
export CROSS_COMPILE = arm-none-linux-gnueabi-
CROSS_COMPILE = arm-none-linux-gnueabi-
CC	      = $(CROSS_COMPILE)gcc

And specify the KernelDIR path which is released by nvidia as kernel source

[[cross compiler]]
Host: My Computer

cadtc@cadtc:~/jetson-TK1/driver/r8168-8.039.00/src$ make
make -C /home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel SUBDIRS=/home/cadtc/jetson-TK1/driver/r8168-8.039.00/src clean
make[1]: Entering directory `/home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel'
  CLEAN   /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/.tmp_versions
make[1]: Leaving directory `/home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel'
make -C /home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel SUBDIRS=/home/cadtc/jetson-TK1/driver/r8168-8.039.00/src modules
make[1]: Entering directory `/home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel'
  CC [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/r8168_n.o
  CC [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/r8168_asf.o
  CC [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/rtl_eeprom.o
  CC [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/rtltool.o
  LD [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/r8168.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/r8168.mod.o
  LD [M]  /home/cadtc/jetson-TK1/driver/r8168-8.039.00/src/r8168.ko
make[1]: Leaving directory `/home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel'
make -C /home/cadtc/jetson-TK1/r21.1_Linux_for_Tegra/source/kernel SUBDIRS=/home/cadtc/jetson-TK1/driver/r8168-8.039.00/src INSTALL_MOD_DIR=kernel/drivers/net/ethernet/realtek modules_install

[Check the file format]

cadtc@cadtc:~/jetson-TK1/driver/r8168-8.039.00/src$ file r8168.ko 
r8168.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), BuildID[sha1]=0x34b93f446ea3861813ca2952dd7c072cf6067d3a, not stripped

[Target: Custom board]

ubuntu@tegra-ubuntu:~$ sudo cp r8168.ko /lib/modules/3.10.40-ged4f697/kernel/net/
ubuntu@tegra-ubuntu:~$ sudo depmod
ubuntu@tegra-ubuntu:~$ sudo modprobe r8168
modprobe: ERROR: could not insert 'r8168': Exec format error

The results are actually the same, whether i used local compiler and cross compiler.
modprobe: ERROR: could not insert ‘r8168’: Exec format error

[[local compiler]]

ubuntu@tegra-ubuntu:~$ sudo apt-get install linux-source kernel-package
[sudo] password for ubuntu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
Suggested packages:
  grub grub2 jfsutils mcelog oprofile reiserfsprogs squashfs-tools xfsprogs
  quota libqt3-dev
The following NEW packages will be installed:
  kernel-package linux-source linux-source-3.13.0
0 upgraded, 3 newly installed, 0 to remove and 193 not upgraded.
Need to get 98.5 MB of archives.

And specify the KernelDIR path which is 3.13.0-45-generic

ubuntu@tegra-ubuntu:~/r8168-8.039.00$ sudo ./autorun.sh 
Check old driver and unload it.
Build the module and install
Can't read private key
DEPMOD 3.10.40-ged4f697
load module r8168
modprobe: ERROR: could not insert 'r8168': Exec format error
Updating initramfs. Please wait.
update-initramfs: Generating /boot/initrd.img-3.10.40-ged4f697
grep: /boot/config-3.10.40-ged4f697: No such file or directory
cryptsetup: WARNING: could not determine root device from /etc/fstab

[Check the file format]

ubuntu@tegra-ubuntu:~/r8168-8.039.00/src$ file r8168.ko 
r8168.ko: ELF 32-bit LSB  relocatable, ARM, EABI5 version 1 (SYSV), BuildID[sha1]=320986579cfa2383daa463a740ff70d287cc0e5c, not stripped

Here, I’m wondering if there is anyone encounterred the same problem.

First try compiling it directly on a Jetson…make sure you have the kernel source installed and configured on Jetson first, including CONFIG_LOCALVERSION. Cross-compiling kernels isn’t usually too painful, but it can add a lot of complications. From there copy the module over to your custom board…this should eliminate any cross-compile issues (or at least give information about what’s going on).

I doesn’t make much sense to install linux-source or kernel-package to Jetson as they are not the same kernel as the one that you are using.

The cross-compiled one should work though.

What does “dmesg” say after you tried to modprobe the cross compiled kernel? It may say e.g. that the magics (version numbers basically) don’t match. If that’s the case, you can try --force with the modprobe or modify the kernel version to match exactly the one you are running on Jetson and recompile.

I’m just saying to simplify things first. The kernel source can be set to his custom board’s config using its kernel source on Jetson and there’ll be no chance of cross compiling complicating it. It certainly won’t hurt anything and will provide more information.


do you have an advice to program efuse mac address for rtl8111g under linux?

Best Regards