mediatek: make emmc image generation work on mt7622
authorJohn Crispin <john@phrozen.org>
Thu, 4 Jun 2020 12:23:07 +0000 (14:23 +0200)
committerJohn Crispin <john@phrozen.org>
Sun, 7 Jun 2020 15:52:21 +0000 (17:52 +0200)
Signed-off-by: John Crispin <john@phrozen.org>
target/linux/mediatek/image/Makefile
target/linux/mediatek/image/gen_mt7622_emmc_img.sh [new file with mode: 0755]

index 385277fd3dec26aa2c50eebf3e51788f56ee3950..db702509ed3fcc1b20e80d17a34e61fb89a7de17 100644 (file)
@@ -12,7 +12,7 @@ define Build/sysupgrade-emmc
        rm -f $@.recovery
        mkfs.fat -C $@.recovery 3070
 
-       ./gen_mt7623_emmc_img.sh $@ \
+       ./gen_$(SUBTARGET)_emmc_img.sh $@ \
                $(IMAGE_KERNEL) \
                $@.recovery \
                $(IMAGE_ROOTFS)
diff --git a/target/linux/mediatek/image/gen_mt7622_emmc_img.sh b/target/linux/mediatek/image/gen_mt7622_emmc_img.sh
new file mode 100755 (executable)
index 0000000..d74068c
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+OUTPUT_FILE=$1
+KERNEL_FILE=$2
+RECOVERY_FILE=$3
+ROOTFS_FILE=$4
+
+BS=512
+
+#RECOVERY_OFFSET= kernel size / BS = 20M / 512 (blocks)
+RECOVERY_OFFSET=40960
+
+#ROOTFS_OFFSET = RECOVERY_OFFSET + (RECOVERY_SIZE / BS)
+#             = 40960 + (10M  / 512) (blocks)
+ROOTFS_OFFSET=61440
+dd bs="$BS" of="$OUTPUT_FILE" if="$KERNEL_FILE"
+dd bs="$BS" of="$OUTPUT_FILE" if="$RECOVERY_FILE" seek="$RECOVERY_OFFSET"
+dd bs="$BS" of="$OUTPUT_FILE" if="$ROOTFS_FILE" seek="$ROOTFS_OFFSET"
+dd if=/dev/zero of="$OUTPUT_FILE" bs=128k count=1 oflag=append conv=notrunc