Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC PATCH 0/2] linux: install in-tree device-tree blob overlays
@ 2024-04-12 14:09 Gaël PORTAY
  2024-04-12 14:09 ` [Buildroot] [RFC PATCH 1/2] " Gaël PORTAY
  2024-04-12 14:09 ` [Buildroot] [RFC PATCH 2/2] board/raspberrypi: " Gaël PORTAY
  0 siblings, 2 replies; 5+ messages in thread
From: Gaël PORTAY @ 2024-04-12 14:09 UTC (permalink / raw)
  To: buildroot, Thomas Petazzoni
  Cc: Gaël PORTAY, Martin Bark, Julien Grossholtz

Hello,

This patch serie intends to address a possible out-of-sync for the
device-tree blob and overlays with the raspberrypi's. This follows
up[1].

The first patch adds the three configurations to install the dtbo's;
these configurations are copies of the original dtb's configurations.

The second patch applies these configurations to the raspberrypi's.

Note: All the story lives in the commit message of the first patch; this
could be drop if this patch serie is something you are interested in.

Note 2: I have also pending patches to support for wildcards for both
dtb's and dtbo's filenames that simplifies the integrator life if the
whole output files need to be installed.

Note 3: If you known other downstream trees that compiles dtbo's,
please tell me.

[1]: https://patchwork.ozlabs.org/project/buildroot/cover/20231121193448.1151936-1-gael.portay@rtone.fr/

Kind Regards,
Gaël PORTAY (2):
  linux: install in-tree device-tree blob overlays
  board/raspberrypi: install in-tree device-tree blob overlays

 board/raspberrypi/post-image.sh       |  2 +-
 configs/raspberrypi0w_defconfig       |  5 +++++
 configs/raspberrypi3_64_defconfig     |  4 ++++
 configs/raspberrypi3_defconfig        |  4 ++++
 configs/raspberrypi3_qt5we_defconfig  |  4 ++++
 configs/raspberrypi4_64_defconfig     |  4 ++++
 configs/raspberrypi4_defconfig        |  4 ++++
 configs/raspberrypicm4io_64_defconfig |  4 ++++
 configs/raspberrypicm4io_defconfig    |  4 ++++
 configs/raspberrypizero2w_defconfig   |  4 ++++
 linux/Config.in                       | 23 +++++++++++++++++++++++
 linux/linux.mk                        | 24 ++++++++++++++++++++++++
 12 files changed, 85 insertions(+), 1 deletion(-)

--
2.44.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [RFC PATCH 1/2] linux: install in-tree device-tree blob overlays
  2024-04-12 14:09 [Buildroot] [RFC PATCH 0/2] linux: install in-tree device-tree blob overlays Gaël PORTAY
