From 319a6a3742ec6e4cd987a9f3a1b9bb1946ffa66e Mon Sep 17 00:00:00 2001
From: Oskar Viljasaar <oskar.viljasaar@iopsys.eu>
Date: Tue, 25 May 2021 00:21:43 +0200
Subject: [PATCH] brcm63xx: Remove all board features

As root.ubifs in the build directory is not used anymore, avoid
generating it by not providing 'ubifs' as a feature of the board.
This avoids <iopsyswrt>/scripts/target-metadata.pl setting
CONFIG_USES_UBIFS for the target, which in turn is responsible for
CONFIG_TARGET_ROOTFS_UBIFS having the value 'y' by default.
The same principle applies for CONFIG_TARGET_ROOTFS_JFFS2_NAND.

This has a cascading effect though, in that the Image/Build function
we define is not executed anymore, as it is run per-rootfs (see the
install_images target defined in the BuildImage section of
include/image.mk). As $(TARGET_FILESYSTEMS) is empty now, the loop
iterating on that variable is not run anymore.
To work around that, fill in the TARGET_FILESYSTEMS variable
ourselves. The loop itself does not do anything with it, and just
passes it on as $(1) to the Image/Build function. On our side, we
can just get away by ignoring it.

The remaining features removed are 'usb' and 'nand', these should
be provided by the bcm SDK.
---
 iopsys-brcm63xx-arm/Makefile       |  2 +-
 iopsys-brcm63xx-arm/image/Makefile | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/iopsys-brcm63xx-arm/Makefile b/iopsys-brcm63xx-arm/Makefile
index 8b64d7e73..e73b779c9 100644
--- a/iopsys-brcm63xx-arm/Makefile
+++ b/iopsys-brcm63xx-arm/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=iopsys-brcm63xx-arm
 BOARDNAME:=IOPSYS Broadcom ARM
-FEATURES:=usb jffs2_nand nand ubifs
+FEATURES:=
 MAINTAINER:=Benjamin Larsson <benjamin.larsson@iopsys.eu>
 CFLAGS:=-Os -pipe -mfpu=vfpv3-d16 -mfloat-abi=softfp
 CFLAGS += -DCONFIG_TARGET_iopsys_brcm63xx_arm
diff --git a/iopsys-brcm63xx-arm/image/Makefile b/iopsys-brcm63xx-arm/image/Makefile
index d58bc5717..06d966ee5 100644
--- a/iopsys-brcm63xx-arm/image/Makefile
+++ b/iopsys-brcm63xx-arm/image/Makefile
@@ -440,6 +440,17 @@ endif
 
 endef
 
+# Fill in the TARGET_FILESYSTEMS variable, used by include/image.mk
+# There is a loop iterating on it there, which will call Image/Build.
+# As we do not use the toplevel config options for the rootfs types in
+# this makefile, this is a good way to achieve something equivalent to
+# how a "more usual" image makefile would be called from the build system.
+TARGET_FILESYSTEMS += BCM_PKGTB
+
+# For the next soul wandering here: Keep the empty newlines
+# in this function. Otherwise make will complain about an
+# extraneous 'endif' in the makefile, and you will lose all
+# your hair while debugging this...
 define Image/Build
 
     ifdef CONFIG_TARGET_IMAGE_FIT
-- 
GitLab