From 390e3efde67bbcdaf98cb8b2d6ecee9a54e8d2c2 Mon Sep 17 00:00:00 2001
From: j1nx
Date: Tue, 4 Aug 2020 18:59:41 +0200
Subject: [PATCH] MycroftOS: Build, install and use the dtbo files from the
kernel sources. Instead of the pre-compiled version from the rpi-firmware
repository this to make sute everything is using the same version.
---
.../raspberrypi/genimage-raspberrypi3-64.cfg | 2 +-
.../raspberrypi/genimage-raspberrypi4-64.cfg | 2 +-
.../configs/rpi3_64-gui_defconfig | 2 +
.../configs/rpi4_64-gui_defconfig | 2 +
...erry-Pi-Overlays-from-kernel-sources.patch | 75 +++++++++++++++++++
5 files changed, 81 insertions(+), 2 deletions(-)
create mode 100644 buildroot-patches/0103-Compiling-Raspberry-Pi-Overlays-from-kernel-sources.patch
diff --git a/buildroot-external/board/raspberrypi/genimage-raspberrypi3-64.cfg b/buildroot-external/board/raspberrypi/genimage-raspberrypi3-64.cfg
index af1d17cd..128ebc6e 100644
--- a/buildroot-external/board/raspberrypi/genimage-raspberrypi3-64.cfg
+++ b/buildroot-external/board/raspberrypi/genimage-raspberrypi3-64.cfg
@@ -9,7 +9,7 @@ image boot.vfat {
"rpi-firmware/config.txt",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
- "rpi-firmware/overlays",
+ "overlays",
"Image"
}
}
diff --git a/buildroot-external/board/raspberrypi/genimage-raspberrypi4-64.cfg b/buildroot-external/board/raspberrypi/genimage-raspberrypi4-64.cfg
index 854e0c7e..51488757 100644
--- a/buildroot-external/board/raspberrypi/genimage-raspberrypi4-64.cfg
+++ b/buildroot-external/board/raspberrypi/genimage-raspberrypi4-64.cfg
@@ -6,7 +6,7 @@ image boot.vfat {
"rpi-firmware/config.txt",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
- "rpi-firmware/overlays",
+ "overlays",
"Image"
}
}
diff --git a/buildroot-external/configs/rpi3_64-gui_defconfig b/buildroot-external/configs/rpi3_64-gui_defconfig
index 72200ab6..aaa5a9e8 100644
--- a/buildroot-external/configs/rpi3_64-gui_defconfig
+++ b/buildroot-external/configs/rpi3_64-gui_defconfig
@@ -35,6 +35,8 @@ BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/a
BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi3"
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_DTS_OVERLAYS_SUPPORT=y
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
BR2_PACKAGE_LINUX_TOOLS_GPIO=y
diff --git a/buildroot-external/configs/rpi4_64-gui_defconfig b/buildroot-external/configs/rpi4_64-gui_defconfig
index 574826c1..85545830 100644
--- a/buildroot-external/configs/rpi4_64-gui_defconfig
+++ b/buildroot-external/configs/rpi4_64-gui_defconfig
@@ -39,6 +39,8 @@ BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_LZ4=y
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b broadcom/bcm2711-rpi-400 broadcom/bcm2711-rpi-cm4"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_DTS_OVERLAYS_SUPPORT=y
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
BR2_PACKAGE_LINUX_TOOLS_GPIO=y
diff --git a/buildroot-patches/0103-Compiling-Raspberry-Pi-Overlays-from-kernel-sources.patch b/buildroot-patches/0103-Compiling-Raspberry-Pi-Overlays-from-kernel-sources.patch
new file mode 100644
index 00000000..a8523f16
--- /dev/null
+++ b/buildroot-patches/0103-Compiling-Raspberry-Pi-Overlays-from-kernel-sources.patch
@@ -0,0 +1,75 @@
+From c69b94f5a260dea78f913c70741c034618c5c981 Mon Sep 17 00:00:00 2001
+From: j1nx
+Date: Tue, 4 Aug 2020 15:49:45 +0200
+Subject: [PATCH 1/1] Compiling Raspberry Pi Overlays from kernel sources.
+
+---
+ linux/Config.in | 7 +++++++
+ linux/linux.mk | 7 +++++++
+ package/rpi-firmware/Config.in | 7 +++----
+ 3 files changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/linux/Config.in b/linux/Config.in
+index c19ccb70a8..743b9290aa 100644
+--- a/linux/Config.in
++++ b/linux/Config.in
+@@ -417,6 +417,13 @@ config BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT
+
+ endif
+
++config BR2_LINUX_KERNEL_DTS_OVERLAYS_SUPPORT
++ bool "Build Device Tree Overlays"
++ depends on BR2_LINUX_KERNEL_DTS_SUPPORT
++ help
++ Build in-tree device tree overlays.
++ Currently supports Raspberry Pi kernels.
++
+ config BR2_LINUX_KERNEL_INSTALL_TARGET
+ bool "Install kernel image to /boot in target"
+ depends on !BR2_TARGET_ROOTFS_INITRAMFS
+diff --git a/linux/linux.mk b/linux/linux.mk
+index ae1edbeb55..7acd1d9998 100644
+--- a/linux/linux.mk
++++ b/linux/linux.mk
+@@ -430,6 +430,12 @@ define LINUX_INSTALL_DTB
+ endef
+ endif # BR2_LINUX_KERNEL_APPENDED_DTB
+ endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
++ifeq ($(BR2_LINUX_KERNEL_DTS_OVERLAYS_SUPPORT),y)
++define LINUX_INSTALL_DTB_OVERLAYS
++ mkdir -p $(1)
++ cp $(LINUX_ARCH_PATH)/boot/dts/overlays/*.dtbo $(1)
++endef
++endif # BR2_LINUX_KERNEL_DTS_OVERLAYS
+ endif # BR2_LINUX_KERNEL_DTS_SUPPORT
+
+ ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
+@@ -510,6 +516,7 @@ endef
+ define LINUX_INSTALL_IMAGES_CMDS
+ $(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
+ $(call LINUX_INSTALL_DTB,$(BINARIES_DIR))
++ $(call LINUX_INSTALL_DTB_OVERLAYS,$(BINARIES_DIR)/overlays)
+ endef
+
+ ifeq ($(BR2_STRIP_strip),y)
+diff --git a/package/rpi-firmware/Config.in b/package/rpi-firmware/Config.in
+index f5a25c5680..066d32168d 100644
+--- a/package/rpi-firmware/Config.in
++++ b/package/rpi-firmware/Config.in
+@@ -84,10 +84,9 @@ config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS
+ config BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS
+ bool "Install DTB overlays"
+ default y
+- depends on BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS \
+- || BR2_LINUX_KERNEL_DTS_SUPPORT
+- select BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT \
+- if BR2_LINUX_KERNEL_DTS_SUPPORT
++ depends on (BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTBS \
++ || BR2_LINUX_KERNEL_DTS_SUPPORT) && \
++ !BR2_LINUX_KERNEL_DTS_OVERLAYS_SUPPORT
+ help
+ Say 'y' here if you need to load one or more of the DTB
+ overlays, to support HATs (Hardware Attached on Top, add-on
+--
+2.20.1
+