cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
eyalniv4
Observer
Observer
4,084 Views
Registered: ‎12-03-2019

Running vitis from windows using sysroot exported from petalinux

Hi,
vitis (or xsdk) integration with petalinux is all over the place.
A couple of questions:

  1. What is the recommended way to setup a linux domain and app project in Vitis (running on Windows) using sysroot exported from petalinux (running on VM)?
    Yes, I can copy the sysroot folder to Windows, but do I have to manually setup the configuration in vitis eclipse to be like the generated environment-setup-cortexa9t2hf-neon-xilinx-linux-gnueabi shell script?
  2. If there is no recommended way, does that mean that windows users need another copy of vitis in their linux VM (this is over 50GB) if they want to use the IDE?
    Does xilinx forces windows users to have another copy of vitis on a linux machine for doing linux development?
Tags (2)
0 Kudos
13 Replies
stephenm
Xilinx Employee
Xilinx Employee
4,002 Views
Registered: ‎09-12-2007

You need the set th XILINX_XRT param. This can be done in the setup.sh/csh script manually

https://github.com/Xilinx/XRT/blob/master/src/runtime_src/tools/scripts/setup.sh

0 Kudos
eyalniv4
Observer
Observer
3,980 Views
Registered: ‎12-03-2019

I believe you are referring to accelerated applications development.

I'm asking about cross-compiling applications from a windows machine to the cortex-a9 running linux.

Mostly, I want to know if there is a convenient way to setup a vitis linux application project with all the gcc/g++ flags on a windows machine?

0 Kudos
gilles007
Visitor
Visitor
3,734 Views
Registered: ‎12-11-2018

Hello

I am trying to do the same thing. Did you manage to find a solution ?

I tried doing it with Ext1-2-3-4 reader programs, but they don't really make it possible to mount/use the sysroot of an usb.

0 Kudos
eyalniv4
Observer
Observer
3,727 Views
Registered: ‎12-03-2019

Yes, but not in the most elegant way.
My VM was in Virtualbox. I created a shared folder between the host and the VM and copied the entire sysroot/cortexa9t2hf-neon-xilinx-linux-gnueabi folder to it (making sure to de-reference symbolic links -L). It is then available for you in Windows. In theory, you don't need the entire thing, just the include and bin folders. A small number of files failed to copy (I forget how many) which probably happened since there was a different file in the directory with the same name but different casing (allowed in Linux, but not in Windows). If you happen to require to include any of these files in your application, you can probably rename them (making sure that any other headers using them take that into account).

0 Kudos
beni.falk
Participant
Participant
3,663 Views
Registered: ‎01-05-2020

The following summary describes the tool setup and use process (based on my experience). It applies to MPSOC/RFSOC and the ZCU111 target, however I believe that it may be useful with other targets as well.

**************************************************************************************************************************

I) General
==========
Xilinx supports several software development flows for the MPSOC/RFSOC, as follows:
- Linux running on the A53 cores (in SMP mode)
- Free RTOS or "bare metal" software running on the A53 and/or R5 cores (it is
possible that different cores run different types of software).

In addition to Linux kernel and application software also need several software
packages for the system to start, as follows:
- PMU firmware
- ATF (ARM trusted firmware)
- FSBL (first-stage boot loader)
- SSBL (second-stage boot loader) - usually U-Boot

Xilinx provides two software development environments, as follows:
a) PetaLinux tools - this environment is necessary for preparing a bootable Linux
image. Specifically, it allows preparing an image containing the various
bootloaders, the Linux image and (optionally) application code.

It follows that any custom drivers that are linked to the kernel must be added to
the system using this flow.

PetaLinux tools are only supported on Linux.

b) Vitis development environment - this environment supports development of all
design flows mentioned above except for bootable Linux kernel preparation (which
necessitates PetaLinux tools).

Vitis can run on Windows or on Linux.

Application software running under Linux (on the A53 cores in SMP mode) can be
developed in two ways:
a) Using PetaLinux tools - the application is added to the bootable image.
b) Using Vitis - creating a separate executable (ELF) which can be downloaded to the
target and run separately (once Linux is up).

In the latter case, need to export target libraries, BSP data, device tree, etc.
from the PetaLinux environment to the Vitis environment. This data is known as the
"sysroot".

In general, software development under PetaLinux is quite user-unfriendly. In
particular, there is no GUI-based IDE for building and debugging. Vitis does provide
a graphical IDE (based on Eclipse) which facilitates a reasonably convenient build
and debug flow.

Both the PetaLinux environment and the Vitis environment use custom design
details exported from Vivado (these are files with .xsa extension).


