imx: extract common combined image operations between subtargets
authorLech Perczak <lech.perczak@gmail.com>
Thu, 28 Apr 2022 21:31:34 +0000 (23:31 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Mon, 11 Jul 2022 12:18:40 +0000 (14:18 +0200)
The same combined image format can be used to boot both i.MX 6 and
i.MX 7 platforms - extract the common part.

Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
target/linux/imx/image/common.mk [new file with mode: 0644]
target/linux/imx/image/cortexa7.mk
target/linux/imx/image/cortexa9.mk

diff --git a/target/linux/imx/image/common.mk b/target/linux/imx/image/common.mk
new file mode 100644 (file)
index 0000000..8a9b260
--- /dev/null
@@ -0,0 +1,51 @@
+define Build/imx-combined-image-prepare
+       rm -rf $@.boot
+       mkdir -p $@.boot
+endef
+
+define Build/imx-combined-image-clean
+       rm -rf $@.boot $@.fs
+endef
+
+define Build/imx-combined-image
+       $(CP) $(IMAGE_KERNEL) $@.boot/uImage
+
+       $(foreach dts,$(DEVICE_DTS), \
+               $(CP) \
+                       $(DTS_DIR)/$(dts).dtb \
+                       $@.boot/;
+       )
+
+       mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
+               -n '$(DEVICE_ID) OpenWrt bootscript' \
+               -d bootscript-$(DEVICE_NAME) \
+               $@.boot/boot.scr
+
+       cp $@ $@.fs
+
+       $(SCRIPT_DIR)/gen_image_generic.sh $@ \
+               $(CONFIG_TARGET_KERNEL_PARTSIZE) \
+               $@.boot \
+               $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
+               $@.fs \
+               1024
+endef
+
+define Build/imx-sdcard
+       $(Build/imx-combined-image-prepare)
+
+       if [ -f $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img ]; then \
+               $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img \
+               $@.boot/u-boot.img; \
+       fi
+
+       if [ -f $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot-dtb.img ]; then \
+               $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot-dtb.img \
+               $@.boot/u-boot-dtb.img; \
+       fi
+
+       $(Build/imx-combined-image)
+       dd if=$(STAGING_DIR_IMAGE)/$(UBOOT)-SPL of=$@ bs=1024 seek=1 conv=notrunc
+
+       $(Build/imx-combined-image-clean)
+endef
index 063b89fdd6681d903412a25ee9d05303e0322dc8..9b2159c5406efd3e9cee5e6249b2765d94a55f37 100644 (file)
@@ -1,3 +1,5 @@
+include common.mk
+
 define Device/Default
   PROFILES := Default
   FILESYSTEMS := squashfs ext4
index 17a507b8da347a6ad268611c56d9deb80d5b2618..78079aa746b9ec5982dc3f28c6be5259b454264b 100644 (file)
@@ -1,5 +1,7 @@
 DEVICE_VARS += MKUBIFS_OPTS UBOOT
 
+include common.mk
+
 define Build/boot-overlay
        rm -rf $@.boot
        mkdir -p $@.boot
@@ -44,62 +46,10 @@ define Build/recovery-scr
        -d ./recovery-$(DEVICE_NAME) $@
 endef
 
-define Build/imx6-combined-image-prepare
-       rm -rf $@.boot
-       mkdir -p $@.boot
-endef
-
-define Build/imx6-combined-image-clean
-       rm -rf $@.boot $@.fs
-endef
-
-define Build/imx6-combined-image
-       $(CP) $(IMAGE_KERNEL) $@.boot/uImage
-
-       $(foreach dts,$(DEVICE_DTS), \
-               $(CP) \
-                       $(DTS_DIR)/$(dts).dtb \
-                       $@.boot/;
-       )
-
-       mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
-               -n '$(DEVICE_ID) OpenWrt bootscript' \
-               -d bootscript-$(DEVICE_NAME) \
-               $@.boot/boot.scr
-
-       cp $@ $@.fs
-
-       $(SCRIPT_DIR)/gen_image_generic.sh $@ \
-               $(CONFIG_TARGET_KERNEL_PARTSIZE) \
-               $@.boot \
-               $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
-               $@.fs \
-               1024
-endef
-
-define Build/imx6-sdcard
-       $(Build/imx6-combined-image-prepare)
-
-       if [ -f $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img ]; then \
-               $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img \
-               $@.boot/u-boot.img; \
-       fi
-
-       if [ -f $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot-dtb.img ]; then \
-               $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot-dtb.img \
-               $@.boot/u-boot-dtb.img; \
-       fi
-
-       $(Build/imx6-combined-image)
-       dd if=$(STAGING_DIR_IMAGE)/$(UBOOT)-SPL of=$@ bs=1024 seek=1 conv=notrunc
-
-       $(Build/imx6-combined-image-clean)
-endef
-
 define Build/apalis-emmc
-       $(Build/imx6-combined-image-prepare)
-       $(Build/imx6-combined-image)
-       $(Build/imx6-combined-image-clean)
+       $(Build/imx-combined-image-prepare)
+       $(Build/imx-combined-image)
+       $(Build/imx-combined-image-clean)
 endef
 
 
@@ -184,7 +134,7 @@ define Device/solidrun_cubox-i
   KERNEL_SUFFIX := -zImage
   FILESYSTEMS := squashfs
   IMAGES := combined.bin dtb
-  IMAGE/combined.bin := append-rootfs | pad-extra 128k | imx6-sdcard
+  IMAGE/combined.bin := append-rootfs | pad-extra 128k | imx-sdcard
   IMAGE/dtb := install-dtb
 endef
 TARGET_DEVICES += solidrun_cubox-i