Building the FIT Image
The fitimage target assembles the fitImage that U-Boot loads. It bundles the following into
a single file:
the kernel image,
the base DTB,
every device tree overlay, each exposed as its own FIT configuration,
the ARM Trusted Firmware BL31 blob,
the U-Boot boot script,
the initramfs.
Every one of them is built from source, so a single command produces a complete boot image:
./main_build.sh fitimage all
The following fitimage sub-commands are available:
Sub-command |
Description |
|---|---|
|
Build the kernel image, the device trees and the kernel modules, then the BL31 blob and the initramfs, and assemble the FIT image. |
|
Assemble the FIT image from an existing kernel build, without rebuilding the kernel. The BL31 blob and the initramfs are built only when they are missing. |
|
Remove |
The build writes the following files to FIT_OUTPUT_DIR:
File |
Description |
|---|---|
|
The FIT image to deploy to the target board. |
|
Generated image tree source describing the contents of the FIT image. Set |
|
Staged copies of the inputs referenced by |
Note
The BL31 blob is mandatory: the bootable configurations load it, and the build stops if it is
missing. It is built from source by the bl31 target, which fitimage runs itself when
the blob is not there, so no additional setup is required. See
Building the ARM Trusted Firmware BL31 Blob.
Important
fitimage all rebuilds the initramfs together with the kernel. The initramfs carries
pcie-rcar-gen4.ko, whose vermagic has to match the kernel packaged in the same
fitImage; a stale module would only fail at switch_root time, long after the boot
looks successful. fitimage image reuses an existing initramfs instead, so use it only when
the kernel has not changed.
FIT Configurations
fitImage contains two kinds of configuration. default and initramfs are the bootable
ones: they carry the kernel, the base DTB and the BL31 blob. Every other configuration carries
nothing but one device tree overlay, so it is not bootable on its own and has to be combined with
one of the two.
A configuration is selected by appending its name to the boot address with a # separator, and
several can be combined:
bootm ${loadaddr}#default#uio
The generated FIT image provides the following configurations:
Configuration |
Description |
|---|---|
|
Kernel, base DTB and BL31 blob. This is the default configuration. |
|
Same as |
|
Exposes the R-Car V4H hardware IP through UIO. Required by the CNN-IP, among others. |
|
IMX219 camera on connector J1 / J2. |
|
IMX462 camera on connector J1 / J2. |
|
IMX708 camera on connector J1 / J2. |
|
PWM-controlled fan. |
|
Argon40 fan. |
|
Raspberry Pi Touch Display 2, 5-inch / 7-inch model. |
|
Waveshare 13.3-inch MIPI DSI panel. |
|
Olimex DSI-to-HDMI adapter. |
Tip
The FIT image also embeds boot.cmd as a U-Boot script, which builds the configuration
string automatically. It always adds #uio, probes the I2C buses to detect which camera is
on J1 and J2 and which display is on J4, reads the fan environment variable to add the
matching fan overlay, and selects #initramfs instead of #default when root= in
bootargs is not an mmcblk device.
To add a configuration it does not select on its own, set the conf_append environment
variable in U-Boot: its value is appended to the end of the configuration string it builds.
Building the ARM Trusted Firmware BL31 Blob
The bootable FIT configurations load the BL31 blob through loadables, and the FIT image build
stops when the blob is missing. The bl31 target builds it from the ARM Trusted Firmware
source:
./main_build.sh bl31 all
The source is cloned from TFA_URL at the revision pinned in TFA_SRCREV into
TFA_SRC_DIR, and built for PLAT=rcar_gen4 with LSI=V4H. The following bl31
sub-commands are available:
Sub-command |
Description |
|---|---|
|
Fetch the source if needed, then build the blob. |
|
Re-clone the source at the pinned revision. |
|
Clean the TF-A build tree and remove |
The build writes three files to TFA_OUTPUT_DIR, which defaults to
rcar-utils/workspace/arm-trusted-firmware/release/:
File |
Description |
|---|---|
|
The blob packaged into |
|
Same firmware in ELF and S-record form, for debugging and for flashing. |
Note
The fitimage target builds BL31 itself when the blob is missing, and reuses it otherwise:
BL31 does not depend on the kernel, so it does not have to be rebuilt with it. Run
./main_build.sh bl31 all to rebuild it explicitly, for example after changing
TFA_SRCREV.
Setting BL31_BIN in config.ini points the FIT image at a blob from another build. That
blob is then used as it is and never rebuilt, and the build stops if the path does not exist.
Building the Initramfs
The initramfs is only needed to boot a root filesystem that is not on the microSD card or on
eMMC, such as an NVMe SSD behind PCIe. The PCIe controller driver is built as a module, so on such
a setup the driver needed to reach the root filesystem lives inside the root filesystem itself.
The initramfs breaks that loop: it loads the driver, waits for the root device to appear, and then
hands over to the real init with switch_root.
Build it with:
./main_build.sh initramfs all
The following initramfs sub-commands are available:
Sub-command |
Description |
|---|---|
|
Build busybox if needed, stage the tree, and pack |
|
Build the statically linked busybox only. |
|
Remove the busybox tree, the staged root filesystem and |
The image is written to INITRAMFS_OUTPUT_DIR, which defaults to
rcar-utils/workspace/initramfs/, and contains only what is needed to reach the root
filesystem: a statically linked busybox, pcie-rcar-gen4.ko taken from the kernel build, the
PCIe PHY firmware that the driver requests while bringing the link up, and the init script.
Important
This target needs the kernel modules of the current kernel build, so run
./main_build.sh kernel modules first if you have not built them yet. Otherwise the build
stops with an error naming the missing pcie-rcar-gen4.ko.
./main_build.sh fitimage all takes care of the ordering itself: it builds the kernel and
its modules, then the initramfs, and then packages both.
Note
If the board drops to an initramfs: shell during boot, the init script could not reach the
root filesystem. It prints the reason and lists the block devices it can see, which
distinguishes a driver that failed to load from a root device that never appeared.
Building the Out-of-Tree Kernel Modules
Some drivers are not part of the kernel source tree and are built separately by the
ext-modules target:
Module |
Description |
Installed to |
|---|---|---|
|
Contiguous memory allocator used by the multimedia and CNN stacks. |
|
|
Quality-of-service settings for the memory controller. |
|
|
PowerVR GPU kernel module. |
|
The sources are fetched automatically at the revisions pinned in config.ini and patched with
the patches under local-build-scripts/patches/, so only a built kernel is required.
Build and install them to KERNEL_MODULES_OUTPUT_DIR:
./main_build.sh ext-modules install
The following ext-modules sub-commands are available:
Sub-command |
Description |
|---|---|
|
Fetch the sources if needed, then build the modules. |
|
Re-clone the sources at the pinned revisions and re-apply the patches. |
|
Build the modules and install them to |
|
Clean the module build outputs. |
Besides the modules themselves, install writes the files the modules need in order to be
usable on the board:
File in |
Purpose |
|---|---|
|
Load |
|
Load |
|
PowerVR GPU firmware from the same release as the module. Without it |
|
Headers for applications built against these drivers. |
Important
These modules must be rebuilt whenever the kernel is rebuilt. They are compiled against the
kernel in KERNEL_DIR and are installed under the kernel release string, so a kernel built
with a different configuration or KERNEL_LOCALVERSION leaves them in a directory the running
kernel does not load.