Device Tree Overlay
A device tree overlay (DTO) is a fragment of device tree that is merged into the base device tree before the kernel starts. It can add, remove, or modify nodes and properties, which makes it possible to describe an optional piece of hardware — a camera module, a display panel, a fan — without maintaining a separate device tree for every possible combination.
On the R-Car V4H SH, overlays are shipped inside /boot/fitImage and are selected by U-Boot at
boot time. In the normal case the selection is automatic: the board detects what is connected and
applies the matching overlays, so you do not have to configure anything.
How Overlays Are Delivered
Every overlay is packaged into fitImage as its own FIT configuration. A configuration is
selected by appending its name to the boot address with a # separator, and several can be
combined:
bootm <addr>#<base-config>#<overlay-config>#<overlay-config>...
The first configuration is the base one. It supplies the kernel, the base device tree, the BL31 blob and, when present, the initramfs.
Every following configuration contributes only its device tree fragment, which U-Boot applies as an overlay, in the order written.
Note
Overlays are never applied with fdt apply from the U-Boot shell on this board. The only
supported way to apply one is to name its configuration in the bootm command line, as shown
above.
Boot Flow
The configuration string is assembled at boot time by boot.cmd, a U-Boot script that is itself
packaged inside fitImage:
bootcmd (U-Boot environment, stored in SPI flash)
└─ run autoconf_mmc | autoconf_nvme | autoconf_usb
├─ setenv bootargs "rw root=<device> rootwait"
├─ load <interface> 0:1 ${loadaddr} /boot/fitImage
└─ source ${loadaddr}:script → executes boot.cmd from inside fitImage
├─ probes the I2C buses to detect cameras and the display, and reads the fan variable
├─ derives the base configuration from root= in bootargs
└─ bootm ${loadaddr}${conf}
source ${loadaddr}:script means “execute the script sub-image of the FIT image loaded at
${loadaddr}”. This is the mechanism that lets the boot image itself decide which overlays are
applied. On a normal boot you type nothing.
Just before booting, boot.cmd echoes the command it is about to run, for example:
bootcmd: bootm 0x58000000#initramfs#uio#fan-argon40
Tip
That line is the single best place to start when a peripheral does not come up. It shows exactly which overlays were selected on this boot.
Available Configurations
fitImage contains two kinds of configuration. default and initramfs are the bootable
ones. Every other configuration carries nothing but one overlay, so it is not bootable on its own
and always has to follow one of the two.
Configuration |
Description |
|---|---|
|
Kernel, base device tree and BL31 blob. Used when the root filesystem is on the microSD card or on eMMC. |
|
Same as |
|
Exposes the R-Car V4H hardware IP (IMP, IMR, IMS and CMEM) 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 MIPI-DSI to HDMI adapter (LT8912B). |
|
Aliases of |
Automatic Detection
boot.cmd probes the I2C buses and the boot arguments, and builds the configuration string from
the result:
Slot |
Detection |
Configuration added |
|---|---|---|
Base |
|
|
Base |
|
|
UIO |
Always applied |
|
Camera J1 |
Device answers at I2C address |
|
Camera J1 |
Device answers at |
|
Camera J1 |
Device answers at |
|
Camera J2 |
Same three rules, on bus 2 |
|
Display J4 |
On bus 0, after the mux at |
|
Display J4 |
Same, config version |
|
Display J4 |
|
|
Display J4 |
Nothing answers at |
|
Display J4 |
Nothing answers at |
None. No display overlay is applied. |
Fan |
The |
|
Fan |
The |
|
Note
Fan selection is driven by the fan U-Boot environment variable, which boot.cmd never
sets itself. Set it once from the U-Boot prompt so the selection is explicit:
setenv fan pwm # or: setenv fan argon40
saveenv
The bootcmd: line echoed just before booting shows which fan overlay was actually
selected.
The configurations are always assembled in this fixed order:
base -> uio -> J1 camera -> J2 camera -> J4 display -> fan -> conf_append
Because overlays are applied from left to right, a later one can override properties set by an
earlier one, and anything you add through conf_append is applied last.
To create a new overlay or change which overlays are packaged into fitImage, refer to
Building the FIT Image.