Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Howto make PetaLinux module header available to an app?

Started by bigguiness, February 14, 2023, 09:06:16 PM

Previous topic - Next topic


I have created a custom Linux driver (basically a miscdevice) for my hardware using:

$ petalinux-create -t modules--name myip --enable

The driver consists of a myip.c file and a myip.h header with the IOCTL definitions and other uapi stuff.

The driver compiles fine and is getting loaded with no issues during the kernel boot.

I'm now trying to write a test app for the driver. I created the app with:

$ petalinux-create -t apps -n test_myip --template install --enable

This app just has a test_myip.c file but it needs the myip.h header.

If I #ifdef out all the stuff provided by myip.h the test app compiles and is installed to the rootfs. And it runs fine when the system is booted.

But if I try to include the myip.h I get a compile error. I have tried a number of paths ("myip.h", <myip.h>, <linux/myip.h>, etc.) but no luck.

I tried searching the <plnx-proj-root> for the myip.h file and it is only found at project-spec/meta-user/recipes-modules/myip/files/myip.h.

What do I need to do to get the myip.h header installed in the build tree so that the test_myip.c file can include it?



you can ask this question here, but this is completely independent from our modules.

It's better to ask here:
AMD/Xilinx community is much bigger. So you will get faster an answer there.



I have looked in the AMD/Xilinx forums already.

The only answer I found there was to create a symbolic link in the apps files directory to the header in the modules files directory.

That would probably work but doesn't seem like the proper way to do this.

I was hoping someone in this forum has had to do this and knows the "right" way.

It seems many of the AMD/Xilinx answers just say "read this doc"...


Answering this myself in case anyone else has the same issue...

I finally found an old yoctoproject message about this and figured it out.

In the recipe for the "app" you need to add something like this:

DEPENDS = "myip"

Then in the recipe for the "module" add something like this:

do_install_append() {
    install -d ${D}/usr/include/myip
    install -m 0755 ${S}/myip.h ${D}/usr/include/myip/

This makes the "app" depend on the "module" and the "module" install the header to /usr/include/myip/.

Then in the "app" the header can be simply included with:

#include <myip/myip.h>



thanks for sharing this information here.
Have a nice weekend!