@ 2024-04-12 14:09 ` Gaël PORTAY
  2024-08-30 12:20   ` Niklas Cassel via buildroot
  2024-04-12 14:09 ` [Buildroot] [RFC PATCH 2/2] board/raspberrypi: " Gaël PORTAY
  1 sibling, 1 reply; 5+ messages in thread
From: Gaël PORTAY @ 2024-04-12 14:09 UTC (permalink / raw)
  To: buildroot, Thomas Petazzoni
  Cc: Gaël PORTAY, Martin Bark, Julien Grossholtz

The device-tree blob overlays are automatically built from the custom
raspberrypi linux tree (for both architectures arm and arm64).

The device-tree overlays is mostly a downstream feature even though the
upstream kernel generates the symbols node into the device-tree blobs it
compiles (thanks to the option -@ in the DTC_FLAGS); and it does not
have intree device-tree overlays.

Note: The device-tree overlays require the node __symbols__ to be part
of the device-tree blob to get successfully loaded at runtime if the
overlaied nodes make reference to symbols from the original devicetree
blob.

The kernel image and the device-tree blobs for the raspberrypi boards
are built from the downstream linux package, and the device-tree blob
overlays are taken from the package rpi-firmware. Both packages linux
and rpi-firmware have to be closely synced.

The buildroot tree maintains the packages and the board configurations,
and it keeps things synced.

The downstream configurations in br2-external trees require to pay
attention to that synchronization as well. If the files are out-of-sync,
(i.e. the dtbos in the rpi-firmware package from the buildroot tree do
not match the linux commit in the br2-external tree), then the boot may
fail.

Since the Raspberry Pi's with Bluetooth have no dedicated debugging UART,
they require to merge the bt-miniuart.dtbo to restore the UART0 to the
accessible GPIOs of 40-pin GPIO header.

The investigation of the boot failure is comlicated if the root cause is
due to the out-of-sync merge of the debugging uart's dtbo to the dtb and
if firmware bootloader does not output the debug traces.

	MESS:00:00:05.389885:0: brfs: File read: /mfs/sd/overlays/miniuart-bt.dtbo
	MESS:00:00:05.408881:0: dterror: can't find symbol 'uart1_bt_pins'
	MESS:00:00:05.411942:0: Failed to resolve overlay 'miniuart-bt'

All this long story to introduce the three new dtbos configs to build
in-tree or out-of-tree dtbos, and to keep the directory name (assuming
the downstream trees uses the directory name overlays).

The three configs are the equivalent to existing dts configs:
 - BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES is equivalent to
   BR2_LINUX_KERNEL_INTREE_DTS_NAME
 - BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH is equivalent to
   BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
 - BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME is equivalent to
   BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME

Signed-off-by: Gaël PORTAY <gael.portay@rtone.fr>
---
 linux/Config.in | 23 +++++++++++++++++++++++
 linux/linux.mk  | 24 ++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/linux/Config.in b/linux/Config.in
index 2767b709d4..fdd57e6ff9 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -434,6 +434,29 @@ config BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
 	  Choose this option to support Device Tree overlays
 	  on the target system.

+config BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES
+	string "In-tree Device Tree Source Overlay file names"
+	depends on BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
+	help
+	  Name of in-tree device tree source file, without
+	  the trailing -overlay.dts. You can provide a list of
+	  dts files to build, separated by spaces.
+
+config BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH
+	string "Out-of-tree Device Tree Source Overlay file paths"
+	help
+	  Paths to out-of-tree Device Tree Source Overlay (-overlay.dts)
+	  and Device Tree Source Include (.dtsi) files, separated by
+	  spaces. These files will be copied to the kernel sources and
+	  the .dts files will be compiled from there.
+
+config BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME
+	bool "Keep the directory name of the Device Tree Overlay"
+	help
+	  If enabled, the device tree blob overlays keep their
+	  directory prefixes when they get copied to the
+	  output image directory or the target directory.
+
 endif

 config BR2_LINUX_KERNEL_INSTALL_TARGET
diff --git a/linux/linux.mk b/linux/linux.mk
index 4e12b36c1f..8b3563394d 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -199,6 +199,14 @@ LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_K

 LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))

+ifeq ($(BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT),y)
+LINUX_DTS_OVERLAY_NAMES += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES))
+
+LINUX_DTS_OVERLAY_NAMES += $(basename $(filter %-overlay.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH)))))
+
+LINUX_DTBOS = $(addsuffix .dtbo,$(LINUX_DTS_OVERLAY_NAMES))
+endif
+
 ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
 LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))
 LINUX_TARGET_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME))
@@ -459,10 +467,23 @@ define LINUX_INSTALL_DTB
 			$(1)/$(if $(BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME),$(dtb),$(notdir $(dtb)))
 	)
 endef
+define LINUX_INSTALL_DTBO
+	$(foreach dtbo,$(LINUX_DTBOS), \
+		install -D \
+			$(wildcard $(LINUX_ARCH_PATH)/boot/dts/$(dtbo)) \
+			$(1)/$(if $(BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME),$(dtbo),$(notdir $(dtbo)))
+	)
+endef
 endif # BR2_LINUX_KERNEL_APPENDED_DTB
 endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
 endif # BR2_LINUX_KERNEL_DTS_SUPPORT

+ifeq ($(BR2_LINUX_KERNEL_DTS_OVERLAY_SUPPORT),y)
+define LINUX_BUILD_DTBO
+	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_DTBOS)
+endef
+endif # BR2_LINUX_KERNEL_DTS_OVERLAY_SUPPORT
+
 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
 # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1
 define LINUX_APPEND_DTB
@@ -509,6 +530,7 @@ define LINUX_BUILD_CMDS
 	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
 	$(LINUX_BUILD_DTB)
 	$(LINUX_APPEND_DTB)
+	$(LINUX_BUILD_DTBO)
 endef

 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
@@ -530,6 +552,7 @@ ifeq ($(BR2_LINUX_KERNEL_INSTALL_TARGET),y)
 define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
 	$(call LINUX_INSTALL_IMAGE,$(TARGET_DIR)/boot)
 	$(call LINUX_INSTALL_DTB,$(TARGET_DIR)/boot)
+	$(call LINUX_INSTALL_DTBO,$(TARGET_DIR)/boot/overlays)
 endef
 endif

@@ -544,6 +567,7 @@ endef
 define LINUX_INSTALL_IMAGES_CMDS
 	$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
 	$(call LINUX_INSTALL_DTB,$(BINARIES_DIR))
+	$(call LINUX_INSTALL_DTBO,$(BINARIES_DIR))
 endef

 ifeq ($(BR2_STRIP_strip),y)
--
2.44.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [RFC PATCH 2/2] board/raspberrypi: install in-tree device-tree blob overlays
  2024-04-12 14:09 [Buildroot] [RFC PATCH 0/2] linux: install in-tree device-tree blob overlays Gaël PORTAY
  2024-04-12 14:09 ` [Buildroot] [RFC PATCH 1/2] " Gaël PORTAY
