aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/apm821xx/image
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/apm821xx/image')
-rw-r--r--target/linux/apm821xx/image/Makefile83
-rw-r--r--target/linux/apm821xx/image/mbl_boot.scr6
-rwxr-xr-xtarget/linux/apm821xx/image/mbl_gen_hdd_img.sh27
-rw-r--r--target/linux/apm821xx/image/mbl_gen_recovery_tar.sh92
4 files changed, 207 insertions, 1 deletions
diff --git a/target/linux/apm821xx/image/Makefile b/target/linux/apm821xx/image/Makefile
index ba11bb22ee..9ba43d9db2 100644
--- a/target/linux/apm821xx/image/Makefile
+++ b/target/linux/apm821xx/image/Makefile
@@ -78,6 +78,87 @@ define Device/mr24
endef
TARGET_DEVICES += mr24
-$(eval $(call BuildImage))
+endif
+
+ifeq ($(SUBTARGET),sata)
+
+### Image scripts for the WD My Book Live Series ###
+define Build/boot-script
+ $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
+ -d mbl_boot.scr \
+ $@.scr
+endef
+
+define Build/boot-img
+ $(RM) -rf $@.bootdir
+ mkdir -p $@.bootdir/boot
+
+ $(CP) $@.scr $@.bootdir/boot/boot.scr
+ $(CP) $@.dtb $@.bootdir/boot/$(DEVICE_DTB)
+ $(CP) $(word 1,$^) $@.bootdir/boot/uImage
+
+ genext2fs --block-size $(BLOCKSIZE) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
+
+ # convert it to revision 1 - needed for u-boot ext2load
+ $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
+ $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
+endef
+
+define Build/hdd-img
+ ./mbl_gen_hdd_img.sh $@ $@.boot $(word 2,$^)
+ $(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
+endef
+
+define Build/uRamdisk
+ $(call Image/mkfs/ext4)
+ gzip -9n -c $(KDIR)/root.ext4 > $(KDIR)/root.ext4.gz
+ $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T ramdisk -C gzip -n "$(PROFILE) rootfs" \
+ -d $(KDIR)/root.ext4.gz \
+ $@.uRamdisk
+endef
+
+define Build/recovery-tar
+ sh ./mbl_gen_recovery_tar.sh \
+ --profile $(DEVICE_PROFILE) \
+ --dtb $@.dtb \
+ --dtbname $(DEVICE_DTB) \
+ --kernel $@ \
+ --rootfs $@.uRamdisk \
+ $@
+endef
+
+define Device/MyBookLiveDefault
+ IMAGE_SIZE := 48m
+ BLOCKSIZE := 1024
+ DTB_SIZE := 16384
+ KERNEL := kernel-bin | gzip | uImage gzip
+ BOOT_SIZE := 8
+ IMAGES := rootfs.img recovery.tar
+ DEVICE_DTB := apollo3g.dtb
+ IMAGE/rootfs.img := boot-script | dtb | boot-img | hdd-img
+ IMAGE/recovery.tar := kernel-bin | dtb | uRamdisk | recovery-tar
+endef
+
+define Device/MyBookLiveSingle
+$(Device/MyBookLiveDefault)
+ DEVICE_TITLE := Western Digital My Book Live
+ DEVICE_DTS := apollo3g
+ DEVICE_PROFILE := apollo3g
+endef
+
+TARGET_DEVICES += MyBookLiveSingle
+
+define Device/MyBookLiveDuo
+$(Device/MyBookLiveDefault)
+ DEVICE_TITLE := Western Digital My Book Live Duo
+ DEVICE_PACKAGES := kmod-usb-dwc2 kmod-ledtrig-usbdev kmod-usb-storage kmod-fs-vfat wpad-mini
+ DEVICE_DTS := apollo3g-duo
+ DEVICE_PROFILE := ap2nc
+endef
+
+TARGET_DEVICES += MyBookLiveDuo
endif
+
+$(eval $(call BuildImage))
+
diff --git a/target/linux/apm821xx/image/mbl_boot.scr b/target/linux/apm821xx/image/mbl_boot.scr
new file mode 100644
index 0000000000..062dc2725a
--- /dev/null
+++ b/target/linux/apm821xx/image/mbl_boot.scr
@@ -0,0 +1,6 @@
+setenv boot_args 'setenv bootargs root=/dev/sda2 rw rootfstype=ext4'
+setenv load_part1 'sata init; ext2load sata 1:1 ${kernel_addr_r} /boot/uImage; ext2load sata 1:1 ${fdt_addr_r} /boot/apollo3g.dtb'
+setenv load_part2 'sata init; ext2load sata 0:1 ${kernel_addr_r} /boot/uImage; ext2load sata 0:1 ${fdt_addr_r} /boot/apollo3g.dtb'
+setenv load_sata 'if run load_part1; then echo Loaded part 1; elif run load_part2; then echo Loaded part 2; fi'
+setenv boot_sata 'run load_sata; run boot_args addtty; bootm ${kernel_addr_r} - ${fdt_addr_r}'
+run boot_sata
diff --git a/target/linux/apm821xx/image/mbl_gen_hdd_img.sh b/target/linux/apm821xx/image/mbl_gen_hdd_img.sh
new file mode 100755
index 0000000000..589dcf9150
--- /dev/null
+++ b/target/linux/apm821xx/image/mbl_gen_hdd_img.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+set -x
+[ $# -eq 3 ] || {
+ echo "SYNTAX: $0 <file> <bootfs image> <rootfs image>"
+ exit 1
+}
+
+OUTPUT="$1"
+BOOTFS="$2"
+ROOTFS="$3"
+let "BOOTFSSIZE=(`stat -c%s "$2"` + 1048575) / 1048576"
+let "ROOTFSSIZE=(`stat -c%s "$3"` + 1048575) / 1048576"
+
+head=4
+sect=63
+
+set `ptgen -o $OUTPUT -h $head -s $sect -l 4096 -t 83 -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
+
+BOOTOFFSET="$(($1 / 512))"
+BOOTSIZE="$(($2 / 512))"
+ROOTFSOFFSET="$(($3 / 512))"
+ROOTFSSIZE="$(($4 / 512))"
+
+dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
+dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
+
diff --git a/target/linux/apm821xx/image/mbl_gen_recovery_tar.sh b/target/linux/apm821xx/image/mbl_gen_recovery_tar.sh
new file mode 100644
index 0000000000..f871aefd8c
--- /dev/null
+++ b/target/linux/apm821xx/image/mbl_gen_recovery_tar.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+# based on scripts/sysupgrade-nand.sh
+
+profile=""
+dtb=""
+dtbname=""
+kernel=""
+rootfs=""
+outfile=""
+err=""
+
+while [ "$1" ]; do
+ case "$1" in
+ "--profile")
+ profile="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--dtb")
+ dtb="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--dtbname")
+ dtbname="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--kernel")
+ kernel="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--rootfs")
+ rootfs="$2"
+ shift
+ shift
+ continue
+ ;;
+ *)
+ if [ ! "$outfile" ]; then
+ outfile=$1
+ shift
+ continue
+ else
+ shift
+ continue
+ fi
+ ;;
+ esac
+done
+
+if [ -z "$profile" -o ! -r "$dtb" -o ! -r "$kernel" -o ! -r "$rootfs" -o ! "$outfile" ]; then
+ echo "syntax: $0 [--profile profilename] [--dtb dtbimage] [--dtbname dtbname] [--kernel kernelimage] [--rootfs rootfs] out"
+ exit 1
+fi
+
+tmpdir="$( mktemp -d 2> /dev/null )"
+if [ -z "$tmpdir" ]; then
+ # try OSX signature
+ tmpdir="$( mktemp -t 'roottmp' -d )"
+fi
+
+if [ -z "$tmpdir" ]; then
+ exit 1
+fi
+
+mkdir -p "${tmpdir}/${profile}"
+[ -z "${dtb}" ] || cp "${dtb}" "${tmpdir}/${profile}/${dtbname}"
+[ -z "${rootfs}" ] || cp "${rootfs}" "${tmpdir}/${profile}/uRamdisk"
+[ -z "${kernel}" ] || cp "${kernel}" "${tmpdir}/${profile}/uImage"
+
+mtime=""
+if [ -n "$SOURCE_DATE_EPOCH" ]; then
+ mtime="--mtime=@${SOURCE_DATE_EPOCH}"
+fi
+
+(cd "$tmpdir"; tar cvf ${profile}.tar ${profile} ${mtime})
+err="$?"
+if [ -e "$tmpdir/${profile}.tar" ]; then
+ cp "$tmpdir/${profile}.tar" "$outfile"
+else
+ err=2
+fi
+rm -rf "$tmpdir"
+
+exit $err