Petalinux Modifications

Issue #228 new
Bryerton Shaw created an issue

I recently modified MIDAS to build the libraries only for a Petalinux image (Petalinux 2018.3), and I wanted to share my experience and get some feedback.

Backstory: The Darkside experiment requested a MIDAS Frontend (FE) be installed on the Petalinux they are running on top of a Xilinx Ultrascale+ FPGA. PAA asked if I could assist with the task.

I decided to split this task into two parts:

  1. Build+Install the MIDAS libraries into Petalinux
  2. Build+Install a custom MIDAS FE into Petalinux using the MIDAS libraries

Part 1) Build+Install the MIDAS libraries into Petalinux

After looking over the MIDAS source, I chose to use the CMake build, as it was very easy to strip away the example and programs by commenting out the final two lines like so:

# add_subdirectory(progs)
# add_subdirectory(examples)

This gets you a MIDAS compile with only the libraries. But there is more to be done. I quickly discovered installing those libraries into petalinux easily required the use of PUBLIC_HEADER` as well when installing the lib target.
The next issue is a bit strange, during the Petalinux staging cmake can’t seem to find git to make git_revision.h , I ended up adding:

if (NOT GIT_FOUND)
    set(GIT_EXECUTABLE "/usr/bin/git")
    set(GIT_FOUND true)
endif()

To correct for it, I tried adding git to my DEPENDS in the midas.bb like soDEPENDS = “git curl zlib” but while it did install git during the Petalinux staging, it did not fix the issue. Some googling indicated I wasn’t the only one who has encountered this issue, so I stuck with this work-around, but there is likely a more elegant solution to be found.

As I did not want to keep a local copy of MIDAS in the DS repo, i chose to use the SRC_URI + Patch method to pull the MIDAS code and then patch it. I used the commit for the tag midas-2020-03-a, I tried the tag=… feature but it caused a Petalinux error.

SRC_URI = "gitsm://bitbucket.org/tmidas/midas.git;protocol=https;branch=develop;rev=4054e07d5a986216189df6364a3fcec35724618c \ file://cmake.patch"

Once Petalinux could build the MIDAS libraries, it complained about ‘unversioned’ shared library files, so I used the given work-around in the midas.bb

SOLIBS = ".so"
FILES_SOLIBSDEV = ""

And this resolved the issue.

Finally, after several minutes hours of dealing with various other oddities of Petalinux and Yocto MIDAS was building the libraries, then installing the libraries and headers into /usr/lib and /usr/include/midas respectively.

Part 2) Build+Install a custom MIDAS FE into Petalinux using the MIDAS libraries

In comparison this is very straight forward, and no real issue came up. Just ran through the steps, linked the missing libraries in, and it worked 🙂

Thoughts

  1. Adding a library only build option to MIDAS, maybe:

    if (NOT LIBS_ONLY) add_subdirectory(progs) add_subdirectory(examples) endif

  2. Make building shared libraries optional? I’ve been told most users of MIDAS build statically, and their inclusion causes fits for Petalinux’s QA check.

  3. Installation of header files via PUBLIC_HEADER method(s). These eases the challenge of installing under Petalinux, and might make it a bit easier for others trying to link to the MIDAS libraries. (And clearer which headers are to be used against those libraries?)
  4. The host building MIDAS for the Petalinux target saves a lot of image space compared to requiring self-hosted compilation of MIDAS on the FPGA. No gcc, cmake, etc are required to be added to the petalinux image itself. And the MIDAS static libraries do not need to be installed as they are used only during compilation.
  5. By not using pre-built libraries, we guarantee the MIDAS libraries are built in the same environment as the FE and Petalinux and are compatible.

I’ve attached the two ‘recipes’ used, including the patch file necessary to make MIDAS compile for Petalinux

Comments (2)

  1. Stefan Ritt
    1. No problem, I would agree to that.
    2. Fine with me. Actually I’m not using shared libraries, it was invented by KO, so he should comment
    3. We are discussing now how to get all header files together. This becomes more problematic with having more and more sub-modules. If I understand correctly, PUBLIC_HEADERS is something for OSX, normally a simple file copy should be enough: https://stackoverflow.com/questions/46713143/cmake-install-library-and-development-files-as-separate-components-using-public

  2. Log in to comment