cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
2,430 Views
Registered: ‎12-20-2017

Toolchain file for cmake cross-compiling?

I'm working with petalinux on a zcu102 ultrascale, and I'd like some workflow advice.

I've been building my cmake-based application on petalinux for quite some time now, using a linux build host and the command line.  It takes forever for the bitbake recipes to process, and then it's a pain in the butt to try to find the application executables in the build/tmp/whereever path, so usually I just build a new image and throw it on the sd card.  However, it gets painful when I have many small code changes to make, and I'm thinking there's got to be a better way.

I'd like to be able to use the SDK to build my cmake application.  However, the setup for cmake cross-compiling toolchains is not simple, and I'm wondering if this has been done already.  I would think that this is a pretty common thing to do.  Can anyone advise?

0 Kudos
1 Reply
Highlighted
Voyager
Voyager
2,385 Views
Registered: ‎10-21-2015

Hi

You can make sdk for your image.

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug1144-petalinux-tools-reference-guide.pdf p99

Then use cmake toolchain file like this

set(CMAKE_SYSTEM_NAME Linux)
#this one not so much
set(CMAKE_SYSTEM_VERSION 1)

set(MYROOT /home/hokim/work/_root)
# specify the cross compiler
set(CMAKE_C_COMPILER  aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_SYSROOT ${MYROOT})
# where is the target environment 
set(CMAKE_FIND_ROOT_PATH  ${MYROOT})
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NAVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

 

But I recommend you use package management

At first you make image with package management like this

$ vi project-spec/meta-user/conf/petalinuxbsp.conf
EXTRA_IMAGE_FEATURES += " package-management"
PACKAGE_FEED_URIS = "http://192.168.7.1:5678"
$ petalinux-build 

Afterward, you can add packages you want and service repository for packages like this

$ petalinux-build -c hello-world
$ petalinux-build -c package-index

$ cd build/tmp/deploy/rpm
$ python3 -m http.server 5678

Then you can install the packages on your target board

# dnf --refresh install hello-world

Here, I assume you use petalinux 2018.2

Use smart in the previous versions