04. Debuging (aka. the "fun" part)

If you faithfully followed the instructions up to this point, you'll be glad to know that you are precisely 3 bugs away from having a working Linux-based system. So, let's get started:

Bug A - bootm decompression error

After executing bootm, you may notice some successful loads of the FDT and ramdisk, but the following error during the kernel loading process:

uncompressed: uncompress error -28

The U-Boot source code may hold some answers.
The error message formatting looks something like ”%s: uncompress error %d”.
The error code is an errno value.
grep is your friend; but so is a text editor with LSP support.

Bug B - Kernel panic

Congratulations! The kernel is finally booting. I'm certain you're thankful for keeping that Makefile up to date, right? But what's this?

[    1.878803] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.887072] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.5.0-rc1-00248-gb6e6cc1f78c7 #1
[    1.894996] Hardware name: TechNexion PICO-PI-8M (DT)
[    1.900051] Call trace:
[    1.902501]  dump_backtrace+0x90/0xe8
[    1.906183]  show_stack+0x18/0x24
[    1.909510]  dump_stack_lvl+0x48/0x60
[    1.913182]  dump_stack+0x18/0x24
[    1.916503]  panic+0x31c/0x378
[    1.919567]  mount_root_generic+0x254/0x324
[    1.923762]  mount_root+0x16c/0x330

First time seeing a kernel panic may be a bit daunting, but the reason looks to be pretty clear:

Unable to mount root fs on unknown-block(0,0)

The kernel needs to know the backing device (and partition) for the root file system in order to mount it at /. Apparently, U-Boot did not know how to tell it to use the ramdisk as rootfs, but chances are that the kernel does know about it.

This is not documented in the command's help message but bootm relies on an environment argument called bootargs to pass the kernel its command line arguments. This should be a good place to start our investigation:

u-boot=> printenv bootargs
bootargs=console=ttymxc0,115200,115200 rdinit=/linuxrc clk_ignore_unused

From rdinit=/linuxrc we notice that the obsolete change_root procedure is being used. Since we don't actually have a persistent rootfs, let's just treat the ramdisk as root.

The environment variable can be changed from the U-Boot shell.
The name of the ramdisk device will be /dev/ram0.
Check the (partial) documentation on the kernel boot coomand line options.

Bug C - System freeze at login

Now that the kernel panic has been solved, the only remaining issue is a freeze right after forking into User Space. The final kernel log message should be indicative of the underlying problem:

Welcome to Buildroot
buildroot login:
[    9.473402] random: crng init done
[   33.757425] buck1: disabling

Try to decompile the device tree that we include in the FIT image and that is passed to Linux. What is buck1?
Apply the patch mentioned in the tips section below, then recompile the DTB and the FIT image. This should solve the problem.

This patch from the TechNexion fork of the Linux kernel contains the solution.
Apparently, the power regulator shuts itself down after a while if a certain attribute is not specified in the FDT.
It's always the butler power regulator.

ass/laboratoare/02/tasks/04.txt · Last modified: 2023/07/18 12:36 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0