cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
357 Views
Registered: ‎06-26-2020

libiio in petalinux 2019.2 - can create .so, but not service or tests

Hello community,

I need your help to get libiio working on petalinux. After a few days of research and learning, I have gotten a little forward, but I am very stuck right now. What I have been able to do:

- Using the bb file at https://layers.openembedded.org/layerindex/recipe/57509/ and following the UG1144 (Xilinx Reference Guide) direction to add a library, I successfully added the 'app' library and actually got to create the full package.

petalinux-create -t apps --template c -n libiio --enable

then replace the default libiio.bb with the one in the OE.

However, when I boot to the pentalinux, I only see a partial result of libiio:

/usr/lib/
lrwxrwxrwx    1 root     root            14 Jun 26 20:36 libiio.so.0 -> libiio.so.0.20
-rwxr-xr-x    1 root     root         75040 Jun 26 20:36 libiio.so.0.20

BUT iiod is nowhere to be found (on /sbin or as a service). In addition, the libiio/tests are not created and copied to /usr/bin. The tests are created by default, and the bb does not send any options to stop that, from what I can tell.

It seems to me, as a first guess, that the 'make install' portion of the process is not happening. According to https://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#new-recipe-installing because libiio uses a CMakeLists.txt file, it should be completing everything. Plus the addition of the FILES_${PN}- at the end of the bb should be taking care of copying things, I thought. And I have no idea of why its doing this, unless the Xilinx Petalinux tools do not actually support those parts of the bb file, and I need to manually code them differently?

So at this point I have a .so, but its not very useful yet.

Your help is greatly appreciated!

Alvar

PS, I have already tried as much as I could, including following other links and going about 4 levels into these:

https://forums.xilinx.com/t5/Embedded-Linux/Install-libiio-to-petalinux/m-p/706907

https://forums.xilinx.com/t5/Embedded-Linux/Petalinux-2018-1-IIO-Library-Integration/m-p/871482

 

3 Replies
Highlighted
Participant
Participant
212 Views
Registered: ‎03-10-2015

I got a tip from the ADI Engineer Zone about how to get libiio into PetaLinux.  I had also followed the UG1144 guide, specifically the section on "Adding an Existing Recipe into Rootfs", but was observing exactly what you described.  Turns out, the solution was to not only include "libiio" in the petalinux-image.bbappend file but also "libiio-tests" and "libiio-iiod".  

#Note: Mention Each package in individual line
# cascaded representation with line breaks are not valid in this file.

IMAGE_INSTALL_append = " libiio"
IMAGE_INSTALL_append = " libiio-tests"
IMAGE_INSTALL_append = " libiio-iiod"

 After doing that an rebuilding the image I can see these libiio programs in /usr/bin:

-rwxr-xr-x    1 root     root          9760 Aug 31 15:29 iio_adi_xflow_check
-rwxr-xr-x    1 root     root          9696 Aug 31 15:29 iio_genxml
-rwxr-xr-x    1 root     root         13916 Aug 31 15:29 iio_info
-rwxr-xr-x    1 root     root         13904 Aug 31 15:29 iio_readdev
-rwxr-xr-x    1 root     root          5580 Aug 31 15:29 iio_reg

...and iiod in /usr/sbin:

-rwxr-xr-x    1 root     root         46916 Aug 31 15:29 iiod

 

Highlighted
Visitor
Visitor
185 Views
Registered: ‎06-26-2020

Thank you for putting that info here from the ADI site!

I'm going to do the same and post my full reply there, to hopefully help people here too.

Cheers,

Alvar

0 Kudos
Highlighted
Visitor
Visitor
184 Views
Registered: ‎06-26-2020

After a lot of work and combining many things, I have libiio working reasonably well in my build.

This is all for Petalinux 2019.2, which is important to say, because a lot of people forget to mention BIG changes between versions. In this case, for example, petalinux-image.bbappend is no longer used. It is now a differently named file in a differently named location. So I apologize to anyone who will need to learn about different file locations if you are not using 2019.2. But I will try to provide a complete process to get libiio working, hopefully good enough for any new person (as I was a month ago).

1) While in your project's home directory which I will refer to <project> from now on (I know this is 'basic', but its very terribly documented, so I like to point it out):

 

petalinux-create -t apps --template c --name libiio --enable

 

2) The newly created <project>/project-spec/meta-user/recipes-apps/libiio/libiio.bb

should have basically the following (you might need to customize a little, see long note below):

 

SUMMARY = "Library for interfacing with IIO devices"
HOMEPAGE = "https://wiki.analog.com/resources/tools-software/linux-software/libiio"
SECTION = "libs"
LICENSE = "LGPLv2.1+"
LIC_FILES_CHKSUM = "file://COPYING.txt;md5=7c13b3376cea0ce68d2d2da0a1b3a72c"