@ 2024-04-12 14:09 ` Gaël PORTAY
  1 sibling, 0 replies; 5+ messages in thread
From: Gaël PORTAY @ 2024-04-12 14:09 UTC (permalink / raw)
  To: buildroot, Thomas Petazzoni
  Cc: Gaël PORTAY, Martin Bark, Julien Grossholtz

This installs some device-tree blob overlays built in-tree by the
instead of installing the ones from the rpi-firmware.

Signed-off-by: Gaël PORTAY <gael.portay@rtone.fr>
---
 board/raspberrypi/post-image.sh       | 2 +-
 configs/raspberrypi0w_defconfig       | 5 +++++
 configs/raspberrypi3_64_defconfig     | 4 ++++
 configs/raspberrypi3_defconfig        | 4 ++++
 configs/raspberrypi3_qt5we_defconfig  | 4 ++++
 configs/raspberrypi4_64_defconfig     | 4 ++++
 configs/raspberrypi4_defconfig        | 4 ++++
 configs/raspberrypicm4io_64_defconfig | 4 ++++
 configs/raspberrypicm4io_defconfig    | 4 ++++
 configs/raspberrypizero2w_defconfig   | 4 ++++
 10 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/board/raspberrypi/post-image.sh b/board/raspberrypi/post-image.sh
index 9b9eac972b..8e6d19066b 100755
--- a/board/raspberrypi/post-image.sh
+++ b/board/raspberrypi/post-image.sh
@@ -12,7 +12,7 @@ if [ ! -e "${GENIMAGE_CFG}" ]; then
 	GENIMAGE_CFG="${BINARIES_DIR}/genimage.cfg"
 	FILES=()
 
-	for i in "${BINARIES_DIR}"/*.dtb "${BINARIES_DIR}"/rpi-firmware/*; do
+	for i in "${BINARIES_DIR}"/{overlays,*.dtb} "${BINARIES_DIR}"/rpi-firmware/*; do
 		FILES+=( "${i#${BINARIES_DIR}/}" )
 	done
 
diff --git a/configs/raspberrypi0w_defconfig b/configs/raspberrypi0w_defconfig
index ac72d49f92..683fd7ec8c 100644
--- a/configs/raspberrypi0w_defconfig
+++ b/configs/raspberrypi0w_defconfig
@@ -13,12 +13,17 @@ BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,17f135
 BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi"
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2708-rpi-zero-w"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
+
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi0w/config_0w.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypi3_64_defconfig b/configs/raspberrypi3_64_defconfig
index 6871dc0fe0..2dbf6cf363 100644
--- a/configs/raspberrypi3_64_defconfig
+++ b/configs/raspberrypi3_64_defconfig
@@ -17,6 +17,9 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi3"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2710-rpi-3-b broadcom/bcm2710-rpi-3-b-plus broadcom/bcm2837-rpi-3-b"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
@@ -24,6 +27,7 @@ BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi3-64/config_3_64bit.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig
index f0e7b82191..92e74002cb 100644
--- a/configs/raspberrypi3_defconfig
+++ b/configs/raspberrypi3_defconfig
@@ -17,6 +17,9 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
@@ -24,6 +27,7 @@ BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi3/config_3.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypi3_qt5we_defconfig b/configs/raspberrypi3_qt5we_defconfig
index 532b3ed686..0e6236dea4 100644
--- a/configs/raspberrypi3_qt5we_defconfig
+++ b/configs/raspberrypi3_qt5we_defconfig
@@ -18,6 +18,9 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
@@ -34,6 +37,7 @@ BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi3/config_3_qt5we.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 BR2_PACKAGE_RPI_USERLAND=y
 BR2_PACKAGE_CA_CERTIFICATES=y
 BR2_PACKAGE_NTP=y
diff --git a/configs/raspberrypi4_64_defconfig b/configs/raspberrypi4_64_defconfig
index 453bbe9440..6be9d3f366 100644
--- a/configs/raspberrypi4_64_defconfig
+++ b/configs/raspberrypi4_64_defconfig
@@ -17,12 +17,16 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt overlays/vc4-kms-v3d-pi4 overlays/imx219"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi4-64/config_4_64bit.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypi4_defconfig b/configs/raspberrypi4_defconfig
index 1ed5d34b56..5a4fa2b69b 100644
--- a/configs/raspberrypi4_defconfig
+++ b/configs/raspberrypi4_defconfig
@@ -17,12 +17,16 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2711-rpi-4-b"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi4/config_4.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypicm4io_64_defconfig b/configs/raspberrypicm4io_64_defconfig
index d53711c3a7..f74bfd04fa 100644
--- a/configs/raspberrypicm4io_64_defconfig
+++ b/configs/raspberrypicm4io_64_defconfig
@@ -17,12 +17,16 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-cm4"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt overlays/i2c-rtc overlays/dwc2"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypicm4io-64/config_cm4io_64bit.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypicm4io_defconfig b/configs/raspberrypicm4io_defconfig
index 4b50dc9ef9..54ff528f51 100644
--- a/configs/raspberrypicm4io_defconfig
+++ b/configs/raspberrypicm4io_defconfig
@@ -17,12 +17,16 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
 # Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2711-rpi-cm4"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt overlays/i2c-rtc overlays/dwc2"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypicm4io-64/config_cm4io.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
diff --git a/configs/raspberrypizero2w_defconfig b/configs/raspberrypizero2w_defconfig
index 1bf335c076..66cea3721e 100644
--- a/configs/raspberrypizero2w_defconfig
+++ b/configs/raspberrypizero2w_defconfig
@@ -16,11 +16,15 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-zero-2-w"
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES="overlays/miniuart-bt"
+BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME=y
 
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypizero2w/config_zero2w.txt"
+# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
 
 # MicroSD images generation tools
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
-- 
2.44.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [RFC PATCH 1/2] linux: install in-tree device-tree blob overlays
  2024-04-12 14:09 ` [Buildroot] [RFC PATCH 1/2] " Gaël PORTAY
