Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Rockpi4/dev/compile-a-kernel-module-on-rockpi4

< Rockpi4‎ | dev
       ROCK Pi 4 >  Development >  Compile a kernel module on ROCK Pi 4

Description

This guide is for compiling a kernel module for ROCK Pi 4 on ROCK Pi 4 board. You can use system images Debian and Ubuntu.

Software Support

For kernel, you need to upgrade to at least 4.4.154-98-rockchip version.

Note that the latest U-boot and Kernel packages are in Radxa APT stretch-testing ans bionic-testing repositories.

Also, you need to update rockchip-fstab, rockchip-overlay, u-boot packages. And Radxa APT helps.

Example: r8152 device driver

Here take r8152 device driver as an example.

Install necessary packages.

 $ sudo apt-get install -y libssl-dev build-essential

Recompile dependent libraries.

 $ cd /usr/src/linux-headers-$(uname -r)
 $ make scripts

Download r8152 driver source code to ROCK Pi 4 and extract it to home directory.

Go to the top-level directory of the source code

 $ cd realtek-r8152-linux-master
 $ ls
 50-usb-realtek-net.rules  compatibility.h  Makefile  r8152.c  ReadMe.txt

Generate r8152.ko file.

 $ make

Check kernel release and processor

 $ uname -rp
 4.4.154-98-rockchip-gcbc3da2ca32c aarch64

Check r8152 ko information

 $ modinfo r8152.ko 
 filename:       /home/rock/r8152_2.12.0/r8152.ko
 version:        v2.12.0 (2019/04/29)
 license:        GPL
 description:    Realtek RTL8152/RTL8153 Based USB Ethernet Adapters
 author:         Realtek nic sw <nic_swsd@realtek.com>
 srcversion:     576F778ECF92A5E23120A75
 ...
 depends:        
 vermagic:       4.4.154-98-rockchip-gcbc3da2ca32c SMP mod_unload aarch64

The vermagic of module should be the same as current kernel release version like 4.4.154-98-rockchip-gcbc3da2ca32c.

Install driver module to kernel.

 $ sudo make install

Remove driver module.

 $ sudo rmmod r8152

FAQs

Troubleshooting

If you have issue with compiling a kernel module on ROCK Pi 4, start a new post on the forum. https://forum.radxa.com/c/dev