SRCREV = "565bf68eccfdbbf22cf5cb6d792e23de564665c7"
PV = "0.21+git${SRCPV}"

SRC_URI = "git://github.com/analogdevicesinc/libiio.git;protocol=https"
UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"

S = "${WORKDIR}/git"

inherit cmake python3native systemd

DEPENDS = " \
    flex-native bison-native libaio libxml2\
    ${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
"

EXTRA_OECMAKE = " \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DUDEV_RULES_INSTALL_DIR=${nonarch_base_libdir}/udev/rules.d \
    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '-DWITH_SYSTEMD=ON -DSYSTEMD_UNIT_INSTALL_DIR=${systemd_system_unitdir}', '', d)} \
"

PACKAGECONFIG ??= "examples"

PACKAGECONFIG[usb_backend]     = "-DWITH_USB_BACKEND=ON,-DWITH_USB_BACKEND=OFF,libusb1,libxml2"
PACKAGECONFIG[network_backend] = "-DWITH_NETWORK_BACKEND=ON,-DWITH_NETWORK_BACKEND=OFF,libxml2"
PACKAGECONFIG[libiio-python3]  = "-DPYTHON_BINDINGS=ON,-DPYTHON_BINDINGS=OFF"
PACKAGECONFIG[examples]        = "-DWITH_EXAMPLES=ON,-DWITH_EXAMPLES=OFF"

inherit ${@bb.utils.contains('PACKAGECONFIG', 'libiio-python3', 'distutils3-base', '', d)}

PACKAGES =+ "${PN}-iiod ${PN}-tests ${PN}-${PYTHON_PN}"

RDEPENDS_${PN}-${PYTHON_PN} = "${PN} ${PYTHON_PN}-ctypes ${PYTHON_PN}-stringold"

FILES_${PN}-iiod = " \
    ${sbindir}/iiod \
    ${systemd_system_unitdir}/iiod.service \
"
FILES_${PN}-tests = "${bindir}"
FILES_${PN}-${PYTHON_PN} = "${PYTHON_SITEPACKAGES_DIR}"

SYSTEMD_PACKAGES = "${PN}-iiod"
SYSTEMD_SERVICE_${PN}-iiod = "iiod.service"


do_install_append() {
	     install ${B}/examples/dummy-iiostream ${D}${bindir}
	     install -m 0755 ${B}/examples/dummy-iiostream ${D}${bindir}
	     chrpath -d ${D}${bindir}/dummy-iiostream
}
FILES_${PN} += "${bindir}/iiostream-dummy"

 

NOTE: you do NOT need to download any files. This bb uses the GIT of the official libiio to get all the files from there. You can actually empty out the 'files' directory <project>/meta-user/recipes-apps/libiio/files if you want.

NOTE: this is my latest version for testing, where I manually added "examples" as a PACKAGECONFIG option, where I do NOT use USB or Network (I only use the local backend), and where I copy the "examples/dummy-iiostream" to /usr/bin/ manually at the end, because the libiio CMakeFile does NOT make have an 'install' for examples, so I had to copy the file 'manually' using a do_install_append ... I know this is very quick info, it took me hours to collect all the pieces from a dozen websites, but hopefully its a tiny guide for others to get started).

3) add to <project>/project-spec/meta-user/conf/user-rootfsconfig (note: this is where it is for 2019.2 at least, check others, I'd say sorry, but Xilinx should be the one to be sorry for not documenting it clearly)

 

CONFIG_libiio
CONFIG_libiio-iiod
CONFIG_libiio-tests

 

the CONFIG_libiio is likely already there.

But you MUST have CONFIG_libiio-tests in order to get the tests executables in your rootfs. If you don't have those, while they will get compiled in your host system, they will not end up in the embedded system.

4) run

petalinux-config -c rootfs

then choose

 

user packages --->
  [*] libiio
  [*] libiio-iiod
  [*] libiio-tests

 

5) in theory the next step should be that you can simply run

 

petalinux-build

 

however, I found that petalinux does whatever it wants some times, so you might need to do petalinux-build -c libiio first, followed by petalinux-build -c rootfs and petalinux-build -x package

and then do your steps depending on how you are booting. In my case:

petalinux-package --boot $fsbl_option --fpga $bit --u-boot --force

Hopefully others find these full instructions helpful, maybe someday the libiio team can put them fully in their documentation, without the million assumptions that are needed right now... once I put it all together, it can be done in one day (some of you, I know, likely in a couple hours).

 

Good luck!