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: 
880 Views
Registered: ‎03-28-2018

PetaLinux 2017.4 kernel panic after kernel rebuild

Hello,

 

I'm running PetaLinux 2017.4 on a Trenz te0803 SoM (UltraScale+ XCZU2EG), and running into an issue where I rebuild the Linux kernel in an existing project.

 

Starting with a clean kernel build environment, I can:

 

1. build a kernel in a clean environment (resulting image.ub is bootable)

2. apply or revert a known-good patch to the kernel (resulting image.ub is non-booting)

3. clean the working space and sstate for the kernel and rebuild (resulting image.ub is bootable)

 

This is reproducible across multiple machines for kernel changes, and anecdotally has been observed for non-kernel changes (possibly changes that require re-import of a hardware description).

 

From what I can tell, there is no documented solution to this issue (https://forums.xilinx.com/t5/Embedded-Linux/Petalinux-2016-4-large-image-boot/td-p/751694 references a similar behavior but does not provide a solution using INITRAMFS). It is not clear whether 2018.1 addresses this issue and I have not had a chance to upgrade a system to 2018.1 to test yet.

 

I'm curious if anyone else has encountered this and if there is a known solution that doesn't require cleaning up the kernel between builds?

 

Best regards,

Mike

 

Example steps to reproduce

 

 

Step 0 - Clean the kernel build and sstate, and delete anything from <projdir>/images/linux/

 

cd <projdir>
source <petalinuxdir>/settings.sh
petalinux-build -c virtual/kernel -x cleansstate
rm -rf images/linux/*

 

 

Step 1 - Build image

 

petalinux-build
... rebuild BOOT.bin ...

Built image files (~44 MB):

 

 

ls -l images/linux/
...
-rw-r--r-- 1 mike mike  44638720 May  4 11:38 Image
-rw-r--r-- 1 mike mike  44694408 May  4 11:45 image.ub
...

This image boots fine.

 

 

Step 2 - Apply (or revert) a kernel patch, resulting in a known-working kernel configuration and source, then rebuild image

 

petalinux-build
... rebuild BOOT.bin ...

 

Observe that Image is now 4.6 MB (reduced from 44.6 MB) and image.ub is 35.5 MB (reduced from 44.7 MB):

 

ls -l images/linux/
...
-rw-r--r-- 1 mike mike   4680192 May  4 12:17 Image
-rw-r--r-- 1 mike mike  35546100 May  4 12:17 image.ub
...

On boot, the console output ends with:

 

 

...
List of all partitions:
No filesystem could mount root, tried: 
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.0-xilinx-v2017.4 #3
Hardware name: xlnx,zynqmp (DT)
Call trace:
[<ffffff8008085df0>] dump_backtrace+0x0/0x198
[<ffffff8008085f9c>] show_stack+0x14/0x20
[<ffffff80081d7404>] dump_stack+0x94/0xb8
[<ffffff80080f5b00>] panic+0x114/0x25c
[<ffffff8008481238>] mount_block_root+0x298/0x2b4
[<ffffff80084812c8>] mount_root+0x74/0x84
[<ffffff8008481404>] prepare_namespace+0x12c/0x168
[<ffffff8008480e20>] kernel_init_freeable+0x1c0/0x1e0
[<ffffff80083aaae8>] kernel_init+0x10/0x100
[<ffffff8008082b30>] ret_from_fork+0x10/0x20
SMP: stopping secondary CPUs
Kernel Offset: disabled
Memory Limit: none
---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

 

I can further trace the bad file size back to the kernel build:

 

find build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/ -name 'Image*' -ls

 18483610   4572 -rw-r--r--   2 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/packages-split/kernel-image-image/boot/Image-4.9.0-xilinx-v2017.4
 18483079   4480 -rw-r--r--   1 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/image/boot/Image-4.9.0-xilinx-v2017.4
 18483610   4572 -rw-r--r--   2 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/package/boot/Image-4.9.0-xilinx-v2017.4
 18484045   4480 -rw-r--r--   2 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/deploy-linux-xlnx/Image-initramfs-4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0-plnx_aarch64-20180504191552.bin
 18484042      4 lrwxrwxrwx   2 mike     mike           76 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/deploy-linux-xlnx/Image-plnx_aarch64.bin -> Image--4.9-xilinx-v2017.4+git0+b450e900fd-r0-plnx_aarch64-20180504191552.bin
 18484046      4 lrwxrwxrwx   2 mike     mike           91 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/deploy-linux-xlnx/Image-initramfs-plnx_aarch64.bin -> Image-initramfs-4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0-plnx_aarch64-20180504191552.bin
 18484043      4 lrwxrwxrwx   2 mike     mike           76 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/deploy-linux-xlnx/Image -> Image--4.9-xilinx-v2017.4+git0+b450e900fd-r0-plnx_aarch64-20180504191552.bin
 18484041   4480 -rw-r--r--   2 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/deploy-linux-xlnx/Image--4.9-xilinx-v2017.4+git0+b450e900fd-r0-plnx_aarch64-20180504191552.bin
 19398971   4480 -rwxrwxr-x   1 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/linux-plnx_aarch64-standard-build/arch/arm64/boot/Image.initramfs
 19398885   4480 -rwxr-xr-x   1 mike     mike      4680192 May  4 12:17 build/tmp/work/plnx_aarch64-xilinx-linux/linux-xlnx/4.9-xilinx-v2017.4+gitAUTOINC+b450e900fd-r0/linux-plnx_aarch64-standard-build/arch/arm64/boot/Image

 

 

Step 3 - clean kernel build and sstate and rebuild same kernel

petalinux-build -c virtual/kernel -x cleansstate
petalinux-build
... rebuild BOOT.bin ...

Built images (again ~44 MB):

ls -l images/linux/
...
-rw-r--r-- 1 mike mike 44112384 May 4 12:30 Image
-rw-r--r-- 1 mike mike 44176372 May 4 12:30 image.ub
...

This image boots fine.

 

2 Replies
Mentor jmcclusk
Mentor
861 Views
Registered: ‎02-24-2014

Re: PetaLinux 2017.4 kernel panic after kernel rebuild

Ugh..  It really looks like the kernel build is only workable from a completely clean state.   Which means that any patching forces a cleanup before rebuilding.   Thank you for bringing this to our attention.   Kudo's to you, Michael.

Don't forget to close a thread when possible by accepting a post as a solution.
0 Kudos
845 Views
Registered: ‎03-28-2018

Re: PetaLinux 2017.4 kernel panic after kernel rebuild

Thank you for the feedback! I was toying with a recipe modification that would clean things up when (and only when) the kernel needed to be rebuilt. The closest I got was to add do_cleansstate as a task after do_setscene or do_fetch, which unfortunately defeats setscene and forces a kernel recompile with every build. Do you have any suggestions for another way to inject a cleanup operation into a linux-xlnx_%.bbappend ?
0 Kudos