Skip to contentSkip to conversation

fitimage rework

PATCH Superseded Trevor Woerner 2 participants 2 messages Jun 13, 2025 – Jun 23, 2025 Arm Rockchip

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fitimage rework

oe-core has completely re-written the fitImage support starting roughly at commit [1], update meta-rockchip to match.

Most of the MACHINEs in meta-rockchip use a fitImage, but some don't. Create a boolean variable (RK_FITIMAGE), enabled by default, to keep track of which ones do and which ones don't. Use this variable to decide how to configure various image-related fields.

Run tested on the following with RAUC configured:
- nanopi-m4b
- nanopi-r2s
- radxa-zero-3e
- rock-pi-4b
- rock-pi-e
- rock-pi-s

Run tested on the following without RAUC:
- radxa-zero-3e
- rock-pi-e
- rock-pi-s

[1] oe-core: 3442d9297dca ("oe-selftest: fitimage: test external dtb")

---
changes in v3:
- remove the 2nd MACHINE_ESSENTIAL_EXTRA_RDEPENDS from the rockchip-extlinux.inc file and place the relevant portions into either the rockchip-fitimage.inc or rockchip-unfitimage.inc files as appropriate

changes in v2:
- remove the ",False" from the bb.utils.to_boolean() calls
- add informaton on new param (RK_FITIMAGE) to README
- re-structure the fitimage require so it is less invasive in MACHINE.conf files

---
 README                                       | 7 +++++++
 conf/machine/include/px30.inc                | 2 --
 conf/machine/include/rk3066.inc              | 2 +-
 conf/machine/include/rk3188.inc              | 2 +-
 conf/machine/include/rk3288.inc              | 2 +-
 conf/machine/include/rk3308.inc              | 2 --
 conf/machine/include/rk3328.inc              | 2 --
 conf/machine/include/rk3399.inc              | 2 --
 conf/machine/include/rk3566.inc              | 2 --
 conf/machine/include/rk3568.inc              | 2 --
 conf/machine/include/rk3588s.inc             | 2 --
 conf/machine/include/rockchip-defaults.inc   | 3 +++
 conf/machine/include/rockchip-extlinux.inc   | 7 +++----
 conf/machine/include/rockchip-fitimage.inc   | 5 +++++
 conf/machine/include/rockchip-unfitimage.inc | 2 ++
 15 files changed, 23 insertions(+), 21 deletions(-)
 create mode 100644 conf/machine/include/rockchip-fitimage.inc
 create mode 100644 conf/machine/include/rockchip-unfitimage.inc
README +7 -0
index 9672c6ab8d5b..5a12f6118fae 100644
@@ -159,6 +159,13 @@ Notes:
 	compatible (see Rockchip Media Process Platform (MPP) and
 	downstream gstreamer-rockchip plugin for those kernels).
 
+  RK_FITIMAGE
+
+	When generating an image, the BSP code needs to know whether or not to
+	package the pieces as a fitImage or not. By default it is assumed most
+	MACHINEs will use the fitImage format. Otherwise disable the RK_FITIMAGE
+	variable boolean to indicate otherwise.
+
 U-Boot Environment:
 ------------------
 	In order to configure U-Boot to be able to store its environment into the
conf/machine/include/px30.inc +0 -2
index 8173cb19be2c..1997f6fe6a9d 100644
@@ -11,8 +11,6 @@ require conf/machine/include/arm/armv8a/tune-cortexa35.inc
 require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 TFA_PLATFORM = "px30"
 TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3066.inc +1 -1
index a898309bbf88..90cadd82fbf2 100644
@@ -2,6 +2,7 @@
 # Released under the MIT license (see COPYING.MIT for the terms)
 
 SOC_FAMILY = "rk3066"
+RK_FITIMAGE = "False"
 
 require conf/machine/include/soc-family.inc
 require conf/machine/include/rockchip-defaults.inc
@@ -11,6 +12,5 @@ SERIAL_CONSOLES = "115200;ttyS2"
 
 KBUILD_DEFCONFIG = "multi_v7_defconfig"
 KERNEL_FEATURES:append:rk3066 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
conf/machine/include/rk3188.inc +1 -1
index 554d4f1c904d..23c2a806b3c4 100644
@@ -2,6 +2,7 @@
 # Released under the MIT license (see COPYING.MIT for the terms)
 
 SOC_FAMILY  = "rk3188"
+RK_FITIMAGE = "False"
 
 require conf/machine/include/soc-family.inc
 require conf/machine/include/rockchip-defaults.inc
