UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor wlin2
Visitor
9,139 Views
Registered: ‎11-21-2016

gcc in petalinux kernel

Hi everyone,

 

I am using the zcu102 es1 board and I have created a linux kernel with Petalinux BSP and successfully download the kernel to the zcu102 platform.

 

Then, I tried to compile some simple C code, ie Hello World, in the kernel but I cannot find the gcc. I am wondering how to add the gcc to the kernel, because it seems like I cannot use any command like apt-get to install the tools I want.

 

Thank you in advance

0 Kudos
13 Replies
Voyager
Voyager
9,125 Views
Registered: ‎06-24-2013

Re: gcc in petalinux kernel

Hey @wlin2,

 

Then, I tried to compile some simple C code, ie Hello World, in the kernel ...

You normally do not compile C code 'in the kernel' you compile it in userspace (petalinux in your case)

 

... but I cannot find the gcc.

Most likely it was not selected and thus not installed into the image.

 

I am wondering how to add the gcc to the kernel ...

You don't add it to the kernel, you add it as recipe to the petalinux configuration

 

it seems like I cannot use any command like apt-get to install the tools I want.

If you install a package manager like apt, you can probably use that as well, but I doubt that you want to do that.

 

Hope this clarifies,

Herbert

-------------- Yes, I do this for fun!
0 Kudos
Visitor wlin2
Visitor
9,111 Views
Registered: ‎11-21-2016

Re: gcc in petalinux kernel

Hi @hpoetzl,

 

Thank you for your reply. I am wondering how to add the gcc to the kernel image generated by petalinux, since I didn't see this option in petalinux-config. Are there any example?

 

Thank you

 

0 Kudos
Voyager
Voyager
9,108 Views
Registered: ‎06-24-2013

Re: gcc in petalinux kernel

Hey @wlin2,

 

Thank you for your reply.

You're welcome!

 

I am wondering how to add the gcc to the kernel image generated by petalinux,

You can add basically anything to petalinux with a proper recipe.

 

since I didn't see this option in petalinux-config.

Yes, it doesn't seem to be available, probably because Xilinx assumes that you don't want to run a compiler on the target.

 

Are there any example?

Maybe, haven't seen any gcc specific examples.

 

Maybe consider putting a full fledged distro like Ubuntu or Arch on the target where you have all the nice tools like compilers and build systems already available as packages?

 

Best,

Herbert

-------------- Yes, I do this for fun!
0 Kudos
Moderator
Moderator
9,071 Views
Registered: ‎10-06-2016

Re: gcc in petalinux kernel

Hi @wlin2

 

I just checked the packages within the petalinux rootfs and it doesn't seem to have any gcc compiler option in order to add it to you Linux image. Nevertheless that is a strange use case as the target machine in a embedded system is unlikely used for application compilation, and cross-compilation is used for that.

 

For cross-compilation, you can either use the following options:

1. Petalinux. Refer to UG1144 (adding custom applications) where is explained how to compile applications

2. Xilinx SDK. Create a linux application for your target board and compile it, then you can just copy it to your target.

3. Command line compilation with the cross-compiler.

 

Regards


Ibai
Don’t forget to reply, kudo, and accept as solution.
0 Kudos
Explorer
Explorer
8,598 Views
Registered: ‎10-18-2017

Re: gcc in petalinux kernel

So you are basically telling me to edit any user app I create on PetaLinux, I need to exit out of the QEMU/on-Zynq OS, make my changes, rebuilding with cross-compilation, then rebooting. I guess with the SDK, loading apps is easy, but this seems a pain if you want to do a PetaLinux/QEMU run

0 Kudos
Observer ewilliams01
Observer
8,583 Views
Registered: ‎09-21-2012

Re: gcc in petalinux kernel

We "side load" pre-compiled binaries (compiled in XSDK on a host/development machine) via FTP to the target board. We've got a physical hardware target, so the specifics of our setup aren't very relevant, but if you've got a network connection to the host through QEMU then you can try that as well. Not as quick as compiling on the target itself, but at least you don't have to rebuild the entire system.

Moderator
Moderator
8,567 Views
Registered: ‎10-06-2016

Re: gcc in petalinux kernel

@johnfrye11

 

As I pointed in the previous post, development in a ARM based target is not a usual use case as the most common use case is to use a development IDE for the development process. This way not only compilation can be done, debugging can be also done or different kind of analysis.

 

I do agree that development process with petalinux compilation is not a good approach but we do have the SDK for that use case. Use the SDK for the development process and use also the TCF debugging capabilities, once the application is done you can integrate it in your petalinux build flow in order to generate the final binary file.

 

Regards,

Ibai


Ibai
Don’t forget to reply, kudo, and accept as solution.
0 Kudos
Highlighted
Contributor
Contributor
7,061 Views
Registered: ‎08-31-2016

Re: gcc in petalinux kernel

1) Create this file:  meta-user/recipes-core/images/petalinux-user-image.bbappend

2) Add the following line to this file:

 

IMAGE_INSTALL += "packagegroup-core-buildessential"

 

It will add in the following packages to your build, and you will be able to run GCC on the target system.

 

RDEPENDS_packagegroup-core-buildessential = "\
    autoconf \
    automake \
    binutils \
    binutils-symlinks \
    cpp \
    cpp-symlinks \
    gcc \
    gcc-symlinks \
    g++ \
    g++-symlinks \
    gettext \
    make \
    libstdc++ \
    libstdc++-dev \
    libtool \
    pkgconfig \
    "

Visitor lowuze
Visitor
6,835 Views
Registered: ‎01-18-2018

Re: gcc in petalinux kernel

Could you tell more about this? When I try to build a kernel with this file, I get the following message: WARNING: No recipes available for: ....

0 Kudos
Moderator
Moderator
5,730 Views
Registered: ‎04-24-2017

Re: gcc in petalinux kernel

Hi @lowuze,

 

If you want to compile hello world program on ZCU102 target this means you need self host packages. If so then enable from 

petalinux-config -c rootfs ---> 
    Filesystem Packages --->
        misc ---> 
          [*] packagegroup-petalinux-self-hosted

Note: With this your image size will increase.

 

Or 

 

If you want to build application on host refer UG1144 petalinux apps creation section.

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
Visitor lowuze
Visitor
5,705 Views
Registered: ‎01-18-2018

Re: gcc in petalinux kernel

 Thank you, @sandeepg!

 

I just want to clarify, that it is correct to write "petalinux-config -c rootfs".

0 Kudos
Moderator
Moderator
5,666 Views
Registered: ‎04-24-2017

Re: gcc in petalinux kernel

@lowuze thanks for catching its a typo.

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Observer anmol_8496
Observer
1,597 Views
Registered: ‎01-03-2019

Re: gcc in petalinux kernel

Screenshot from 2019-10-09 11-37-34.pngerror when installing packages @sandeepgScreenshot from 2019-10-09 11-37-37.png

Tags (1)
0 Kudos