aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2020-07-21 19:07:47 +0100
committerChuanhong Guo <gch981213@gmail.com>2020-07-26 17:08:21 +0800
commitf5cebbe2e49c3807d1bd3ed371da35ed2ef32314 (patch)
tree81cbe66f75f67a458815a42c63620b85311e557a /target/linux/mediatek
parent5787684cb4e241bd5d28237fbcad5d4a0dca7ba1 (diff)
downloadupstream-f5cebbe2e49c3807d1bd3ed371da35ed2ef32314.tar.gz
upstream-f5cebbe2e49c3807d1bd3ed371da35ed2ef32314.tar.bz2
upstream-f5cebbe2e49c3807d1bd3ed371da35ed2ef32314.zip
mediatek: mt7623: make gen_banana_pi_img.sh more generic
This actually covers fairly much all the MediaTek platforms; they only have different images because they don't include the preloader and U-Boot, and rely on preinstalled stuff from the vendor. So this script can slowly take over the world as we complete the support for various other platforms, starting with UniElec U7623… Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'target/linux/mediatek')
-rwxr-xr-xtarget/linux/mediatek/image/gen_banana_pi_img.sh21
-rw-r--r--target/linux/mediatek/image/mt7623.mk18
2 files changed, 24 insertions, 15 deletions
diff --git a/target/linux/mediatek/image/gen_banana_pi_img.sh b/target/linux/mediatek/image/gen_banana_pi_img.sh
index d46e92fa42..611a17edff 100755
--- a/target/linux/mediatek/image/gen_banana_pi_img.sh
+++ b/target/linux/mediatek/image/gen_banana_pi_img.sh
@@ -79,7 +79,7 @@
# with the preloader loading 512KiB of U-Boot starting at 0x50000.
usage() {
- echo "SYNTAX: $0 sd <file> <preloader image> <u-boot image> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
+ echo "SYNTAX: $0 sd <file> <preloader image> <u-boot image> <u-boot offset> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
echo " OR: $0 emmc <file> <preloader image>"
exit 1
}
@@ -96,20 +96,21 @@ BRLYT="BRLYT\x00\x00\x00\x01\x00\x00\x00\x00\x08\x00\x00\
case $1 in
sd)
- [ $# -eq 8 ] || usage
+ [ $# -eq 9 ] || usage
OUTPUT="$2"
PRELOADER="$3"
UBOOT="$4"
- BOOTFS="$5"
- ROOTFS="$6"
- BOOTFSSIZE="$7"
- ROOTFSSIZE="$8"
+ UBOOTOFS="$5"
+ BOOTFS="$6"
+ ROOTFS="$7"
+ BOOTFSSIZE="$8"
+ ROOTFSSIZE="$9"
head=4
sect=63
set $(ptgen -o $OUTPUT -h $head -s $sect -a 0 -l 1024 \
- -t 41 -p 512k@320k \
+ -t 41 -p 512k@${UBOOTOFS} \
-t c -p ${BOOTFSSIZE}M \
-t 83 -p ${ROOTFSSIZE}M )
@@ -123,7 +124,11 @@ case $1 in
echo -en "${SDMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0 conv=notrunc
echo -en "${BRLYT}" | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc
- dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc
+ # For eMMC-only boards like U7623 the preloader doesn't need to be included in the
+ # main image as it's only ever needed in the eMMC boot partition.
+ if [ -r ${PRELOADER} ]; then
+ dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc
+ fi
dd bs=512 if="${UBOOT}" of="${OUTPUT}" seek="${UBOOT_OFFSET}" conv=notrunc
dd bs=512 if="${BOOTFS}" of="${OUTPUT}" seek="${BOOTFS_OFFSET}" conv=notrunc
dd bs=512 if="${ROOTFS}" of="${OUTPUT}" seek="${ROOTFS_OFFSET}" conv=notrunc
diff --git a/target/linux/mediatek/image/mt7623.mk b/target/linux/mediatek/image/mt7623.mk
index ef14969029..1061a0d281 100644
--- a/target/linux/mediatek/image/mt7623.mk
+++ b/target/linux/mediatek/image/mt7623.mk
@@ -1,5 +1,5 @@
KERNEL_LOADADDR := 0x80008000
-DEVICE_VARS += UBOOT_TARGET
+DEVICE_VARS += UBOOT_TARGET UBOOT_OFFSET UBOOT_ENVSIZE
ifneq ($(CONFIG_BANANA_PI_BOOT_PARTSIZE),)
BOOTFS_BLOCK_SIZE := 1024
@@ -10,16 +10,18 @@ define Build/banana-pi-sdcard
rm -f $@.boot
mkfs.fat -C $@.boot $(BOOTFS_BLOCKS)
- ./gen_banana_pi_img.sh emmc $@.emmc \
- $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin
-
- mkenvimage -s 0x2000 -o $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-uboot.env $(UBOOT_TARGET)-uEnv.txt
+ if [ -r $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin ]; then \
+ ./gen_banana_pi_img.sh emmc $@.emmc \
+ $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin; \
+ mcopy -i $@.boot $@.emmc ::eMMCboot.bin; \
+ fi
+ mkenvimage -s $(UBOOT_ENVSIZE) -o $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-uboot.env $(UBOOT_TARGET)-uEnv.txt
mcopy -i $@.boot $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-uboot.env ::uboot.env
mcopy -i $@.boot $(IMAGE_KERNEL) ::uImage
- mcopy -i $@.boot $@.emmc ::eMMCboot.bin
./gen_banana_pi_img.sh sd $@ \
$(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin \
- $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-u-boot.bin \
+ $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-u-boot*.bin \
+ $(UBOOT_OFFSET) \
$@.boot \
$(IMAGE_ROOTFS) \
$(CONFIG_BANANA_PI_BOOT_PARTSIZE) \
@@ -41,6 +43,8 @@ define Device/bpi_bananapi-r2
DEVICE_DTS := mt7623n-bananapi-bpi-r2
DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \
mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk
+ UBOOT_ENVSIZE := 0x2000
+ UBOOT_OFFSET := 320k
UBOOT_TARGET := mt7623n_bpir2
IMAGES := img.gz
IMAGE/img.gz := banana-pi-sdcard | gzip | append-metadata