II) PetaLinux environment setup (for PetaLinux 2019.2)
======================================================
1. Setting up the Linux virtual machine
---------------------------------------
a) PetaLinux development tools need to run under Linux. Per UG1144 I installed
Ubuntu 18.04.02 (64-bit). It subsequently updated itself to 18.04.4.

b) I am running Ubuntu in a VirtualBox VM. Specifically, I am using VirtualBox 6.1
(had some problems with 6.1.2).

c) Specified 200 GB disk size for the VM (the PetaLinux tools are extremely disk-
hungry).

d) Needed to enable 3D acceleration, or else the display did not function very well.
Note: even now occasionally there are transient problems with rendering which are
worked around by minimizing and maximizing the VM.

e) Specified a shared folder with all permissions. Also enabled clipboard sharing.

2, Changes in Linux setup after installation
--------------------------------------------
a) Changed the shell from dash to bash (sudo dpkg-reconfigure dash and select the
option not to use /bin/dash as the default shell).

b) sudo apt-get update

c) Per UG1144 installed various packages:
- Used the list provided in 2019.2_PetaLinux_Package_List.xlsx (found at
https://www.xilinx.com/support/answers/72950.html)
- Afterwards went over the list using sudo apt-get install commands and almost
everything was installed correctly except for pyhton-pip.
- Used the sudo apt-get install sequence from here:
https://wiki.trenz-electronic.de/display/PD/PetaLinux+KICKstart
- sudo apt-get install tftpd-hpa and configured it to allow client uploads as
well (this is all probably unnecessary).

d) Installed PetaLinux 2019.2 per UG1144.
Note: before doing that, issued the following command:
sudo chown beni-falk:beni-falk /opt/
Note: had to chmod the installer (.run file) to 755, or else it would not run
(UG1144 specifically says not to do that, but I had no choice).

e) After installing PetaLinux:
- Added the following to ~/.bashrc:
source /opt/pkg/petalinux/2019.2/settings.sh > /dev/null
PATH=$PATH:/opt/pkg/petalinux/2019.2/tools/xsct/bin
(this last one was necessary since otherwise it wouldn't find bootgen)

- petalinux-util --webtalk off
(following https://wiki.trenz-electronic.de/display/PD/PetaLinux+KICKstart)

3. Additional changes to Linux setup for the sake of compatibility, convenience, etc.
-------------------------------------------------------------------------------------
a) Using the Tweaks application (from the dock):
a1) Enabled Ubuntu app indicators.
a2) Enabled Windows-like behavior for numeric keypad keys:
Keyboard and Mouse->Additional Layout Options->
Miscellaneous compatibility options->Num Lock on: digits; Shift for arrow
keys. NumLock off: arrow keys (as in Windows)

b) Disabled screen saver (Settings->Power) since it caused the VM to misbehave.


III) Using the PetaLinux development environment (in conjunction with ZCU111 EVB)
=================================================================================

1. ZCU111 BSP can be downloaded from here:
https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html).

Another option which also comprises rftool source code is here: 
https://www.xilinx.com/member/forms/download/design-license-xef.html?filename=rdf0476-zcu111-rf-dc-eval-tool-2019-2.zip

2. Following the tutorial provided here:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/130973731/PetaLinux+Build+Tutorial+for+2019.1

a) petalinux-create -t project -s rfsoc_petalinux_bsp.bsp
cd rfsoc_petalinux_bsp

b) Applying the modifications as provided on that page (some of them were
unnecessary - they were already there in the 2019.2 BSP; I wasn't able to
perform the step calling for adding an entry to
project-spec/meta-user/recipes-bsp/rfdc/rfdc_%.bbappend)

c) For each of nonmts, mts, ssr:
petalinux-config --get-hw-description=$DCET_HOME/pl/<design_path>/pre-built/rfsoc_trd/
petalinux-build
cd pre-built/linux/images
./dtc -O dtb -o pl.dtbo -b 0 -@ pl_<design type>.dtsi
bootgen -image bitstream.bif -arch zynqmp -o zcu111_rfsoc_trd_wrapper.bit.bin -w
<copy pl.dtbo and zcu111_rfsoc_trd_wrapper.bit.bin to appropriate esdcard directory>
cd $DCET_HOME/apu/rfsoc_petalinux_bsp/images/linux
petalinux-package --force --boot --fsbl zynqmp_fsbl.elf --pmufw pmufw.elf --u-boot u-boot.elf
<copy BOOT.BIN and image.ub to sdcard directory>

3. Prepare a FAT-formatted SD card containing BOOT.bin and image.ub in the root
directory (along with optional autostart.sh). It should also contain three
subdirectories containing nonmts, mts and ssr data, respectively. This SD card
should be able to boot the ZCU111. If autostart.sh is provided - it can be used
to automatically set IP address (ifconfig) and start the rftool application.
Note: autostart.sh should be placed at the root of the SD card.

