Tuesday, January 4, 2022

[SOLVED] Could I Build a kernel driver for Ubuntu without building Ubunto kernel?

Issue

I have a Zynq Ultrascale board and I want to use its DMA interface from Aarch64 processor which is running Linux as OS. for this purpose I should place .ko driver file in kernel and load it into Linux kernel.

currently, I use Petalinux and build driver .ko file by it, and Petalinux place this .ko file in rootfs and Petalinux kernel.

now, I want to move from Petalinux to Ubuntu and use Ubuntu on Zynq board, so I want to know could I build a DMA driver separately from the ubuntu kernel and add it to its kernel afterward?

formerly, Petalinux built my driver while it built whole linux kernel. but I want to build only driver and use existing kernel(without building ubuntu kernel)

if yes and I could build the driver separately, how could I build a driver for Ubunto?


Solution

fortunately, I copied the driver built by Petalinux to Ubuntu and it works properly.

It means I could use Petalinux for building drivers without compiling Ubuntu's kernel, I added driver's .c file to Petalinux as a module then build Petalinux entirely, then pick the driver's .ko file from /lib/modules/5.10.0-xilinx-v2021.2/extra/ path in Petalinux and copied it to somewhere in Ubuntu and call insmod command.

I know this solution isn't respectful but it works for me and pulled me out of the swamp.



Answered By - hamed