cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
liwenz
Explorer
Explorer
4,152 Views
Registered: ‎10-09-2017

Is there a simple way to compile petalinux modules and app?

In ug1165, I find a way to compile modules. After create the  modules, petalinux-build.

It takes a long time to finish. As it compile the module and maybe the system.

I have a lot of code which need to test for more, So I hope to compile the .ko module only, then test it.

 

I also hope a simple way to compile the app. Someone tell me to use aarch64-linux-gnu-gcc to compile app.May I use it to compile modules? How to?

 

0 Kudos
6 Replies
sandeepg
Moderator
Moderator
4,118 Views
Registered: ‎04-24-2017

Hi @liwenz,

 

modules depends on kernel source.

 

$ petalinux-build -c <recipe-module-name>

to build apps

 

$ petalinux-build -c <recipe-app-name>
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
liwenz
Explorer
Explorer
4,077 Views
Registered: ‎10-09-2017

Thanks for your help!

 

I know this way. It takes a long time to have a compile. Even I make a small mistake.

 

Now I know the application compile: 

arm-linux-gnueabihf-gcc helloworld.c -o helloworld

 

I also know about module compile:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  but I get a error.

I don't understand the Makefile and change it to my way.

 

I change to :

gcc -DMODULE -D__KERNEL__ -isystem /lib/modules/$(uname -r)/build/include -c hello.c -o hello.ko

but it also fails. 

 

I think I should know the option -isystem /lib/modules/$(uname -r)/build/include

Maybe it is a include path.

The last command come from : 

https://stackoverflow.com/questions/26113959/compiling-linux-kernel-module-using-gcc-with-kernel-header-files

 

anyone could help me?

 

ubuntu16,  petalinux 2018.2, zynq 7010

 

 

 

0 Kudos
sandeepg
Moderator
Moderator
4,069 Views
Registered: ‎04-24-2017

The one you mentioned will build for x86 $(uname -r) not for target. Once you have kernel source built then it should be fast to built out of tree modules.

 

Below is the how you can try something like this but this is not a recommended flow for any customers.

$ vim project-spec/meta-user/conf/petalinuxbsp.conf

RM_WORK_EXCLUDE += "linux-xlnx"

$ petalinux-build -x mrproper
$ petalinux-build -c kernel
$ cd <PATH_TO_MODULES_SRC>
$ export KERNEL_src=<TMPDIR_LOCATION_PATH>/work-shared/plnx-zynq/kernel-source
$ export KERNEL_VERSION=4.14.0-xilinx-v2018.2
$ export CC=aarch64-xilinx-linux-gcc -fuse-ld=bfd
$ export LD=aarch64-xilinx-linux-ld.bfd
$ make
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
liwenz
Explorer
Explorer
4,063 Views
Registered: ‎10-09-2017

Thanks for your reply.

But I have something I don't  understand.

I open the petalinuxbsp.conf. It is as below: Should I append your line?

 

#User Configuration

#OE_TERMINAL = "tmux"

# Add EXTRA_IMAGEDEPENDS default components
EXTRA_IMAGEDEPENDS_append_zynqmp = " virtual/fsbl virtual/pmu-firmware arm-trusted-firmware"
EXTRA_IMAGEDEPENDS_append_zynq = " virtual/fsbl"
EXTRA_IMAGEDEPENDS_append_microblaze = " virtual/fsboot virtual/elfrealloc"


#Remove all qemu contents
IMAGE_CLASSES_remove = "image-types-xilinx-qemu qemuboot-xilinx"
IMAGE_FSTYPES_remove = "wic.qemu-sd"

EXTRA_IMAGEDEPENDS_remove = "qemu-helper-native virtual/boot-bin"

 

After vim the petalinuxbsp.conf (which append your line), 

 

export CC=aarch64-xilinx-linux-gcc -fuse-ld=bfd

I think it should be  ( i use it to compile app)

export CC=arm-linux-gnueabihf-gcc

but why 

-fuse-ld=bfd

the last line  

export LD=aarch64-xilinx-linux-ld.bfd

 

I think it should be 32 bits, not 64 . I ever tried the 64 bits compile, the result does not work on my zynq petalinux.

I  change to 32 bits,then It work fine.

I don't know how to change this line. 

export LD=aarch64-xilinx-linux-ld.bfd
0 Kudos
sandeepg
Moderator
Moderator
4,034 Views
Registered: ‎04-24-2017

Looks like its confusing for you.

 

Let me split it up

 

$ vim project-spec/meta-user/conf/petalinuxbsp.conf

# Add this config variable at the bottom or any where it doesn't matter
RM_WORK_EXCLUDE += "linux-xlnx"

Run these commands from terminal console

$ petalinux-build -x mrproper
$ petalinux-build -c kernel
$ cd <PATH_TO_OUT_OF_TREE_MODULES_SRC>
$ export KERNEL_src=<TMPDIR_LOCATION_PATH>/work-shared/plnx-zynq/kernel-source
$ export KERNEL_VERSION=4.14.0-xilinx-v2018.2
$ export CC=aarch64-xilinx-linux-gcc -fuse-ld=bfd
$ export LD=aarch64-xilinx-linux-ld.bfd
$ make
Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
liwenz
Explorer
Explorer
4,016 Views
Registered: ‎10-09-2017

$ export CC=aarch64-xilinx-linux-gcc -fuse-ld=bfd
$ export LD=aarch64-xilinx-linux-ld.bfd

The 2 lines have some problem, as follow:

liwenz@ubuntu:~/pro/gpio/project-spec/meta-user/recipes-modules/blink/files$ export CC=aarch64-xilinx-linux-gcc -fuse-ld=bfd
bash: export: `-fuse-ld=bfd': not a valid identifier

 

another problem, my system is 32 not 64

64 bits can't run on my petalinux. 

0 Kudos