@ 2024-08-30 12:20   ` Niklas Cassel via buildroot
  2024-09-02 19:57     ` Gaël PORTAY
  0 siblings, 1 reply; 5+ messages in thread
From: Niklas Cassel via buildroot @ 2024-08-30 12:20 UTC (permalink / raw)
  To: Gaël PORTAY
  Cc: Julien Grossholtz, Michael Walle, Damien Le Moal,
	Thomas Petazzoni, buildroot@buildroot.org, Martin Bark

Hello Gaël,

On Fri, Apr 12, 2024 at 04:09:44PM +0200, Gaël PORTAY wrote:
> The device-tree blob overlays are automatically built from the custom
> raspberrypi linux tree (for both architectures arm and arm64).
> 
> The device-tree overlays is mostly a downstream feature even though the
> upstream kernel generates the symbols node into the device-tree blobs it
> compiles (thanks to the option -@ in the DTC_FLAGS); and it does not
> have intree device-tree overlays.
> 
> Note: The device-tree overlays require the node __symbols__ to be part
> of the device-tree blob to get successfully loaded at runtime if the
> overlaied nodes make reference to symbols from the original devicetree
> blob.
> 
> The kernel image and the device-tree blobs for the raspberrypi boards
> are built from the downstream linux package, and the device-tree blob
> overlays are taken from the package rpi-firmware. Both packages linux
> and rpi-firmware have to be closely synced.
> 
> The buildroot tree maintains the packages and the board configurations,
> and it keeps things synced.
> 
> The downstream configurations in br2-external trees require to pay
> attention to that synchronization as well. If the files are out-of-sync,
> (i.e. the dtbos in the rpi-firmware package from the buildroot tree do
> not match the linux commit in the br2-external tree), then the boot may
> fail.
> 
> Since the Raspberry Pi's with Bluetooth have no dedicated debugging UART,
> they require to merge the bt-miniuart.dtbo to restore the UART0 to the
> accessible GPIOs of 40-pin GPIO header.
> 
> The investigation of the boot failure is comlicated if the root cause is
> due to the out-of-sync merge of the debugging uart's dtbo to the dtb and
> if firmware bootloader does not output the debug traces.
> 
> 	MESS:00:00:05.389885:0: brfs: File read: /mfs/sd/overlays/miniuart-bt.dtbo
> 	MESS:00:00:05.408881:0: dterror: can't find symbol 'uart1_bt_pins'
> 	MESS:00:00:05.411942:0: Failed to resolve overlay 'miniuart-bt'
> 
> All this long story to introduce the three new dtbos configs to build
> in-tree or out-of-tree dtbos, and to keep the directory name (assuming
> the downstream trees uses the directory name overlays).
> 
> The three configs are the equivalent to existing dts configs:
>  - BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES is equivalent to
>    BR2_LINUX_KERNEL_INTREE_DTS_NAME
>  - BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH is equivalent to
>    BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
>  - BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME is equivalent to
>    BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME
> 
> Signed-off-by: Gaël PORTAY <gael.portay@rtone.fr>
> ---
>  linux/Config.in | 23 +++++++++++++++++++++++
>  linux/linux.mk  | 24 ++++++++++++++++++++++++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/linux/Config.in b/linux/Config.in
> index 2767b709d4..fdd57e6ff9 100644
> --- a/linux/Config.in
> +++ b/linux/Config.in
> @@ -434,6 +434,29 @@ config BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
>  	  Choose this option to support Device Tree overlays
>  	  on the target system.
> 
> +config BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES
> +	string "In-tree Device Tree Source Overlay file names"
> +	depends on BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
> +	help
> +	  Name of in-tree device tree source file, without
> +	  the trailing -overlay.dts. You can provide a list of
> +	  dts files to build, separated by spaces.