Example autostart.sh:

#!/bin/sh
ifconfig -a | grep eth0
RESULT=$?
if [ $RESULT -eq 0 ]; then
ifconfig eth0 192.168.1.3
rftool
fi

4. Exporting sysroot data in order to allow building and debugging the rftool
application as a standalone application (under Linux) using Vitis is done per the
following:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/70254659/Creating+Linux+application+targeting+the+RFDC+driver+in+SDK+2018.3
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841623/How+to+debug+Linux+Application+in+SDK+2019.1

petalinux-build --sdk
petalinux-package --sysroot

The above build takes a very long time (~45 minutes).

The outputs from this process that need to be conveyed to Vitis reside in the
following folder: <plnx-project>/images/linux/sdk/sysroots/aarch64-xilinx-linux


IV) (Optional) project tweaks in the PetaLinux environment
==========================================================
1, Addition of Midnight Commander to target image -
https://forums.xilinx.com/t5/Embedded-Linux/Midnight-Commander-for-Petalinux/td-p/1058820

2. Adding auto-login (user root, password root) - this is taken from UG1144:
a) Change to the root directory of your PetaLinux project -
cd <plnx-proj-root>
b) Run petalinux-config
c) Select Yocto-settings and enable debug-tweaks
d) Save the configuration and exit
e) Run petalinux-build


V) Vitis environment setup and use (for Vitis 2019.2.1)
=======================================================
The following assumes that Vitis (installed on Windows) is used for developing
applications that will run on the target under Linux on the A53 cores (in SMP mode).

1. Copy sysroot data from the Linux VM - it turns out that many of the files
comprised by the sysroot are actually links to other files. When copying this
file structure to Windows need to convert each such link to the actual file.
This is done as follows (on the Linux machine):
cp -R -L <plnx-project>images/linux/sdk/sysroots/aarch64-xilinx-linux <shared_folder>
The contents of <shared_folder> can now be used under Windows.

2. Copy the images directory from the Linux machine
(<plnx-project>/images/linux - not including the sdk subdirectory).

3. Define a platform project in Vitis:
a) File->New->Platform Project->Create from hardware specification (XSA)
Browse to the appropriate .xsa file (it needs to be copied from the Linux
machine - these files are located under the pl directory, e.g.
pl/NON-MTSDesign_8x8/pre-built/rfsoc_trd).
Set Operating system to linux and Processor to psu_cortexa53

b) In the platform editor view left-click the top-most item. On the right uncheck
'Generate boot components'.

c) In the platform editor view left-click 'linux on psu_cortexa53'. Specify
additional details as follows:
- Bif File: path to BIF file (see below)
- Boot Components Directory: path to where have copied the images directory
- Linux Image Directory: ditto
- Sysroot Directory: path to where have copied sysroot data
QEMU-related fields can be left blank

d) Create a BIF (boot image format) file similar to the following:

/* linux */
the_ROM_image:
{
[fsbl_config] a53_x64
[bootloader] <zynqmp_fsbl.elf>
[pmufw_image] <pmufw.elf>
[destination_device=pl] <bitstream>
[destination_cpu=a53-0, exception_level=el-3, trustzone] <bl31.elf>
[destination_cpu=a53-0, exception_level=el-2] <u-boot.elf>
}

This assumes that the BIF file resides in the images directory.

4. Build the platform project - in the Assistant view right-click the newly created
platform project and then click 'Build'.

5. Create and build an application project in Vitis:
a) File->New->Application Project
Set System project to Create New...
Select the platform, provide sysroot path
Select Linux Hello World Application

b) In the Assistant view right-click the application (the relevant
configuration - Debug or Release) and then click 'Build'.

The above generates an .elf file that can be downloaded to the target and
executed there.

6. Application (cross-)debugging using Vitis:
a) Create a target connection - on the toolbar click 'Launch Target Connections'.
Open 'Linux TCF Agent' and click 'Add new target connection'. Specify the
target's IP address (under Host). Leave the default port number (1534). Click
'Test Connection' to test the connection.

b) In the Assistant view right-click the application (the relevant
configuration) and then click Debug-> Launch on Hardware (Single Application
Debug). This starts the debug session.

c) To edit the debug configuration - in the Assistant view right-click the
application (the relevant configuration) and then click Debug->
Debug Configurations...
In the Main tab select the proper connection.
In the Application tab make sure that 'Disconnect when last debug context
exits' is checked.

Note: when debugging applications in this manner the application's standard I/O
is redirected to a console window in the debugger (TCF Debug Process
Terminal).

