# Building kernel (kernel.tgz)

**URL:** <https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470>\
**Category:** Support\
**Created:** [July 8, 2020, 6:33pm UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470 "2020-07-08T18:33:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alireza\_Khodamoradi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/alireza_khodamoradi/32/1042_2.png) [@Alireza\_Khodamoradi](https://discuss.pynq.io/u/Alireza_Khodamoradi)\
**Post date:** [July 8, 2020, 6:33pm UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/1 "2020-07-08T18:33:01Z")

</div>

Hello,

After decompressing kernel.tgz into /usr/src/kernel, I am having trouble to make it. I followed some suggestions online, but I’m getting errors such as:

root@pynq:/usr/src/kernel# make  
CHK include/generated/compile.h  
make[1]: \*\*\* No rule to make target ‘init/main.o’, needed by ‘init/built-in.a’. Stop.  
Makefile:1052: recipe for target ‘init’ failed  
make: \*\*\* [init] Error 2

and others. Do I have to fix these errors one-by-one manually or am I missing any steps that is supposed to be executed before _make_?

---

<div class="post-metadata">

**Author:** ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)\
**Post date:** [July 10, 2020, 12:34am UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/2 "2020-07-10T00:34:38Z")

</div>

Some examples on how we build kernel modules on the board:  
[https://github.com/Xilinx/DPU-PYNQ/blob/master/upgrade/xrt/install.sh#L14](https://github.com/Xilinx/DPU-PYNQ/blob/master/upgrade/xrt/install.sh#L14)

---

<div class="post-metadata">

**Author:** ![Alireza\_Khodamoradi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/alireza_khodamoradi/32/1042_2.png) [@Alireza\_Khodamoradi](https://discuss.pynq.io/u/Alireza_Khodamoradi)\
**Post date:** [July 10, 2020, 8:27pm UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/3 "2020-07-10T20:27:24Z")

</div>

I followed the steps and got this error:

BUILD: Doing ‘make -j2’ parallel build  
Makefile.perf:6: …/scripts/utilities.mak: No such file or directory  
make[1]: \*\*\* No rule to make target ‘…/scripts/utilities.mak’. Stop.  
Makefile:69: recipe for target ‘all’ failed  
make: \*\*\* [all] Error 2

I was trying to build _perf_ for PYNQ. Here is how I got it to work:

- apt-get install linux-source
- cd /usr/src
- tar xvfj linux-source-4.15.0.tar.bz2
- cd linux-source-4.15.0/tools/perf
- make
- cp ./perf /usr/bin/perf

---

<div class="post-metadata">

**Author:** ![rock](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/rock/32/32_2.png) [@rock](https://discuss.pynq.io/u/rock)\
**Post date:** [July 10, 2020, 11:33pm UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/4 "2020-07-10T23:33:15Z")

</div>

Image v2.5 should be kernel 4.19.0, where you used 4.15.0. So I am not sure if the binary works well. Your flow should be good, but you need to download 4.19.0 tarball I guess. I think I did install perf in the past similar as you did.

---

<div class="post-metadata">

**Author:** ![Alireza\_Khodamoradi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/alireza_khodamoradi/32/1042_2.png) [@Alireza\_Khodamoradi](https://discuss.pynq.io/u/Alireza_Khodamoradi)\
**Post date:** [July 11, 2020, 1:05am UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/5 "2020-07-11T01:05:35Z")

</div>

Thank you for mentioning that. The 4.15.0 version worked fine, but to be safe, I compiled the correct version. Here are the instructions for 4.19.0 version:

- Download the source from here: [https://launchpad.net/ubuntu/+source/linux/4.19.0-12.13](https://launchpad.net/ubuntu/+source/linux/4.19.0-12.13). File: [linux\_4.19.0.orig.tar.gz](https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/linux/4.19.0-12.13/linux_4.19.0.orig.tar.gz)
  - tar xf linux\_4.19.0.tar.gz
  - cd linux-4.19/tools/perf
  - make
  - cp ./perf /usr/bin/perf

---

<div class="post-metadata">

**Author:** ![hcap](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@hcap](https://discuss.pynq.io/u/hcap)\
**Post date:** [May 19, 2022, 3:40pm UTC](https://discuss.pynq.io/t/building-kernel-kernel-tgz/1470/6 "2022-05-19T15:40:51Z")

</div>

Where can I find kernel.tgz for pynq 2.7, I do not find it back in the filesystem/image of a pynq 2.7 build with a prebuilt Ubuntu image for aarch64 (and using a make, not the shorter scripted approach with a bsp only). That being said the build completed with an error, but seemed to contain all things needed to run. I’d like to build a kernel module.

Using a plain vanilla xilinx petalinux kernel does not succeed due to a different kernel version number:  
**version magic ‘5.4.0 SMP mod\_unload modversions aarch64’ should be ‘5.4.0-xilinx-v2020.2 SMP mod\_unload aarch64’** (output of dmesg)  
With ‘5.4.0 SMP mod\_unload modversions aarch64’ the version of the module, compiled with petalinux kernel 2020.2 and ‘5.4.0-xilinx-v2020.2 SMP mod\_unload aarch64’ the expected version for pynq2.7

Is kernel.tgz for pynq 2.7 available somewhere for download? Or is there another way to solve this module version conflict.

> **[GitHub - Xilinx/linux-xlnx at xilinx-v2020.2](https://github.com/Xilinx/linux-xlnx/tree/xilinx-v2020.2)**
>
> xilinx-v2020.2
