📜 ⬆️ ⬇️

Replacing the boot-animation of an Android device with flickering Linux kernel logs

After developing a custom bootloader for my phone, I wanted to implement the output of nuclear logs on the display, as Linux desktop distributions can do. And all because personally when I boot the phone, it’s much more interesting to watch the flashing kmsg logs, rather than watching the bootloader logo first, and then also the Android boot animation of the system. In two years, the “boring wallpapers” have already become boring.

Now I will try to briefly tell you about the LLCON module for the Android kernel, which implements low-level output of kmsg logs to the display.

I will immediately mention that in any Linux kernel there is a module that deals with the output of nuclear logs on the screen. This kernel mechanism is enabled by specifying the FRAMEBUFFER_CONSOLE option. But this mechanism works only through the display driver, which is usually initialized at the very last (late_init stage). Because of this feature, the primary bootloader logo will be displayed for quite some time.

The words "low-level output" I use is not casual, because The LLCON module works directly with video memory (I immediately recall young crafts for MS-DOS) and at the same time begins its work before initializing the internal Linux kernel drivers (early_init). These features allow LLCON to start displaying kernel logs to the screen as quickly as possible.
')
After adding the LLCON module, the following options should be added to the kernel config:
CONFIG_VT=y CONFIG_LLCON=y CONFIG_FONTS=y CONFIG_FONT_6x11=y CONFIG_FONT_8x16=y CONFIG_FONT_SUN12x22=y 

In this case, I have specified 3 different fonts, since in the loader I use, you can choose any font. But if you need to keep the minimum size of the kernel image, then you should specify only one font.

Before starting the assembly of a modified kernel, you should not forget to add a new kernel option to BoardConfig:
 androidboot.llcon=<mode>,<delay>,<textwrap>,<fb_addr>,<fb_bpp>,<fb_height>,<fb_width>,<fb_stride>,<font_size>,<font_color> 

Explanation of parameters
  • mode:
    0 = LLCON is disabled
    1 = simultaneous logging (page scrolling)
    2 = asynchronous logging (line scrolling)
  • delay:
    delay in milliseconds (used in a stream that displays graphics on the screen; the recommended value is 100)
  • textwrap:
    0 = text wrap to new lines is prohibited
    1 = text wrap to new lines allowed
  • fb_addr:
    physical address framebuffer
  • fb_bpp:
    display pixel format (now ignored)
  • fb_height:
    display height in pixels
  • fb_width:
    display width in pixels
  • fb_stride:
    the size of one line in pixels or in bytes
  • font_size:
    font size (supported values: 6, 8, 10, 12)
  • font_color:
    color of characters in HEX format

Example:
 androidboot.llcon=2,100,0,0x03200000,24,1280,720,720,8,0xFFFFFF 

How to find out the value of the fb_addr parameter
The physical address of the FrameBuffer can be found in the DeviceTree of the assembled kernel. To do this, look for the parameter "qcom, memblock-reserve" in the branch "qcom, mdss_fb_primary". It is also very common for the FrameBuffer address to appear in the kmsg kernel logs.


I will not completely copy the source code for the LLCON module here, but only point out links to the corresponding patches:

It is also worth noting that without the completion of the init module (which is in ramdisk), the boot-animation will start playing when the android subsystems are initialized. Therefore, when using LLCON, you should automate the disabling of the boot-animation that this patch performs.

Demonstration of the LLCON module:



The LLCON module also has additional functionality, which is useful for:

But about these opportunities LLCON I will try to tell next time.

Source: https://habr.com/ru/post/310886/


All Articles