bcm4908: build bootfs image per-SoC
authorRafał Miłecki <rafal@milecki.pl>
Wed, 20 Jul 2022 11:47:05 +0000 (13:47 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 25 Jul 2022 16:13:12 +0000 (18:13 +0200)
In theory we could have just 1 bootfs image for all devices as each
device has its own entry in the "configurations" node. It doesn't work
well with default configuration though.

If something goes wrong U-Boot SPL can be interrupted (by pressing A) to
enter its minimalistic menu. It allows ignoring boardid. In such case
bootfs default configuration is used.

For above reason each SoC family (BCM4908, BCM4912) should have its own
bootfs built. It allows each of them to have working default
configuration.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
target/linux/bcm4908/image/Makefile
target/linux/bcm4908/image/bootfs-bcm4908.its [new file with mode: 0644]
target/linux/bcm4908/image/bootfs-bcm4912.its [new file with mode: 0644]
target/linux/bcm4908/image/bootfs-generic.its [deleted file]
target/linux/bcm4908/image/bootfs.itsi [new file with mode: 0644]

index 809ae9fad463cea4300d6330c4eeceabf57081bd..7116c2a9f1fb2355dd29707d251be9c85a4ee124 100644 (file)
@@ -5,19 +5,20 @@ include $(INCLUDE_DIR)/image.mk
 
 DEVICE_VARS += ASUS_PRODUCTID ASUS_BUILD_NO ASUS_FW_REV ASUS_EXT_NO
 DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION
-DEVICE_VARS += PKGTB_ITS
+DEVICE_VARS += SOC
 
 define Image/Prepare
-       cp bootfs-generic.its $(KDIR)/
-       sed -i "s=\$$$${images_dir}=$(STAGING_DIR_IMAGE)=" $(KDIR)/bootfs-generic.its
-       sed -i "s=\$$$${dts_dir}=$(DTS_DIR)=" $(KDIR)/bootfs-generic.its
+       cp bootfs*.its* $(KDIR)/
+       sed -i "s=\$$$${images_dir}=$(STAGING_DIR_IMAGE)=" $(KDIR)/bootfs*.its*
+       sed -i "s=\$$$${dts_dir}=$(DTS_DIR)=" $(KDIR)/bootfs*.its*
 endef
 
 define Build/bootfs
        cat $@ | $(STAGING_DIR_HOST)/bin/lzma e -eos -si -so > $@.tmp
        mv $@.tmp $@
-       sed -i "s=\$${kernel}=$@=" $(KDIR)/bootfs-generic.its
-       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-generic.its $(KDIR)/bootfs-generic.itb
+       sed -i "s=\$${kernel}=$@=" $(KDIR)/bootfs*.its*
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-bcm4908.its $(KDIR)/bootfs-bcm4908.itb
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/bootfs-bcm4912.its $(KDIR)/bootfs-bcm4912.itb
 endef
 
 define Build/bcm4908asus
@@ -54,8 +55,8 @@ endef
 
 define Build/pkgtb
        mv $@ $@.rootfs
-       cp $(PKGTB_ITS) $@.its
-       sed -i "s=\$${bootfs}=$(KDIR)/bootfs-generic.itb=" $@.its
+       cp pkgtb-$(SOC).its $@.its
+       sed -i "s=\$${bootfs}=$(KDIR)/bootfs-$(SOC).itb=" $@.its
        sed -i "s=\$${rootfs}=$@.rootfs=" $@.its
        PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@
 endef
@@ -129,7 +130,7 @@ endef
 define Device/netgear_raxe500
   DEVICE_MODEL := RAXE500
   $(Device/netgear)
-  PKGTB_ITS := pkgtb-bcm4908.its
+  SOC := bcm4908
   NETGEAR_BOARD_ID := U12H449T00_NETGEAR
 endef
 # TARGET_DEVICES += netgear_raxe500
diff --git a/target/linux/bcm4908/image/bootfs-bcm4908.its b/target/linux/bcm4908/image/bootfs-bcm4908.its
new file mode 100644 (file)
index 0000000..b80cbd5
--- /dev/null
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/include/ "bootfs.itsi"
+
+/ {
+       images {
+               uboot {
+                       data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin");
+               };
+
+               fdt_uboot {
+                       data = /incbin/("${images_dir}/u-boot/u-boot.dtb");
+               };
+
+               fdt_uboot_RAX220 {
+                       description = "dtb";
+                       data = /incbin/("${images_dir}/u-boot/RAX220.dtb");
+                       type = "flat_dt";
+                       compression = "none";
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+
+               fdt_linux_RAX220 {
+                       description = "dtb";
+                       data = /incbin/("${dts_dir}/broadcom/bcm4908/bcm4908-netgear-raxe500.dtb");
+                       arch = "arm64";
+                       type = "flat_dt";
+                       compression = "none";
+               };
+       };
+
+       configurations {
+               conf_ub_RAX220 {
+                       description = "RAX220";
+                       fdt = "fdt_uboot_RAX220";
+                       loadables = "atf", "uboot";
+               };
+
+               conf_lx_RAX220 {
+                       description = "BRCM 63xxx linux";
+                       kernel = "kernel";
+                       fdt = "fdt_linux_RAX220";
+               };
+       };
+};
diff --git a/target/linux/bcm4908/image/bootfs-bcm4912.its b/target/linux/bcm4908/image/bootfs-bcm4912.its
new file mode 100644 (file)
index 0000000..7c91144
--- /dev/null
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/include/ "bootfs.itsi"
+
+/ {
+       images {
+               uboot {
+                       data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin");
+               };
+
+               fdt_uboot {
+                       data = /incbin/("${images_dir}/u-boot/u-boot.dtb");
+               };
+
+               fdt_GTAX6000 {
+                       description = "dtb";
+                       data = /incbin/("${images_dir}/u-boot/GTAX6000.dtb");
+                       type = "flat_dt";
+                       compression = "none";
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+       };
+
+       configurations {
+               conf_ub_GTAX6000 {
+                       description = "GTAX6000";
+                       fdt = "fdt_GTAX6000";
+                       loadables = "atf", "uboot";
+               };
+       };
+};
diff --git a/target/linux/bcm4908/image/bootfs-generic.its b/target/linux/bcm4908/image/bootfs-generic.its
deleted file mode 100644 (file)
index d32e094..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-
-/dts-v1/;
-
-/ {
-       description = "OpenWrt bootfs image";
-       #address-cells = <1>;
-
-       images {
-               atf {
-                       description = "ATF";
-                       data = /incbin/("${images_dir}/bl31.bin");
-                       type = "firmware";
-                       arch = "arm64";
-                       os = "arm-trusted-firmware";
-                       compression = "none";
-                       load = <0x4000>;
-                       entry = <0x4000>;
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               uboot {
-                       description = "U-Boot";
-                       data = /incbin/("${images_dir}/u-boot/u-boot-nodtb.bin");
-                       os = "U-Boot";
-                       arch = "arm64";
-                       compression = "none";
-                       load = <0x1000000>;
-                       entry = <0x1000000>;
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               kernel {
-                       description = "Linux kernel";
-                       data = /incbin/("${kernel}");
-                       type = "kernel";
-                       os = "linux";
-                       arch = "arm64";
-                       compression = "lzma";
-                       load = <0x80000>;
-                       entry = <0x80000>;
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               fdt_uboot {
-                       description = "dtb";
-                       data = /incbin/("${images_dir}/u-boot/u-boot.dtb");
-                       type = "flat_dt";
-                       compression = "none";
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               fdt_GTAX6000 {
-                       description = "dtb";
-                       data = /incbin/("${images_dir}/u-boot/GTAX6000.dtb");
-                       type = "flat_dt";
-                       compression = "none";
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               fdt_uboot_RAX220 {
-                       description = "dtb";
-                       data = /incbin/("${images_dir}/u-boot/RAX220.dtb");
-                       type = "flat_dt";
-                       compression = "none";
-
-                       hash-1 {
-                               algo = "sha256";
-                       };
-               };
-
-               fdt_linux_RAX220 {
-                       description = "dtb";
-                       data = /incbin/("${dts_dir}/broadcom/bcm4908/bcm4908-netgear-raxe500.dtb");
-                       arch = "arm64";
-                       type = "flat_dt";
-                       compression = "none";
-               };
-       };
-
-       configurations {
-               default = "conf_uboot";
-
-               conf_uboot {
-                       description = "BRCM 63xxx with uboot";
-                       fdt = "fdt_uboot";
-                       loadables = "atf", "uboot";
-               };
-
-               conf_ub_GTAX6000 {
-                       description = "GTAX6000";
-                       fdt = "fdt_GTAX6000";
-                       loadables = "atf", "uboot";
-               };
-
-               conf_ub_RAX220 {
-                       description = "RAX220";
-                       fdt = "fdt_uboot_RAX220";
-                       loadables = "atf", "uboot";
-               };
-
-               conf_lx_RAX220 {
-                       description = "BRCM 63xxx linux";
-                       kernel = "kernel";
-                       fdt = "fdt_linux_RAX220";
-               };
-       };
-};
diff --git a/target/linux/bcm4908/image/bootfs.itsi b/target/linux/bcm4908/image/bootfs.itsi
new file mode 100644 (file)
index 0000000..ceaaf10
--- /dev/null
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+/ {
+       description = "OpenWrt bootfs image";
+       #address-cells = <1>;
+
+       images {
+               atf {
+                       description = "ATF";
+                       data = /incbin/("${images_dir}/bl31.bin");
+                       type = "firmware";
+                       arch = "arm64";
+                       os = "arm-trusted-firmware";
+                       compression = "none";
+                       load = <0x4000>;
+                       entry = <0x4000>;
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+
+               uboot {
+                       description = "U-Boot";
+                       os = "U-Boot";
+                       arch = "arm64";
+                       compression = "none";
+                       load = <0x1000000>;
+                       entry = <0x1000000>;
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+
+               kernel {
+                       description = "Linux kernel";
+                       data = /incbin/("${kernel}");
+                       type = "kernel";
+                       os = "linux";
+                       arch = "arm64";
+                       compression = "lzma";
+                       load = <0x80000>;
+                       entry = <0x80000>;
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+
+               fdt_uboot {
+                       description = "dtb";
+                       type = "flat_dt";
+                       compression = "none";
+
+                       hash-1 {
+                               algo = "sha256";
+                       };
+               };
+       };
+
+       configurations {
+               default = "conf_uboot";
+
+               conf_uboot {
+                       description = "BRCM 63xxx with uboot";
+                       fdt = "fdt_uboot";
+                       loadables = "atf", "uboot";
+               };
+       };
+};