UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
9,976 Views
Registered: ‎11-17-2014

How do I build a kernel module seperately?

Jump to solution

Hi, 

 

I just installed petalinux 2015.2 and I was able to build a test kernel and rootfs and a module for practice.

 

Now I want to take a third party USB driver/module and cross-compile it for the Zynq platform. How would I go about building the module if I didn't want to build an entire OS/Rootfs? All I want to build is the .ko file right now and try using insmod with it on a the demo OS that came with my zedboard.

 

Thanks.

0 Kudos
1 Solution

Accepted Solutions
Scholar sampatd
Scholar
18,676 Views
Registered: ‎09-05-2011

Re: How do I build a kernel module seperately?

Jump to solution

With 2015.2 PetaLinux, you do not need SDK to make a PetaLinux image. Once you have compiled the kernel, you can use the
'petalinux-package' command to build a bootable image. For more information, check page 24 of the following guide:
http://www.xilinx.com/support/documentation/sw_manuals/petalinux2015_2/ug1156-petalinux-tools-workflow-tutorial.pdf

If you have pre-compiled kernel modules that you want to add to PetaLinux rootfs, you can follow the instructions on page 64 of UG1144. You may then use 'modprobe' or 'insmod' to insert the module.
http://www.xilinx.com/support/documentation/sw_manuals/petalinux2015_2/ug1144-petalinux-tools-reference-guide.pdf


If you want to automatically call your module after boot, check the discussion below:
http://forums.xilinx.com/t5/Embedded-Linux/petalinux-How-to-load-module-automatically-at-boot-time/td-p/411823

0 Kudos
3 Replies
Scholar sampatd
Scholar
9,952 Views
Registered: ‎09-05-2011

Re: How do I build a kernel module seperately?

Jump to solution

Generally, one would edit the makefile and issue a make command to compile an LKM. Check the link below:

http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html

If you want to use PetaLinux commands, you may want to check page 69 of the following guide.
http://www.xilinx.com/support/documentation/sw_manuals/petalinux2015_2/ug1144-petalinux-tools-reference-guide.pdf

0 Kudos
Contributor
Contributor
9,947 Views
Registered: ‎11-17-2014

Re: How do I build a kernel module seperately?

Jump to solution

Thanks for the reply and the references.

 

On my own, I was able to edit the original makefile for the driver to use the kernel sources from petalinux and use the arm-xilinx-linux-gnueabi-gcc compiler petalinux provides. I still need to test it on my zedboard and I'm kinda weary since the built module is only 170KB but when compiled for a normal pc the module is 4.7MB but it might be due using different arguments when I compiled for a PC.

 

When I go to build the petalinux image that will get added in Xilinx SDK, how do I add the module file that I made outside of a petalinux project? If I made a library or API would I follow the same steps in compiling externally and adding to the project somehow?

 

Thanks again.

0 Kudos
Scholar sampatd
Scholar
18,677 Views
Registered: ‎09-05-2011

Re: How do I build a kernel module seperately?

Jump to solution

With 2015.2 PetaLinux, you do not need SDK to make a PetaLinux image. Once you have compiled the kernel, you can use the
'petalinux-package' command to build a bootable image. For more information, check page 24 of the following guide:
http://www.xilinx.com/support/documentation/sw_manuals/petalinux2015_2/ug1156-petalinux-tools-workflow-tutorial.pdf

If you have pre-compiled kernel modules that you want to add to PetaLinux rootfs, you can follow the instructions on page 64 of UG1144. You may then use 'modprobe' or 'insmod' to insert the module.
http://www.xilinx.com/support/documentation/sw_manuals/petalinux2015_2/ug1144-petalinux-tools-reference-guide.pdf


If you want to automatically call your module after boot, check the discussion below:
http://forums.xilinx.com/t5/Embedded-Linux/petalinux-How-to-load-module-automatically-at-boot-time/td-p/411823

0 Kudos