Customize boot splash screen in Yocto
Tags: psplash, yocto, bitbake, linux
Published: 2022-08-23 21:06:00

My first wish as beginner in Yocto, once I managed to build my  first Linux image, was to to replace the Yocto logo on the boot splash  screen with my own logo. From this seemingly simple task I managed to learn a lot about Bitbake.

The default Yocto splash screen is rendered with the help of a recipe called _psplash_. This recipe is included in the Poky source directory and located at `meta/recipes-core/psplash`.

The rendered Yocto logo image is located in `meta/recipes-core/psplash/files/psplash-poky-img.h` in as a header file.

There are several ways to change the psplash logo. The following are some of them:

### 1. Replace the psplash-poky-img.h with a .png file
You can achieve this by replacing the `psplash-poky-img.h` image header file in the `files` directory with a logo in **png** format. Then add your logo path to the [**SRC_URI**](https://docs.yoctoproject.org/ref-manual/variables.html?highlight=src_uri#term-SRC_URI) through the **SPLASH_IMAGES** by changing the variable assignment:

From 

```
SPLASH_IMAGES = "file://psplash-poky-img.h;outsuffix=default"
```

to

```
SPLASH_IMAGES = "file://my-logo-image.png;outsuffix=default"
```

_assuming that your image is named my-logo-image.png in this case_.

When the image is baked, the new logo will be added to the boot splash screen.

> This approach is very simple, but the drawback is that the modifications are done in the Poky original source files which is not a good approach.

### 2. Create a recipe to extend psplash
The proper alternative is to create a new recipe that will append the same changes mentioned in the first approach above using `.bbappend` file.

The recipe will include a `psplash_%.bbappend` which in this case will contain 

```
SPLASH_IMAGES:forcevariable = "file://my-logo-image.png;outsuffix=default"
```

> **:forcevariable** is important to prevent machine specific overrides from overriding your logo such as in case of raspberry pi layers.

Furthermore, the logo image is placed in the `files` directory located in the same folder as the `psplash_%.bbappend` file. The files directory is then included to psplash's SRC_URI paths by adding the following line in the `psplash_%.bbappend` file.

```
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
```

> Do not forget to make the layer containing this recipe with higher priority (using [BBFILE_PRIORITY](https://docs.yoctoproject.org/ref-manual/variables.html?highlight=src_uri#term-BBFILE_PRIORITY) variable) than any other layer providing or overriding the psplash recipe.

### 3. meta-splash
[meta-splash](https://github.com/hamzamac/meta-splash) is a layer created using the second approach.

Using [meta-splash](https://github.com/hamzamac/meta-splash) all you need to do is:

1. Clone [meta-splash](https://github.com/hamzamac/meta-splash) layer in your Poky project: `git clone https://github.com/hamzamac/meta-splash.git`

2. Replace the default logo.png image in `meta-splash/recipes-core/psplash/files` with your logo image with name logo.png (the name can be customized in customize.bb)

3. Bake your image

That is all

To customize the colors and progress bar, check the meta-splash's [README](https://github.com/hamzamac/meta-splash)