Note: It is --mandatory-- that the symbols on the host match the code running on
the embedded target (inclding user-level code, e.g. XRFDC driver and other
library code). If not, application ELF that the debugger attempts to run on
the target can terminate abnormally during execution (not necessarily
immediately). Symptoms include a message to the TCF console indicating a
failure to resolve a symbol.

Note: the debugger has trouble stepping into library code (in assembly mode, of
course). To work around this problem, can manually enter the address of the
library routine in the text box at the top of the Disassembly window and
set a breakpoint there. Then click F8 (resume).

 

johnmcd
Xilinx Employee
Xilinx Employee
3,644 Views
Registered: ‎02-01-2008

It is unclear if you are using Vitis for an acceleration project or just to create linux apps.

If you are just creating linux apps, then you can do the following:

  1. Use petalinux on VM or linux box to build linux kernel and optionally the boot files
  2. Use petalinux on VM or linux to create sysroot (petalinux-build --sdk)
  3. Run generated sdk.sh to extract and create sysroot
  4. Copy the following directories from <sysroot directory>/aarch64-xilinx-linux to a directory on your windows system:
    lib
    usr/include
    usr/lib
  5. In Vitis (or SDK for older versions of tools) create your linux application
  6. configure your app:  C/C++ Build Settings -> ARM v8 Linux gcc compiler -> Directories :: add include path: <path to windows sysroot>/usr/include
  7. If using RFDC driver, libmetal and math libraries:
    configure your app: C/C++ Build Settings -> ARM v8 Linux gcc linker -> libraries :: add following libraries
    metal
    rfdc
  8. configure your app: C/C++ Build Settings -> ARM v8 Linux gcc linker -> libraries :: add library search path: <path to windows sysroot>/usr/lib
  9. configure your app: C/C++ Build Settings -> ARM v8 Linux gcc linker -> Miscellaneous :: and set Linker Flags as follows but replace path with your windows path to sysroot (also include the double quotes)
    --sysroot="C:\PATH"

Now you can use a Vitis debug configuration to download your app via ethernet and run/debug the app. Or, you can copy the Vitis Debug\your_app.elf to SD to run the app.

beni.falk
Participant
Participant
3,609 Views
Registered: ‎01-05-2020

I am using Vitis to compile and debug Linux.applications.

Thanks,

 

0 Kudos
mt-user-2019
Adventurer
Adventurer
3,525 Views
Registered: ‎07-29-2019

Hello @johnmcd ,

Thank you for this post because I am facing this problem.

I have vitis on windows 10

I have a Petalinux 2019.2 on VM ubuntu 18.04

 

I copied the sdk sysroot into a shared folder when vitis is linked as you described but 

 

How can I know which library to use ? I want to include 


#include "xparameters.h"
#include "xil_exception.h"
#include "xil_cache.h"
#include "xscugic.h"
#include "xipipsu.h"
#include "xipipsu_hw.h"

 

I have a A53 standalone app that I would like to move on custom Linux generated by petalinux 2019.2.

But maybe It is not possible....

 

Regards,

Again thank you

MT
0 Kudos
mt-user-2019
Adventurer
Adventurer
3,457 Views
Registered: ‎07-29-2019

Well I probably have to dig to ug1186 (open AMP).
If I understand right the equivalent bareMetal ipi can be done with it...
MT
0 Kudos
javier-rh
Visitor
Visitor
3,192 Views
Registered: ‎02-10-2020

Hi

I have the same problem. We want to develop Apps with Vitis in Windows, so developers don't have to install a virtual machine.

I use the command suggested by @beni.falk  “cp -R -L <plnx-project>images/linux/sdk/sysroots/aarch64-xilinx-linux <shared_folder>”, to copy the files to the windows shared folder, but I get several errors of duplicate files.

I try to copy only the files suggested by @johnmcd  (lib, usr/include, usr/lib) but I get the same errors.

 

There isn’t a easy way to develop Apps in Vitis without a Linux Virtual Machine?

0 Kudos
eethomc
Newbie
Newbie
1,837 Views
Registered: ‎02-04-2021

I wrote a pretty extensive blog post on this using WSL and Git https://doayee.co.uk/petalinux-on-windows-via-wsl-and-git/ which you can find here. It has specific instructions for allowing the Vitis IDE on Windows access to the Petalinux build from WSL.

0 Kudos
eyalniv4
Observer
Observer
1,805 Views
Registered: ‎12-03-2019

This is great!

I found myself laughing a couple of times from your ironic additions.

It doesn't work with Vitis 2020, Xilinx, I'm surprised

0 Kudos
eethomc
Newbie
Newbie
1,794 Views
Registered: ‎02-04-2021

Glad you enjoyed, I spent a good while banging my head on the wall trying to get this all set up... ironic additions were the more PG way of expressing myself

0 Kudos