Trenz Electronic GmbH Support Forum

Trenz Electronic Products => Trenz Electronic FPGA Modules => Topic started by: bigguiness on February 14, 2023, 09:06:16 PM

Title: Howto make PetaLinux module header available to an app?
Post by: bigguiness on February 14, 2023, 09:06:16 PM
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?

Thanks
Title: Re: Howto make PetaLinux module header available to an app?
Post by: JH on February 15, 2023, 02:25:50 PM
Hi,
you can ask this question here, but this is completely independent from our modules.

It's better to ask here: https://support.xilinx.com/s/topic/0TO2E000000YKXXWA4/embedded-linux?language=en_US
AMD/Xilinx community is much bigger. So you will get faster an answer there.
br
John
Title: Re: Howto make PetaLinux module header available to an app?
Post by: bigguiness on February 15, 2023, 04:17:43 PM
John,

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"...
Title: Re: Howto make PetaLinux module header available to an app?
Post by: bigguiness on February 16, 2023, 04:40:59 PM
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>


Hartley
Title: Re: Howto make PetaLinux module header available to an app?
Post by: JH on February 17, 2023, 11:22:29 AM
Hi,
thanks for sharing this information here.
Have a nice weekend!

br
John