From dc7efaefb53d4671893add07934839eb8d44934d Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Wed, 20 Jul 2016 15:44:54 +0200 Subject: apm821xx: add support for the Western Digital MyBook Live Series Hardware Highlights: This patch adds support for Western Digital MyBook Live Series: CPU: AMCC PowerPC UNKNOWN (PVR=12c41c83) at 800 MHz (PLB=200, OPB=100, EBC=100 MHz) 32 kB I-Cache 32 kB D-Cache, 256 kB L2-Cache, 32 kB OnChip Memory Board: Apollo-3G - APM82181 Board, 1*SATA DRAM: 256 MB (2x NT5TU64M16GG-AC) FLASH: 512 kB (SST 39VF040) Ethernet: 1xRGMII - 1 Gbit - Broadcom PHY BCM54610 WARNING: The serial port needs a TTL/RS-232 v3.3 level converter! The MyBook Live Duo additionally features a 1x USB 2.0 host port and can support a second hard-drive. This target produces two images for a target. 1. ext4 image The extracted/raw image can be directly installed on the internal HDD via "dd if=img.ext4 of=/dev/sdX". This can either be done in place with the stock MyBook Live firmware via ssh. Or by removing the HDD and writing the image with a different PC. The the compressed images are useful for sysupgrade. 2. recovery.tar image for TFTP and Serial. extract the recovery.tar to a TFTP server directory. On the MyBook Live (Duo) serial port - Hit Enter during u-boot and insert: # setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1; run net_self Where 192.168.1.254 is your TFTP server. Signed-off-by: Christian Lamparter --- target/linux/apm821xx/image/Makefile | 83 ++++++++++++++++++- target/linux/apm821xx/image/mbl_boot.scr | 6 ++ target/linux/apm821xx/image/mbl_gen_hdd_img.sh | 27 +++++++ .../linux/apm821xx/image/mbl_gen_recovery_tar.sh | 92 ++++++++++++++++++++++ 4 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 target/linux/apm821xx/image/mbl_boot.scr create mode 100755 target/linux/apm821xx/image/mbl_gen_hdd_img.sh create mode 100644 target/linux/apm821xx/image/mbl_gen_recovery_tar.sh (limited to 'target/linux/apm821xx/image') 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 " + 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 -- cgit v1.2.3