I do not like that you assume that the DT overlay has a -overlay.dts suffix,
that seems to be something specific for the raspberry pi downstream kernel.

Most device tree overlays in the upstream kernel simply have a .dtso suffix:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=40658534756f8369e93b84fa75c20bde6528cb82

So it would be nice if your patch supported that as well.


Also see this other proposal from Michael Walle:
https://lore.kernel.org/buildroot/20240213154847.914068-1-michael@walle.cc/


Kind regards,
Niklas

> +
> +config BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH
> +	string "Out-of-tree Device Tree Source Overlay file paths"
> +	help
> +	  Paths to out-of-tree Device Tree Source Overlay (-overlay.dts)
> +	  and Device Tree Source Include (.dtsi) files, separated by
> +	  spaces. These files will be copied to the kernel sources and
> +	  the .dts files will be compiled from there.
> +
> +config BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME
> +	bool "Keep the directory name of the Device Tree Overlay"
> +	help
> +	  If enabled, the device tree blob overlays keep their
> +	  directory prefixes when they get copied to the
> +	  output image directory or the target directory.
> +
>  endif
> 
>  config BR2_LINUX_KERNEL_INSTALL_TARGET
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 4e12b36c1f..8b3563394d 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -199,6 +199,14 @@ LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_K
> 
>  LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))
> 
> +ifeq ($(BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT),y)
> +LINUX_DTS_OVERLAY_NAMES += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES))
> +
> +LINUX_DTS_OVERLAY_NAMES += $(basename $(filter %-overlay.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH)))))
> +
> +LINUX_DTBOS = $(addsuffix .dtbo,$(LINUX_DTS_OVERLAY_NAMES))
> +endif
> +
>  ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
>  LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))
>  LINUX_TARGET_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME))
> @@ -459,10 +467,23 @@ define LINUX_INSTALL_DTB
>  			$(1)/$(if $(BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME),$(dtb),$(notdir $(dtb)))
>  	)
>  endef
> +define LINUX_INSTALL_DTBO
> +	$(foreach dtbo,$(LINUX_DTBOS), \
> +		install -D \
> +			$(wildcard $(LINUX_ARCH_PATH)/boot/dts/$(dtbo)) \
> +			$(1)/$(if $(BR2_LINUX_KERNEL_DTBO_KEEP_DIRNAME),$(dtbo),$(notdir $(dtbo)))
> +	)
> +endef
>  endif # BR2_LINUX_KERNEL_APPENDED_DTB
>  endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
>  endif # BR2_LINUX_KERNEL_DTS_SUPPORT
> 
> +ifeq ($(BR2_LINUX_KERNEL_DTS_OVERLAY_SUPPORT),y)
> +define LINUX_BUILD_DTBO
> +	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_DTBOS)
> +endef
> +endif # BR2_LINUX_KERNEL_DTS_OVERLAY_SUPPORT
> +
>  ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
>  # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1
>  define LINUX_APPEND_DTB
> @@ -509,6 +530,7 @@ define LINUX_BUILD_CMDS
>  	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
>  	$(LINUX_BUILD_DTB)
>  	$(LINUX_APPEND_DTB)
> +	$(LINUX_BUILD_DTBO)
>  endef
> 
>  ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
> @@ -530,6 +552,7 @@ ifeq ($(BR2_LINUX_KERNEL_INSTALL_TARGET),y)
>  define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
>  	$(call LINUX_INSTALL_IMAGE,$(TARGET_DIR)/boot)
>  	$(call LINUX_INSTALL_DTB,$(TARGET_DIR)/boot)
> +	$(call LINUX_INSTALL_DTBO,$(TARGET_DIR)/boot/overlays)
>  endef
>  endif
> 
> @@ -544,6 +567,7 @@ endef
>  define LINUX_INSTALL_IMAGES_CMDS
>  	$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
>  	$(call LINUX_INSTALL_DTB,$(BINARIES_DIR))
> +	$(call LINUX_INSTALL_DTBO,$(BINARIES_DIR))
>  endef
> 
>  ifeq ($(BR2_STRIP_strip),y)
> --
> 2.44.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [RFC PATCH 1/2] linux: install in-tree device-tree blob overlays
  2024-08-30 12:20   ` Niklas Cassel via buildroot
@ 2024-09-02 19:57     ` Gaël PORTAY
  0 siblings, 0 replies; 5+ messages in thread
