[PATCH] firmware-utils: bcm4908img: convert into bcm63xximg package

Rafał Miłecki zajec5 at gmail.com
Thu Apr 1 16:06:47 BST 2021


From: Rafał Miłecki <rafal at milecki.pl>

1. This tool is also required on target devices (for flashing purposes)
   so make it a package
2. Originally this firmware format was used by bcm63xx so adjust name of
   this tool

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 package/utils/bcm63xximg/Makefile             | 52 +++++++++++++++++++
 package/utils/bcm63xximg/src/Makefile         |  7 +++
 .../utils/bcm63xximg/src/bcm63xximg.c         |  0
 target/linux/bcm4908/Makefile                 |  4 +-
 target/linux/bcm4908/image/Makefile           |  2 +-
 tools/firmware-utils/Makefile                 |  1 -
 6 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 package/utils/bcm63xximg/Makefile
 create mode 100644 package/utils/bcm63xximg/src/Makefile
 rename tools/firmware-utils/src/bcm4908img.c => package/utils/bcm63xximg/src/bcm63xximg.c (100%)

diff --git a/package/utils/bcm63xximg/Makefile b/package/utils/bcm63xximg/Makefile
new file mode 100644
index 0000000000..c4f660731e
--- /dev/null
+++ b/package/utils/bcm63xximg/Makefile
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bcm63xximg
+PKG_RELEASE:=1
+
+PKG_BUILD_DEPENDS := bcm63xximg/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/bcm63xximg
+  SECTION:=utils
+  CATEGORY:=Base system
+  TITLE:=Utility handling bcm63xx firmware images
+  MAINTAINER:=Rafał Miłecki <rafal at milecki.pl>
+  DEPENDS:=@TARGET_bcm4908
+endef
+
+define Package/bcm63xximg/description
+  CFE bootloader for bcm63xx uses custom firmware format. It consists of:
+  1. Optional cferom image
+  2. bootfs JFFS2 partition with cferam, kernel and optional helper files
+  3. rootfs simply appended to the bootfs
+  4. tail with checksum and basic device info
+
+  BCM4908 platform also uses this format. Additionaly it requires device
+  specific 94908.dtb in the bootfs partition.
+endef
+
+define Host/Prepare
+  $(CP) ./src/* $(HOST_BUILD_DIR)
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS) -Wall"
+endef
+
+define Package/bcm63xximg/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/bcm63xximg $(1)/usr/bin/
+endef
+
+define Host/Install
+	$(INSTALL_BIN) $(HOST_BUILD_DIR)/bcm63xximg $(STAGING_DIR_HOST)/bin/
+endef
+
+$(eval $(call BuildPackage,bcm63xximg))
+$(eval $(call HostBuild))
diff --git a/package/utils/bcm63xximg/src/Makefile b/package/utils/bcm63xximg/src/Makefile
new file mode 100644
index 0000000000..7ee284ab29
--- /dev/null
+++ b/package/utils/bcm63xximg/src/Makefile
@@ -0,0 +1,7 @@
+all: bcm63xximg
+
+bcm63xximg:
+	$(CC) $(CFLAGS) -o $@ bcm63xximg.c -Wall
+
+clean:
+	rm -f bcm63xximg
diff --git a/tools/firmware-utils/src/bcm4908img.c b/package/utils/bcm63xximg/src/bcm63xximg.c
similarity index 100%
rename from tools/firmware-utils/src/bcm4908img.c
rename to package/utils/bcm63xximg/src/bcm63xximg.c
diff --git a/target/linux/bcm4908/Makefile b/target/linux/bcm4908/Makefile
index 5bee66fe2b..398f3140d5 100644
--- a/target/linux/bcm4908/Makefile
+++ b/target/linux/bcm4908/Makefile
@@ -20,6 +20,8 @@ include $(INCLUDE_DIR)/target.mk
 
 KERNELNAME:=Image dtbs
 
-DEFAULT_PACKAGES += kmod-usb-ohci kmod-usb2 kmod-usb3
+DEFAULT_PACKAGES += \
+	bcm63xximg \
+	kmod-usb-ohci kmod-usb2 kmod-usb3
 
 $(eval $(call BuildTarget))
diff --git a/target/linux/bcm4908/image/Makefile b/target/linux/bcm4908/image/Makefile
index 30c60db488..903d1eb08a 100644
--- a/target/linux/bcm4908/image/Makefile
+++ b/target/linux/bcm4908/image/Makefile
@@ -22,7 +22,7 @@ define Build/bcm4908img
 
 	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad --little-endian --squash-uids \
 		-v -e 128KiB -o $@-bootfs.jffs2 -d $@-bootfs -m none -n
-	$(STAGING_DIR_HOST)/bin/bcm4908img create $@.new -f $@-bootfs.jffs2 \
+	$(STAGING_DIR_HOST)/bin/bcm63xximg create $@.new -f $@-bootfs.jffs2 \
 		-a 0x20000 -f $@
 	mv $@.new $@
 endef
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index e4a31b6fd0..28f8f0555a 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -28,7 +28,6 @@ define Host/Compile
 	$(call cc,addpattern)
 	$(call cc,asustrx)
 	$(call cc,bcm4908asus,-Wall)
-	$(call cc,bcm4908img,-Wall)
 	$(call cc,bcm4908kernel,-Wall)
 	$(call cc,buffalo-enc buffalo-lib,-Wall)
 	$(call cc,buffalo-tag buffalo-lib,-Wall)
-- 
2.26.2




More information about the openwrt-devel mailing list