@@ -11,6 +12,5 @@ SERIAL_CONSOLES = "115200;ttyFIQ0"
 
 KBUILD_DEFCONFIG = "multi_v7_defconfig"
 KERNEL_FEATURES:append:rk3188 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
 ENABLE_STATELESS_VPU_GST ?= "1"
conf/machine/include/rk3288.inc +1 -1
index 06fda69a3eb7..793a80a72430 100644
@@ -2,6 +2,7 @@
 # Released under the MIT license (see COPYING.MIT for the terms)
 
 SOC_FAMILY = "rk3288"
+RK_FITIMAGE = "False"
 
 require conf/machine/include/soc-family.inc
 require conf/machine/include/rockchip-defaults.inc
@@ -11,7 +12,6 @@ SERIAL_CONSOLES = "115200;ttyS2"
 
 KBUILD_DEFCONFIG ?= "multi_v7_defconfig"
 KERNEL_FEATURES:append:rk3288 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
 UBOOT_SUFFIX ?= "bin"
 
conf/machine/include/rk3308.inc +0 -2
index d30901f15b4f..6876564fbcb2 100644
@@ -13,8 +13,6 @@ SERIAL_CONSOLES = "1500000;ttyS0"
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3308 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 UBOOT_SUFFIX ?= "itb"
 UBOOT_ENTRYPOINT ?= "0x06000000"
conf/machine/include/rk3328.inc +0 -2
index e6f810dcd2ca..2fe2710399b1 100644
@@ -12,8 +12,6 @@ require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3328 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 TFA_PLATFORM = "rk3328"
 TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3399.inc +0 -2
index cd1be49064ed..8d30cf7e460b 100644
@@ -12,8 +12,6 @@ require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3399 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 TFA_PLATFORM = "rk3399"
 TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3566.inc +0 -2
index 6386ec7eb51c..5b65ad7d4a47 100644
@@ -11,8 +11,6 @@ require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3566 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
 PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rk3568.inc +0 -2
index bcf9dd8b0f44..ad3952de074c 100644
@@ -11,8 +11,6 @@ require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3568 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
 PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rk3588s.inc +0 -2
index 6ec344abae5b..203b97c6353c 100644
@@ -10,8 +10,6 @@ require conf/machine/include/rockchip-wic.inc
 
 KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_FEATURES:append:rk3588s = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
 PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
 PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rockchip-defaults.inc +3 -0
index 85ec7b944d1d..4e77a6291657 100644
@@ -1,9 +1,12 @@
 # meta-rockchip default settings
 MACHINEOVERRIDES =. "${@bb.utils.contains('ROCKCHIP_CLOSED_TPL', '1', 'closed-tpl:', '', d)}"
 MACHINEOVERRIDES =. "rockchip:"
+
 # kernel
+RK_FITIMAGE ?= "True"
 PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto"
 KCONFIG_MODE ?= "alldefconfig"
+require conf/machine/include/rockchip-${@ 'fitimage' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else 'unfitimage'}.inc
 
 # xserver
 XSERVER = " \
conf/machine/include/rockchip-extlinux.inc +3 -4
index fddab735bbf7..5753d062579f 100644
@@ -13,13 +13,12 @@ NONFITDT ?= "${@d.getVar('KERNEL_DEVICETREE').split()[0].split('/')[1]}"
 
 UBOOT_EXTLINUX ?= "1"
 UBOOT_EXTLINUX_ROOT ?= "root=PARTLABEL=rootfsA"
-UBOOT_EXTLINUX_FDTDIR ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot', d)}"
-UBOOT_EXTLINUX_FDT ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot/${NONFITDT}', d)}"
+UBOOT_EXTLINUX_FDTDIR ?= "${@ '' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '/boot'}"
+UBOOT_EXTLINUX_FDT ?= "${@ '' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '/boot/${NONFITDT}'}"
 UBOOT_EXTLINUX_CONSOLE ?= "earlycon console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8"
 UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw rootfstype=ext4"
-UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${KERNEL_IMAGETYPE}"
+UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${@ 'fitImage' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '${KERNEL_IMAGETYPE}'}"
 UBOOT_EXTLINUX_LABELS ?= "default"
 UBOOT_EXTLINUX_MENU_DESCRIPTION:default ?= "${MACHINE}"
 
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "u-boot-extlinux"
-MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-image ${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', 'kernel-devicetree', d)}"
conf/machine/include/rockchip-fitimage.inc new file +5 -0
new file mode 100644
index 000000000000..87c1334c7060
@@ -0,0 +1,5 @@
+KERNEL_CLASSES += "kernel-fit-extra-artifacts"
+KERNEL_IMAGETYPE ?= "Image"
+RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""
+KERNEL_DEPLOY_DEPEND ?= "linux-yocto-fitimage:do_deploy"
+MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "linux-yocto-fitimage"
conf/machine/include/rockchip-unfitimage.inc new file +2 -0
new file mode 100644
index 000000000000..6d4f23c67a65
@@ -0,0 +1,2 @@
+KERNEL_IMAGETYPE ?= "zImage"
+MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-devicetree"
Signature · 1 line
2.44.0.501.g19981daefd7c
#1 lore raw

Hi Trevor,

Quoted 60 lines · Trevor Woerner via lists.yoctoproject.org

oe-core has completely re-written the fitImage support starting roughly at commit [1], update meta-rockchip to match.

Most of the MACHINEs in meta-rockchip use a fitImage, but some don't. Create a boolean variable (RK_FITIMAGE), enabled by default, to keep track of which ones do and which ones don't. Use this variable to decide how to configure various image-related fields.

Run tested on the following with RAUC configured:
- nanopi-m4b
- nanopi-r2s
- radxa-zero-3e
- rock-pi-4b
- rock-pi-e
- rock-pi-s

Run tested on the following without RAUC:
- radxa-zero-3e
- rock-pi-e
- rock-pi-s

[1] oe-core: 3442d9297dca ("oe-selftest: fitimage: test external dtb")

---
changes in v3:
- remove the 2nd MACHINE_ESSENTIAL_EXTRA_RDEPENDS from the rockchip-extlinux.inc file and place the relevant portions into either the rockchip-fitimage.inc or rockchip-unfitimage.inc files as appropriate

changes in v2:
- remove the ",False" from the bb.utils.to_boolean() calls
- add informaton on new param (RK_FITIMAGE) to README
- re-structure the fitimage require so it is less invasive in MACHINE.conf files

---
  README                                       | 7 +++++++
  conf/machine/include/px30.inc                | 2 --
  conf/machine/include/rk3066.inc              | 2 +-
  conf/machine/include/rk3188.inc              | 2 +-
  conf/machine/include/rk3288.inc              | 2 +-
  conf/machine/include/rk3308.inc              | 2 --
  conf/machine/include/rk3328.inc              | 2 --
  conf/machine/include/rk3399.inc              | 2 --
  conf/machine/include/rk3566.inc              | 2 --
  conf/machine/include/rk3568.inc              | 2 --
  conf/machine/include/rk3588s.inc             | 2 --
  conf/machine/include/rockchip-defaults.inc   | 3 +++
  conf/machine/include/rockchip-extlinux.inc   | 7 +++----
  conf/machine/include/rockchip-fitimage.inc   | 5 +++++
  conf/machine/include/rockchip-unfitimage.inc | 2 ++
  15 files changed, 23 insertions(+), 21 deletions(-)

create mode 100644 conf/machine/include/rockchip-fitimage.inc create mode 100644 conf/machine/include/rockchip-unfitimage.inc

README +0 -0
index 9672c6ab8d5b..5a12f6118fae 100644

README Notes: · line 168

Quoted 10 lines
README +7 -0
@@ -159,6 +159,13 @@ Notes:
  	compatible (see Rockchip Media Process Platform (MPP) and
  	downstream gstreamer-rockchip plugin for those kernels).
 
+  RK_FITIMAGE
+
+	When generating an image, the BSP code needs to know whether or not to
+	package the pieces as a fitImage or not. By default it is assumed most
+	MACHINEs will use the fitImage format. Otherwise disable the RK_FITIMAGE
+	variable boolean to indicate otherwise.
+

Can you specify this is for the **kernel** fitimage? There can be many fitimages and we actually could generate one for U-Boot (u-boot.itb is one for example). This impacts only the kernel fitimage. Maybe also rename the variable to RK_KERNEL_FITIMAGE?

There's a very important piece of information left out here, this variable needs to be set before any include in the machine configuration file otherwise it won't work (I believe, haven't tried myself). This is the reason why we have inherit_defer now, because "dynamic" inherit simply didn't work due to how BitBake parses inherit and expands the dynamic part of the inherit call. Since we use require here and there is no require_defer, we don't have a choice and need to force the user to set this variable before the require line is parsed.

Quoted 21 lines
README +0 -0
  U-Boot Environment:
  ------------------
  	In order to configure U-Boot to be able to store its environment into the
conf/machine/include/px30.inc +0 -2
index 8173cb19be2c..1997f6fe6a9d 100644
@@ -11,8 +11,6 @@ require conf/machine/include/arm/armv8a/tune-cortexa35.inc
  require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  TFA_PLATFORM = "px30"
  TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3066.inc +0 -0
index a898309bbf88..90cadd82fbf2 100644

conf/machine/include/rk3066.inc line 5

Quoted 4 lines
conf/machine/include/rk3066.inc +1 -0
@@ -2,6 +2,7 @@
  # Released under the MIT license (see COPYING.MIT for the terms)
 
  SOC_FAMILY = "rk3066"
+RK_FITIMAGE = "False"

Please have them all still be ?= "False" so it can be overridden from a machine conf file before the rk3066 include.

Quoted 132 lines
conf/machine/include/rk3066.inc +0 -1
  require conf/machine/include/soc-family.inc
  require conf/machine/include/rockchip-defaults.inc
@@ -11,6 +12,5 @@ SERIAL_CONSOLES = "115200;ttyS2"
 
  KBUILD_DEFCONFIG = "multi_v7_defconfig"
  KERNEL_FEATURES:append:rk3066 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
  ENABLE_STATELESS_VPU_GST ?= "1"
conf/machine/include/rk3188.inc +1 -1
index 554d4f1c904d..23c2a806b3c4 100644
@@ -2,6 +2,7 @@
  # Released under the MIT license (see COPYING.MIT for the terms)
 
  SOC_FAMILY  = "rk3188"
+RK_FITIMAGE = "False"
 
  require conf/machine/include/soc-family.inc
  require conf/machine/include/rockchip-defaults.inc
@@ -11,6 +12,5 @@ SERIAL_CONSOLES = "115200;ttyFIQ0"
 
  KBUILD_DEFCONFIG = "multi_v7_defconfig"
  KERNEL_FEATURES:append:rk3188 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
  ENABLE_STATELESS_VPU_GST ?= "1"
conf/machine/include/rk3288.inc +1 -1
index 06fda69a3eb7..793a80a72430 100644
@@ -2,6 +2,7 @@
  # Released under the MIT license (see COPYING.MIT for the terms)
 
  SOC_FAMILY = "rk3288"
+RK_FITIMAGE = "False"
 
  require conf/machine/include/soc-family.inc
  require conf/machine/include/rockchip-defaults.inc
@@ -11,7 +12,6 @@ SERIAL_CONSOLES = "115200;ttyS2"
 
  KBUILD_DEFCONFIG ?= "multi_v7_defconfig"
  KERNEL_FEATURES:append:rk3288 = " bsp/rockchip/remove-non-rockchip-arch-arm.scc"
-KERNEL_IMAGETYPE ?= "zImage"
 
  UBOOT_SUFFIX ?= "bin"
 
conf/machine/include/rk3308.inc +0 -2
index d30901f15b4f..6876564fbcb2 100644
@@ -13,8 +13,6 @@ SERIAL_CONSOLES = "1500000;ttyS0"
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3308 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  UBOOT_SUFFIX ?= "itb"
  UBOOT_ENTRYPOINT ?= "0x06000000"
conf/machine/include/rk3328.inc +0 -2
index e6f810dcd2ca..2fe2710399b1 100644
@@ -12,8 +12,6 @@ require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3328 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  TFA_PLATFORM = "rk3328"
  TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3399.inc +0 -2
index cd1be49064ed..8d30cf7e460b 100644
@@ -12,8 +12,6 @@ require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3399 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  TFA_PLATFORM = "rk3399"
  TFA_BUILD_TARGET = "bl31"
conf/machine/include/rk3566.inc +0 -2
index 6386ec7eb51c..5b65ad7d4a47 100644
@@ -11,8 +11,6 @@ require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3566 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
  PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rk3568.inc +0 -2
index bcf9dd8b0f44..ad3952de074c 100644
@@ -11,8 +11,6 @@ require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3568 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
  PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rk3588s.inc +0 -2
index 6ec344abae5b..203b97c6353c 100644
@@ -10,8 +10,6 @@ require conf/machine/include/rockchip-wic.inc
 
  KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_FEATURES:append:rk3588s = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc"
-KERNEL_CLASSES = "kernel-fitimage"
-KERNEL_IMAGETYPE ?= "fitImage"
 
  PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin-tf-a"
  PREFERRED_PROVIDER_optee-os = "rockchip-rkbin-optee-os"
conf/machine/include/rockchip-defaults.inc +0 -0
index 85ec7b944d1d..4e77a6291657 100644

conf/machine/include/rockchip-defaults.inc line 10

Quoted 10 lines
conf/machine/include/rockchip-defaults.inc +3 -0
@@ -1,9 +1,12 @@
  # meta-rockchip default settings
  MACHINEOVERRIDES =. "${@bb.utils.contains('ROCKCHIP_CLOSED_TPL', '1', 'closed-tpl:', '', d)}"
  MACHINEOVERRIDES =. "rockchip:"
+
  # kernel
+RK_FITIMAGE ?= "True"
  PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto"
  KCONFIG_MODE ?= "alldefconfig"
+require conf/machine/include/rockchip-${@ 'fitimage' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else 'unfitimage'}.inc
 

This limits us in terms of location for the setting of RK_FITIMAGE as it needs to be set before this line is parsed otherwise it has no effect (today, but it can lead to inconsistent behavior if it's also directly used in recipes for example which would then be of the proper value but still requiring the wrong file here). A nice comment would suffice for now.

Quoted 40 lines
conf/machine/include/rockchip-defaults.inc +0 -0
  # xserver
  XSERVER = " \
conf/machine/include/rockchip-extlinux.inc +3 -4
index fddab735bbf7..5753d062579f 100644
@@ -13,13 +13,12 @@ NONFITDT ?= "${@d.getVar('KERNEL_DEVICETREE').split()[0].split('/')[1]}"
 
  UBOOT_EXTLINUX ?= "1"
  UBOOT_EXTLINUX_ROOT ?= "root=PARTLABEL=rootfsA"
-UBOOT_EXTLINUX_FDTDIR ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot', d)}"
-UBOOT_EXTLINUX_FDT ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot/${NONFITDT}', d)}"
+UBOOT_EXTLINUX_FDTDIR ?= "${@ '' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '/boot'}"
+UBOOT_EXTLINUX_FDT ?= "${@ '' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '/boot/${NONFITDT}'}"
  UBOOT_EXTLINUX_CONSOLE ?= "earlycon console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8"
  UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw rootfstype=ext4"
-UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${KERNEL_IMAGETYPE}"
+UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${@ 'fitImage' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else '${KERNEL_IMAGETYPE}'}"
  UBOOT_EXTLINUX_LABELS ?= "default"
  UBOOT_EXTLINUX_MENU_DESCRIPTION:default ?= "${MACHINE}"
 
  MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "u-boot-extlinux"
-MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-image ${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', 'kernel-devicetree', d)}"
conf/machine/include/rockchip-fitimage.inc new file +5 -0
new file mode 100644
index 000000000000..87c1334c7060
@@ -0,0 +1,5 @@
+KERNEL_CLASSES += "kernel-fit-extra-artifacts"
+KERNEL_IMAGETYPE ?= "Image"
+RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""
+KERNEL_DEPLOY_DEPEND ?= "linux-yocto-fitimage:do_deploy"
+MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "linux-yocto-fitimage"
conf/machine/include/rockchip-unfitimage.inc new file +0 -0
new file mode 100644
index 000000000000..6d4f23c67a65

conf/machine/include/rockchip-unfitimage.inc line 2

Quoted 2 lines
conf/machine/include/rockchip-unfitimage.inc new file +2 -0
@@ -0,0 +1,2 @@
+KERNEL_IMAGETYPE ?= "zImage"
+MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-devicetree"

We could avoid this file by making those the default in conf/machine/include/rockchip-defaults.inc for example.

"""
require ${@ 'conf/machine/include/rockchip-fitimage.inc' if bb.utils.to_boolean(d.getVar('RK_FITIMAGE')) else ''}

KERNEL_IMAGETYPE ?= "zImage" MACHINE_ESSENTIAL_EXTRA_RDEPENDS_KERNEL ?= "kernel-devicetree" MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "${MACHINE_ESSENTIAL_EXTRA_RDEPENDS_KERNEL}" """

An empty require (which we would have when RK_FITIMAGE is False) is legal and is a noop as far as I know.

Set MACHINE_ESSENTIAL_EXTRA_RDEPENDS_KERNEL to linux-yocto-fitimage in rockchip-fitimage.inc so this works.

I tested this with RK_FITIMAGE = "False" for a machine in my BSP layer and it did what it was supposed to :)

Cheers,
Quentin