From: Gaël PORTAY @ 2024-09-02 19:57 UTC (permalink / raw)
  To: Niklas Cassel, Gaël PORTAY
  Cc: Julien Grossholtz, Michael Walle, Damien Le Moal,
	Thomas Petazzoni, buildroot@buildroot.org, Martin Bark

Hello Niklas,

On Fri Aug 30, 2024 at 2:20 PM CEST, Niklas Cassel via buildroot wrote:
> > +config BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAMES
> > +	string "In-tree Device Tree Source Overlay file names"
> > +	depends on BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
> > +	help
> > +	  Name of in-tree device tree source file, without
> > +	  the trailing -overlay.dts. You can provide a list of
> > +	  dts files to build, separated by spaces.
>
> I do not like that you assume that the DT overlay has a -overlay.dts suffix,
> that seems to be something specific for the raspberry pi downstream kernel.
>
> Most device tree overlays in the upstream kernel simply have a .dtso suffix:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=40658534756f8369e93b84fa75c20bde6528cb82
>
> So it would be nice if your patch supported that as well.
>

Thank you very much to let me know about that! I have missed it
entirely.

I based my work on linux 5.15 (raspberrypi), that may explain.

However, I figured out the out-of-tree built is broken, facepalm.

I will post a v1 with the fix.

> Also see this other proposal from Michael Walle:
> https://lore.kernel.org/buildroot/20240213154847.914068-1-michael@walle.cc/
>

I will have a look at it later, thanks.

> Kind regards,
> Niklas

Kind Regards,
Gaël
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-02 19:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12 14:09 [Buildroot] [RFC PATCH 0/2] linux: install in-tree device-tree blob overlays Gaël PORTAY
2024-04-12 14:09 ` [Buildroot] [RFC PATCH 1/2] " Gaël PORTAY
2024-08-30 12:20   ` Niklas Cassel via buildroot
2024-09-02 19:57     ` Gaël PORTAY
2024-04-12 14:09 ` [Buildroot] [RFC PATCH 2/2] board/raspberrypi: " Gaël PORTAY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox