Merge "Create /bin/connection_check."
diff --git a/configs/gfch100_defconfig b/configs/gfch100_defconfig
index b3941e1..bc5e937 100644
--- a/configs/gfch100_defconfig
+++ b/configs/gfch100_defconfig
@@ -71,7 +71,10 @@
 BR2_PACKAGE_GOOGLE_PLATFORM_SYSMGR=y
 BR2_PACKAGE_GOOGLE_TEST=y
 BR2_PACKAGE_GOOGLE_PLATFORM_ONLY=y
+BR2_PACKAGE_HFW_GLAUKUS_HAL=y
+BR2_PACKAGE_HFW_GLAUKUS_LINKMAN=y
 BR2_PACKAGE_CATAWAMPUS=y
+BR2_PACKAGE_MV_CPSS=y
 BR2_PACKAGE_FIRMWARE=y
 BR2_TARGET_ROOTFS_SQUASHFS=y
 BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
diff --git a/fs/skeleton/bin/has-drm-fs b/fs/skeleton/bin/has-drm-fs
new file mode 100755
index 0000000..e909fbc
--- /dev/null
+++ b/fs/skeleton/bin/has-drm-fs
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Checks if the drm keys are stored in a filesystem, currently
+# there is only a single device in this category.
+
+platform=$(cat /etc/platform)
+if [ "$platform" = GFHD254 ]; then
+  exit 0
+fi
+
+exit 1
diff --git a/fs/skeleton/bin/watchdog b/fs/skeleton/bin/watchdog
index 41dff75..f703ca9 100755
--- a/fs/skeleton/bin/watchdog
+++ b/fs/skeleton/bin/watchdog
@@ -24,6 +24,8 @@
   WDIOC_GETBOOTSTATUS=0x40045702
 fi
 
+platform=$(cat /etc/platform)
+
 if [ -c /dev/watchdog ]; then
   init=devwatchdog_init
   setup=devwatchdog_setup
@@ -48,6 +50,10 @@
   setup=bcm_setup
   pushback=bcm_pushback
   stop=
+elif [ "$platform" = "GFHD254" ]; then
+  init=bcm7252_init
+  setup=bcm_setup
+  pushback=bcm_pushback
 else
   echo "Unknown CPU type, cannot initialize watchdog timer"
   cat /proc/cpuinfo
@@ -125,6 +131,14 @@
   timer_wdctrl_reg=0x104066fc
 }
 
+bcm7252_init()
+{
+  timer_wdtimeout_reg=0xf040a7a8
+  timer_wdcmd_reg=0xf040a7ac
+  timer_wdchiprst_cnt_reg=0xf040a7b0
+  timer_wdctrl_reg=0xf040a7bc
+}
+
 bcm_setup()
 {
   # WD timeout value: 159.072862778 seconds (an NMI is triggered halfway through)
diff --git a/fs/skeleton/bin/zap.platform_gfibersc b/fs/skeleton/bin/zap.platform_gfibersc
index b4ec85f..5df2de6 100755
--- a/fs/skeleton/bin/zap.platform_gfibersc
+++ b/fs/skeleton/bin/zap.platform_gfibersc
@@ -71,6 +71,7 @@
 done
 
 # force kill chroot binaries, just in case.
+pkill -9 -f buffet_monitor
 pkill -9 -f buffet
 pkill -9 -f cryptohomed
 pkill -9 -f chapsd
diff --git a/fs/skeleton/etc/diag.d/Config.sh b/fs/skeleton/etc/diag.d/Config.sh
index f6459d1..88e48a3 100755
--- a/fs/skeleton/etc/diag.d/Config.sh
+++ b/fs/skeleton/etc/diag.d/Config.sh
@@ -61,6 +61,8 @@
     ;;
   GFRG210)
     ;;
+  GFRG250)
+    ;;
   GFSC100)
     has_wifi=0
     ;;
diff --git a/fs/skeleton/etc/diag.d/D07disk b/fs/skeleton/etc/diag.d/D07disk
index 6269f5e..04abcff 100755
--- a/fs/skeleton/etc/diag.d/D07disk
+++ b/fs/skeleton/etc/diag.d/D07disk
@@ -18,6 +18,11 @@
   # disk may not be formatted
   sata_blkdev=$(find_sata_blkdev)
 
+  if [ -z "$sata_blkdev" ]; then
+    error="Cannot find hard drive"
+    return 1
+  fi
+
   # run dd non-destuctive read test with several block sizes
   for bs in 32 64 128 256; do
     bytes=$(($bs * 1024))
diff --git a/fs/skeleton/etc/init.d/S08volcheck.platform_gfibertv b/fs/skeleton/etc/init.d/S08volcheck.platform_gfibertv
index bd2b407..e3dd873 100755
--- a/fs/skeleton/etc/init.d/S08volcheck.platform_gfibertv
+++ b/fs/skeleton/etc/init.d/S08volcheck.platform_gfibertv
@@ -6,6 +6,7 @@
 . /etc/utils.sh
 
 sata_blkdev=$(find_sata_blkdev)
+platform=$(cat /etc/platform)
 
 # 'data+ubi' partition
 DATA_MTD_NAME='"data+ubi"'
@@ -22,6 +23,8 @@
 
 # eMMC support
 DATA_MMC_NAME="data+ext4"
+DRM_FS_NAME="drmfs1"
+DRM_FS_RECOVER_NAME="drmfs2"
 
 USER_NAME=user
 CONFIG_NAME=config
@@ -183,6 +186,28 @@
 }
 
 
+mount_drmfs_ro()
+{
+  mount -t ext4 -o ro,defaults $1 $2 || return 1
+}
+
+# $1 : primary drmfs
+# $2 : secondary drmfs
+recover_drmfs()
+{
+    e2fsck $1 || mkfs.ext4 $1 || return 1
+    mkdir -p /tmp/drmfs_primary
+    mkdir -p /tmp/drmfs_secondary
+    mount -t ext4 -o ro,defaults $2 /tmp/drmfs_secondary || return 1
+    mount -t ext4 -o defaults $1 /tmp/drmfs_primary || return 1
+    # TODO(jnewlin):  Need to revisit with real keybox name.
+    cp /tmp/drmfs_secondary/drm.bin /tmp/drmfs_primary/drm.bin
+
+    umount /tmp/drmfs_primary
+    umount /tmp/drmfs_secondary
+    mount_drmfs_ro $1 /user/drmfs
+}
+
 mount_ext4fs()
 {
   mount -t ext4 -o defaults,noatime,discard,data=writeback $1 /user || return 1
@@ -245,6 +270,22 @@
     [ ! -d /tmp/vudu ] && mkdir -p /tmp/vudu
     [ ! -d /tmp/oprofile ] && mkdir -p /tmp/oprofile
 
+    if has-drm-fs; then
+      DRM_FS_MMC_NO=$(check_mmc ${DRM_FS_NAME})
+      DRM_FS_RECOVER_MMC_NO=$(check_mmc ${DRM_FS_RECOVER_NAME})
+      DRM_FS_BLK_NAME=/dev/mmcblk0p${DRM_FS_MMC_NO}
+      DRM_FS_RECOVER_BLK_NAME=/dev/mmcblk0p${DRM_FS_RECOVER_MMC_NO}
+      if [ -b ${DRM_FS_BLK_NAME} ]; then
+        [ ! -d /user/drmfs ] && mkdir -p /user/drmfs
+        if ! mount_drmfs_ro ${DRM_FS_BLK_NAME} /user/drmfs; then
+          echo "DRMFS is corrupt, attempting to recover keybox..."
+          if ! recover_drmfs ${DRM_FS_BLK_NAME} ${DRM_FS_RECOVER_BLK_NAME}; then
+            echo "DRMFS is corrupted and not recoverable."
+          fi
+        fi
+      fi
+    fi
+
     rm -rf /user/diag/diagdb.bin /user/diag/*.tmp /user/diag/log
 
     # /config must be writeable by non-root
diff --git a/fs/skeleton/etc/init.d/S40network.platform_gfibertv b/fs/skeleton/etc/init.d/S40network.platform_gfibertv
index f69e2c6..a7597fb 100755
--- a/fs/skeleton/etc/init.d/S40network.platform_gfibertv
+++ b/fs/skeleton/etc/init.d/S40network.platform_gfibertv
@@ -203,7 +203,7 @@
   # Storage and network boxes should have higher precedence (lower value)
   #  when choosing the root of the spanning tree.
   #  The default in Linux is 0x8000.
-  if is-network-box; then
+  if is-network-box || is-windcharger; then
     brctl setbridgeprio br0 0x7980
   elif is-storage-box; then
     brctl setbridgeprio br0 0x7990
@@ -283,6 +283,24 @@
   done
 }
 
+lan0_up_no_bridging() {
+  echo "Adding interface lan0..."
+  ip link set lan0 up &&
+  kernopt ip |
+  while IFS=: read ip serverip gatewayip netmask hostname ifc junk; do
+    # $ip should be already setup by simpleramfs.
+    # TODO(apenwarr): simpleramfs should set up $gatewayip too.
+    #  But right now its included networking commands are too limited.
+    if [ -n "$gatewayip" ]; then
+      echo "IP: adding default gateway '$gatewayip'"
+      ip route add default via "$gatewayip"
+    fi
+  done
+  echo "Bringing up interface lan0..."
+  ifup lan0
+  enable_rx_coalescing lan0
+}
+
 bridge_up() {
   echo "Bringing up the bridge..."
   ip link set br0 up  # kernel 3.16 behavior, sometimes br0 does not come up.
@@ -301,6 +319,29 @@
   ethtool -K $1 rx on tx on sg on gso on gro on
 }
 
+wan0_down() {
+  if [ -e /sys/class/net/wan0 ]; then
+    echo "Shutting down the WAN port..."
+    ifdown wan0
+    ifdown wan0.2
+    ip link del wan0.2
+  fi
+}
+
+bridge_down() {
+  for x in $(ls /sys/class/net); do
+    if [ -n /sys/class/net/$x/bridge ]; then
+      ifdown $x
+      echo "Shutting down $x interface"
+    fi
+    if [ -e /sys/class/net/$x/device ]; then
+      brctl delif br0 $x
+    fi
+  done
+  ifdown br0
+  [ -e /sys/class/net/br0 ] && brctl delbr br0
+}
+
 case "$1" in
   start)
     if is-tv-box || is-storage-box; then
@@ -320,6 +361,8 @@
         echo "Initializing AlleyCat3 10G switch..."
         echo 1 > $pci/enable
         mmap -q /usr/lib/mmap/ac3Config.mmap
+        echo "Initializing 88x2011 transceiver..."
+        mmap -q /usr/lib/mmap/2011Config.mmap
       fi
     fi
 
@@ -334,13 +377,16 @@
 
     # Create a default resolv.conf and /etc/hosts in case DHCP doesn't.
     # (this is always true if using nfsroot).
-    # 8.8.8.8 and 8.8.4.4 are well-known Google public DNS servers
+    # 8.8.8.8 and 8.8.4.4 are well-known IPv4 Google public DNS servers
     # that can be used from anywhere, so it makes a good place to start.
+    # 2001:4860:4860::8888 is one of the two IPv6 Google public DNS servers
+    # (the other being 2001:4860:4860::8844).
     # DHCP will just overwrite this file when it's ready to go.
     if [ ! -r /etc/resolv.conf ]; then
-      #TODO(apenwarr): add IPv6 DNS once our uClibc can handle it.
+      # Note: uClibc only reads the first three nameserver entries.
       (echo 'nameserver 8.8.8.8';
-       echo 'nameserver 8.8.4.4') >/etc/resolv.conf
+       echo 'nameserver 8.8.4.4';
+       echo 'nameserver 2001:4860:4860::8888') >/etc/resolv.conf
     fi
     if [ ! -r /etc/hosts ]; then
       echo "127.0.0.1 localhost $(hostname)" >/etc/hosts
@@ -352,18 +398,24 @@
     # configure loopback
     ifup lo
 
-    # Set the wifi mac address from values in hnvram.
+    # Set the mac address from values in hnvram.
+    set_mac_from_hnvram wan0 MAC_ADDR1
+    set_mac_from_hnvram lan0 MAC_ADDR2
     set_mac_from_hnvram wlan0 MAC_ADDR_WIFI
     set_mac_from_hnvram wlan1 MAC_ADDR_WIFI2
 
-    create_bridge
-    if is-tv-box || is-storage-box; then
-      configure_moca_vlan
+    if is-spacecast; then
+      lan0_up_no_bridging
+    else
+      create_bridge
+      if is-tv-box || is-storage-box; then
+        configure_moca_vlan
+      fi
+      add_interfaces_to_bridge
+      add_multicast_route
+      bridge_up
+      redistribute_irqs
     fi
-    add_interfaces_to_bridge
-    add_multicast_route
-    bridge_up
-    redistribute_irqs
 
     if [ -e /dev/bmoca0 ]; then
       echo "starting moca..."
@@ -391,40 +443,31 @@
       # Enable receive interrupt coalescing, this is a significant
       # performance gain for multicast receive.
       enable_rx_coalescing wan0
-
     fi
 
-    # Enable hardware offloads, do this at the end to avoid
-    # invalid access caused by powered down core
-    enable_hw_offloads eth0
-    enable_hw_offloads $MOCAIFC
-
+    if is-tv-box || is-storage-box; then
+      # Enable hardware offloads, do this at the end to avoid
+      # invalid access caused by powered down core
+      enable_hw_offloads eth0
+      enable_hw_offloads $MOCAIFC
+    fi
     ;;
   stop)
     if [ ! -e /tmp/NFS ]; then
-      if [ -e /sys/class/net/wan0 ]; then
-        echo "Shutting down the WAN port..."
-        ifdown wan0
-        ifdown wan0.2
-        ip link del wan0.2
+      if is-spacecast; then
+        ifdown lan0
+        echo "Shutting down lan0 interface"
+      else
+        wan0_down
+        bridge_down
       fi
-      for x in $(ls /sys/class/net); do
-        if [ -n /sys/class/net/$x/bridge ]; then
-          ifdown $x
-          echo "Shutting down $x interface"
-        fi
-        if [ -e /sys/class/net/$x/device ]; then
-          brctl delif br0 $x
-        fi
-      done
-      ifdown br0
+
       # Kill mocad and mocactl
       if [ -e /dev/bmoca0 ]; then
         echo -n "mocacfg kill"
         pkillwait mocad
       fi
     fi
-    [ -e /sys/class/net/br0 ] && brctl delbr br0
     ;;
   restart|reload)
     "$0" stop
diff --git a/fs/skeleton/sbin/hotplug b/fs/skeleton/sbin/hotplug
index dec9e31..b4eeda1 100755
--- a/fs/skeleton/sbin/hotplug
+++ b/fs/skeleton/sbin/hotplug
@@ -49,3 +49,16 @@
     echo -1 >/sys/$DEVPATH/loading
     ;;
 esac
+
+# DirectFB apps listen for an AF_UNIX message for hotplug events, which
+# dfb_input_hotplug sends using the ACTION and DEVPATH in the environment.
+if [ "$SUBSYSTEM" = "input" ] && [ "$ACTION" = "add" -o "$ACTION" = "remove" ]; then
+  for dir in /usr/local/bin/directfb/* ; do
+    if [ -d "$dir" ]; then
+      export PATH="$PATH":"$dir"
+    fi
+  done
+  if runnable dfb_input_hotplug; then
+    dfb_input_hotplug
+  fi
+fi
diff --git a/fs/skeleton/usr/lib/mmap/2011Config.mmap b/fs/skeleton/usr/lib/mmap/2011Config.mmap
new file mode 100644
index 0000000..187242f
--- /dev/null
+++ b/fs/skeleton/usr/lib/mmap/2011Config.mmap
@@ -0,0 +1,36 @@
+#
+# configure 88x2011
+#
+
+open 0 /sys/bus/pci/devices/0000:01:00.0/resource0 0 0x00100000
+open 2 /sys/bus/pci/devices/0000:01:00.0/resource2 0 0x04000000
+open 4 /sys/bus/pci/devices/0000:01:00.0/resource4 0 0x00800000
+
+write 2 0x00000000 4 0x00000000
+
+# device 3 - software reset sequence
+mwrite 2 0x01040008 0x01040000 4 3 0x0000 0x8000
+msleep 50
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2100
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2000
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x0000
+msleep 20
+mread 2 0x01040008 0x01040000 4 3 0x8127 1
+
+# device 2 - software reset sequence
+mwrite 2 0x01040008 0x01040000 4 2 0x0000 0x8000
+msleep 50
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2100
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2000
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x0000
+msleep 20
+mread 2 0x01040008 0x01040000 4 3 0x8127 1
+
+# device 1 - software reset sequence
+mwrite 2 0x01040008 0x01040000 4 1 0x0000 0x8000
+msleep 50
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2100
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x2000
+mwrite 2 0x01040008 0x01040000 4 3 0xfe31 0x0000
+msleep 20
+mread 2 0x01040008 0x01040000 4 3 0x8127 1
diff --git a/fs/skeleton/usr/lib/mmap/3220Status.mmap b/fs/skeleton/usr/lib/mmap/3220Status.mmap
new file mode 100644
index 0000000..a37465c
--- /dev/null
+++ b/fs/skeleton/usr/lib/mmap/3220Status.mmap
@@ -0,0 +1,30 @@
+#
+# show registers in 88x3220
+#
+
+open 0 /sys/bus/pci/devices/0000:01:00.0/resource0 0 0x00100000
+open 2 /sys/bus/pci/devices/0000:01:00.0/resource2 0 0x04000000
+open 4 /sys/bus/pci/devices/0000:01:00.0/resource4 0 0x00800000
+
+write 2 0x00000000 4 0x00000000
+
+echo # vendorid
+mread 2 0x01040008 0x01040000 7 1 0x0002 1
+
+echo # fw version
+mread 2 0x01040008 0x01040000 7 1 0xc011 2
+
+echo # boot status
+mread 2 0x01040008 0x01040000 7 1 0xc050 1
+
+echo # mode config, port control
+mread 2 0x01040008 0x01040000 7 31 0xf000 2
+
+echo # mode config, port control
+mread 2 0x01040008 0x01040000 7 3 0x1000 2
+
+echo # 10GBase-R PCS Status 1, 2
+mread 2 0x01040008 0x01040000 7 3 0x1020 2
+
+echo # 10GBase-R Interrupt status, real time status
+mread 2 0x01040008 0x01040000 7 3 0x9001 2
diff --git a/fs/skeleton/usr/lib/mmap/ac3Config.mmap b/fs/skeleton/usr/lib/mmap/ac3Config.mmap
index 2374477..1e212ea 100644
--- a/fs/skeleton/usr/lib/mmap/ac3Config.mmap
+++ b/fs/skeleton/usr/lib/mmap/ac3Config.mmap
@@ -22,6 +22,7 @@
 # !!! 0xe0000000
 # !!! pci write.l 0.0.0 0x10 0xe0000000
 # !!! pci write.l 0.0.0 0x14 0x0
+# set resource2 and resource4 to match where PCI driver puts them (.../resource)
 write 0 0x00041820 4 0x03ff0031
 write 0 0x00041824 4 0xe0000000
 write 0 0x00041830 4 0x007f0083
@@ -45,36 +46,36 @@
 #     Marvell>> md e5000000
 #     e5000000: 00008be5 00000003 0000c048 0000b0e8    // Port control
 
-# dump some registers to verify we are talking to the bars
+# notes on writing to registers.  Lines like so:
+#     write 2 0x00000000 4 0x30201200
+# set the upper byte of future writes.  There are 4 address spaces in resource2.
+#     0x00000000 - 0x01ffffff bank0
+#     0x01000000 - 0x01ffffff bank1
+#     0x02000000 - 0x01ffffff bank2
+#     0x03000000 - 0x01ffffff bank3
+# Register 0 sets the msb of the address for the 4 banks.  0x30201200 makes
+# bank0 prefix 0, bank1 prefix 0x12, back2 prefix 0x20, bank3 prefix 0x30.
+# this means a read/write to:
+#     0x00...... gets mapped to 0x00......
+#     0x01...... gets mapped to 0x12......
+#     0x02...... gets mapped to 0x20......
+#     0x03...... gets mapped to 0x30......
+# This allows the small resource2 address space to me mapped to the large PCI space
+
+# set address completion to legacy mode
 write 2 0x00000140 4 0x00018102
-write 2 0x00000000 4 0x30201200
-dump 2 0x01000000 4 64
 
-read 0 0x00040000 4
-read 2 0x00000050 4
-read 4 0x000f8240 4
+read 0 0x00040000 4 
+read 2 0x00000050 4 
+read 4 0x000f8240 4 
 
-# Read AC3 ports status - port 0,4, 24, 25
-write 2 0x00000000 4 0x00001200
-dump 2 0x01000000 4 5
-dump 2 0x01004000 4 5
 
-write 2 0x00000000 4 0x00001200
-dump 2 0x010d8000 4 4
-
-write 2 0x00000000 4 0x00001200
-dump 2 0x010d9000 4 4
-
-# --------ONLY 2 writes to Ingress Policy and Egress Policy  -----------
-write 2 0x00000000 4 0x00001500
-write 2 0x01000000 4 0x12150000
-write 2 0x00000000 4 0x00001d00
-write 2 0x01000000 4 0x1D100000
+# *****************   Start of INIT:  ***********
 
 # Metal fix in SW space
 write 2 0x00000000 4 0x00000600
 write 2 0x010002b0 4 0x8002ffff
-# General Ctrl in SW space
+# General Ctrl in SW space 
 write 2 0x00000000 4 0x00000000
 write 2 0x010000d4 4 0x00110f0f
 # Global Ctrl in SW space
@@ -88,12 +89,10 @@
 # Enable Device for Tx and Rx in DFX
 write 4 0x000f800c 4 0x00008003
 
-write 2 0x00000140 4 0x00018102
-
 # ----------------------------------------------------------------------
 # --  Init Ports
 # ----------------------------------------------------------------------
-# -  Port 0 in 1000Base-X        ---------------------------------------
+# -  Port 0 in SGMII   ---------------------------------------
 write 2 0x00000000 4 0x00000200
 write 2 0x01800080 4 0x0005FFFE
 write 2 0x01800080 4 0x0005FFFC
@@ -221,10 +220,10 @@
 write 2 0x00000000 4 0x00001200
 write 2 0x01000090 4 0x0000009A
 write 2 0x01000000 4 0x00008BE6
-write 2 0x0100000c 4 0x00009268
+write 2 0x0100000c 4 0x0000B2EC
 write 2 0x01000004 4 0x00000001
-write 2 0x01000008 4 0x0000C048
-write 2 0x01000008 4 0x0000C008
+write 2 0x01000008 4 0x0000C049
+write 2 0x01000008 4 0x0000C009
 write 2 0x00000000 4 0x00000200
 write 2 0x01800080 4 0x0005FF01
 write 2 0x01800080 4 0x0005FF03
@@ -235,7 +234,7 @@
 write 2 0x01800080 4 0x0005FF7F
 write 2 0x01800080 4 0x0005FFFF
 write 2 0x00000000 4 0x00001200
-write 2 0x01000000 4 0x00008BE7
+write 2 0x01000000 4 0x00008BE5
 
 # -  Port 4 in 1000Base-X        ---------------------------------------
 write 2 0x00000000 4 0x00000200
@@ -715,14 +714,3 @@
 write 2 0x010d9018 4 0x0000008C
 write 2 0x010d9018 4 0x0000008E
 
-# Read AC3 ports status - port 0,4, 24, 25
-write 2 0x00000000 4 0x00001200
-dump 2 0x01000000 4 5
-dump 2 0x01004000 4 5
-
-write 2 0x00000000 4 0x00001200
-dump 2 0x010d8000 4 4
-
-write 2 0x00000000 4 0x00001200
-dump 2 0x010d9000 4 4
-
diff --git a/fs/skeleton/usr/lib/mmap/ac3Status.mmap b/fs/skeleton/usr/lib/mmap/ac3Status.mmap
index 184e9a4..a4e883e 100644
--- a/fs/skeleton/usr/lib/mmap/ac3Status.mmap
+++ b/fs/skeleton/usr/lib/mmap/ac3Status.mmap
@@ -4,14 +4,14 @@
 # OLD BAR: 0xe0000000 0xe4000000 0xe0800000
 # NEW BAR: 0xe4800000 0xe0000000 0xe4000000
 
-# Read AC3 ports status - port 0,4, 24, 25
+# Read AC3 ports status - port 0, 4, 24, 25
 write 2 0x00000000 4 0x00001200
+echo status port 0 PoE
 dump 2 0x01000000 4 5
+echo status port 4 SOC
 dump 2 0x01004000 4 5
-
-write 2 0x00000000 4 0x00001200
+echo status port 24 88x2011
 dump 2 0x010d8000 4 4
-
-write 2 0x00000000 4 0x00001200
+echo status port 25 sfp+
 dump 2 0x010d9000 4 4
 
diff --git a/fs/skeleton/usr/lib/mmap/counters.mmap b/fs/skeleton/usr/lib/mmap/counters.mmap
index a646f27..55092d9 100644
--- a/fs/skeleton/usr/lib/mmap/counters.mmap
+++ b/fs/skeleton/usr/lib/mmap/counters.mmap
@@ -1,64 +1,19 @@
 #
-# show config, status and mib counters for ports 0, 4, 24 and 25
+# show mib counters for ports 0, 4, 24 and 25
 #
 
 open 0 /sys/bus/pci/devices/0000:01:00.0/resource0 0 0x00100000
 open 2 /sys/bus/pci/devices/0000:01:00.0/resource2 0 0x04000000
 open 4 /sys/bus/pci/devices/0000:01:00.0/resource4 0 0x00800000
 
-# bank 01 == 04, bank 02 == 09, bank 03 == 12
-write 2 0x00000000 4 0x12090400
-
-echo port 0 config
-dump 2 0x03000000 4 5
-dump 2 0x03000044 4 6
-dump 2 0x03000090 4 1
-
-echo port 4 config
-dump 2 0x03004000 4 5
-dump 2 0x03004044 4 6
-dump 2 0x03004090 4 1
-
-echo try to put port 4 in 1g mode?
-write 2 0x03004000 4 0x8be5
-write 2 0x03004008 4 0xc009
-write 2 0x0300400c 4 0xb3ec
-dump 2 0x03004000 4 5
-
-echo port 24 config
-dump 2 0x03018000 4 5
-dump 2 0x03018044 4 6
-dump 2 0x03018090 4 1
-
-echo port 25 config
-dump 2 0x03019000 4 5
-dump 2 0x03019044 4 6
-dump 2 0x03019090 4 1
-
-echo port 0 status
-dump 2 0x03000010 4 1
-dump 2 0x03000040 4 1
-
-echo port 4 status
-dump 2 0x03004010 4 1
-dump 2 0x03004040 4 1
-
-echo port 24 status
-dump 2 0x030d8000 4 4
-
-echo port 25 status
-dump 2 0x030d9000 4 4
-
-write 2 0x00000000 4 0x12090700
-
-echo mib counters for port 0
-dump 2 0x01010000 4 32
-
-echo mib counters for port 4
-dump 2 0x01010200 4 32
-
-echo mib counters for port 24
-dump 2 0x02300000 4 32
-
-echo mib counters for port 25
-dump 2 0x02320000 4 32
+# Read counters - port 0, 4, 24, 25
+# need to read all 32 to prime next results
+write 2 0x00000000 4 0x00001100
+echo counters port 0 PoE
+dump 2 0x01000000 4 32
+echo counters port 4 SOC
+dump 2 0x01001000 4 32
+echo counters port 24 88x2011
+dump 2 0x01006000 4 32
+echo counters port 25 sfp+
+dump 2 0x01006400 4 32
diff --git a/package/Config.in b/package/Config.in
index 551acad..03bf03d 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -89,6 +89,7 @@
 source "package/patch/Config.in"
 endif
 source "package/pkg-config/Config.in"
+source "package/prelink-cross/Config.in"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 source "package/sed/Config.in"
 endif
@@ -681,6 +682,7 @@
 
 menu "Marvell custom build"
 source "package/mv_app/Config.in"
+source "package/mv_cpss/Config.in"
 endmenu
 
 menu "Quantenna custom build"
diff --git a/package/bcm_common/bcm_common.mk b/package/bcm_common/bcm_common.mk
index 3efc559..7c8f79e 100644
--- a/package/bcm_common/bcm_common.mk
+++ b/package/bcm_common/bcm_common.mk
@@ -11,9 +11,11 @@
 ifeq ($(BR2_PACKAGE_BCM_COMMON_PLATFORM),"97439")
 PLAY_READY_VER=2.5
 STAND_ALONE=n
+GOOG_SAGE_SUPPORT=y
 else
 PLAY_READY_VER=2.0
 STAND_ALONE=y
+GOOG_SAGE_SUPPORT=n
 endif
 
 BCM_MAKE_ENV=\
@@ -71,7 +73,9 @@
 B_REFSW_OPENSSL_IS_EXTERNAL=y \
 MINICLIENT_PATH=${GOOGLE_MINICLIENT_DIR} \
 GLFW_NEXUS_PATH=${GOOGLE_GLFW_NEXUS_DIR} \
-NEXUS_COMMON_CRYPTO_SUPPORT=y
+NEXUS_COMMON_CRYPTO_SUPPORT=y \
+SAGE_SUPPORT=${GOOG_SAGE_SUPPORT} \
+SAGE_SECURE_MODE=6
 
 BCM_MAKE_ENV += B_REFSW_DEBUG=y
 # NOTE(apenwarr): this could also be set to 'release'.
diff --git a/package/bcm_nexus/bcm_nexus.mk b/package/bcm_nexus/bcm_nexus.mk
index 55ca74f..93a9e5a 100644
--- a/package/bcm_nexus/bcm_nexus.mk
+++ b/package/bcm_nexus/bcm_nexus.mk
@@ -61,6 +61,11 @@
 	$(INSTALL) -D $(@D)/bin/libnexus.so $1/usr/lib/libnexus.so
 	$(INSTALL) -D $(@D)/bin/libnexus_client.so $1/usr/lib/libnexus_client.so
 	$(INSTALL) -D $(@D)/bin/libnxclient.so $1/usr/lib/libnxclient.so
+	if [ -f $(@D)/bin/sage_os_app.bin ]; then \
+	  mkdir -p $1/usr/lib/sage_firmware; \
+	  $(INSTALL) -D $(@D)/bin/sage_os_app.bin $1/usr/lib/sage_firmware; \
+	  $(INSTALL) -D $(@D)/bin/sage_bl.bin $1/usr/lib/sage_firmware; \
+	fi
 endef
 
 define BCM_NEXUS_INSTALL_STAGING_CMDS
diff --git a/package/google/google_buffet/S86buffet b/package/google/google_buffet/S86buffet
index f5793eb..0d80536 100755
--- a/package/google/google_buffet/S86buffet
+++ b/package/google/google_buffet/S86buffet
@@ -52,8 +52,6 @@
       # Sanity check: DBus socket has to be present.
       wait-until-created /chroot/chromeos/var/run/dbus/system_bus_socket
       babysit_start 10 "$APP" "chroot /chroot/chromeos $BINARY" "$FLAGS"
-      [ $? -ne 0 ] && echo "Failed to start buffet..." && exit 1
-      echo "Buffet started successfully"
       if [ ! -n "$(pgrep -f buffet_monitor)" ]; then
         buffet_monitor 7200 &
       fi
diff --git a/package/google/google_miniclient/S96mpserver b/package/google/google_miniclient/S96mpserver
index b5911a0..d8be502 100755
--- a/package/google/google_miniclient/S96mpserver
+++ b/package/google/google_miniclient/S96mpserver
@@ -10,6 +10,7 @@
       wait-until-created /tmp/startupvideo.done
       # mcnmp_server playback code needs widevine and pullreader .so
       export LD_LIBRARY_PATH=/app/client
+      export SAGEBIN_PATH=/usr/lib/sage_firmware
       babysit 10 mcnmp_server 2>&1 | logos mcnmp_server 0 20000000 &
       wait-until-created /tmp/nexus_multiprocess
       nice babysit 60 irmon 2>&1 | logos irmon &
diff --git a/package/google/google_oregano/S97basil b/package/google/google_oregano/S97basil
index a1f49c9..8daa97c 100755
--- a/package/google/google_oregano/S97basil
+++ b/package/google/google_oregano/S97basil
@@ -18,7 +18,7 @@
     ;;
   stop)
     # End the Basil dart server (which will also end its babysitter).
-    pkillwait -f '(dart.*)([b]asil\.dart)'
+    pkillwait -f '(dart.*)([b]asil.*\.dart)'
     rc_pipe_deinit
     ;;
   restart)
diff --git a/package/google/google_platform/S50waveguide b/package/google/google_platform/S50waveguide
index a6a21dd..a403fdd 100755
--- a/package/google/google_platform/S50waveguide
+++ b/package/google/google_platform/S50waveguide
@@ -27,6 +27,13 @@
       YES=1
       HP=--no-high-power
     fi
+
+    if is-tv-box; then
+      TB=--tv-box
+    else
+      unset TB
+    fi
+
     if experiment WifiNoBgScans; then
       SI=--scan-interval=0
     elif experiment WifiMoreBgScans; then
@@ -36,7 +43,7 @@
     fi
     if [ -n "$YES" ]; then
       supernice babysit 60 alivemonitor /tmp/waveguide/alive 10 10 600 \
-          waveguide "$HP" "$SI" 2>&1 | logos waveguide &
+          waveguide "$HP" "$SI" "$TB" 2>&1 | logos waveguide &
     fi
     ;;
   stop)
diff --git a/package/hfw/hfw_glaukus_hal/hfw_glaukus_hal.mk b/package/hfw/hfw_glaukus_hal/hfw_glaukus_hal.mk
index 887fac7..4fc5f8b 100644
--- a/package/hfw/hfw_glaukus_hal/hfw_glaukus_hal.mk
+++ b/package/hfw/hfw_glaukus_hal/hfw_glaukus_hal.mk
@@ -29,27 +29,15 @@
 HFW_GLAUKUS_HAL_MAKE=$(HFW_GLAUKUS_HAL_ENV) $(MAKE) $(HFW_GLAUKUS_HAL_MFLAGS)
 
 define HOST_HFW_GLAUKUS_HAL_BUILD_CMDS
-	$(HOST_HFW_GLAUKUS_HAL_MAKE) -C $(@D)
+	$(HOST_HFW_GLAUKUS_HAL_MAKE) -C $(@D) all
 endef
 
 define HFW_GLAUKUS_HAL_BUILD_CMDS
-	$(HFW_GLAUKUS_HAL_MAKE) -C $(@D)
-endef
-
-define HOST_HFW_GLAUKUS_HAL_TEST_CMDS
-	$(HOST_HFW_GLAUKUS_HAL_MAKE) -C $(@D) test
-endef
-
-define HOST_HFW_GLAUKUS_HAL_INSTALL_CMDS
-	$(HOST_HFW_GLAUKUS_HAL_MAKE) -C $(@D) install
+	$(HFW_GLAUKUS_HAL_MAKE) -C $(@D) all
 endef
 
 define HFW_GLAUKUS_HAL_INSTALL_STAGING_CMDS
-	$(HFW_GLAUKUS_HAL_MAKE) -C $(@D) install
-endef
-
-define HFW_GLAUKUS_HAL_INSTALL_TARGET_CMDS
-	true $(HFW_GLAUKUS_HAL_MAKE) -C $(@D) install
+	$(INSTALL) -m 0644 -D $(@D)/build/libhal.a $(STAGING_DIR)/usr/lib/libhal.a
 endef
 
 $(eval $(call GENTARGETS))
diff --git a/package/hfw/hfw_glaukus_linkman/hfw_glaukus_linkman.mk b/package/hfw/hfw_glaukus_linkman/hfw_glaukus_linkman.mk
index 84983aa..9970c39 100644
--- a/package/hfw/hfw_glaukus_linkman/hfw_glaukus_linkman.mk
+++ b/package/hfw/hfw_glaukus_linkman/hfw_glaukus_linkman.mk
@@ -16,10 +16,7 @@
 	XLDFLAGS=-L$(HOST_DIR)/usr/lib \
 
 HFW_GLAUKUS_LINKMAN_MFLAGS= \
-	PCC="$(HOST_DIR)/usr/bin/protoc" \
-	CC="$(TARGET_CC)" \
-	CXX="$(TARGET_CXX)" \
-	LD="$(TARGET_CC)" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
 	TARGET_CFLAGS=-I$(STAGING_DIR)/usr/include \
 	XTARGET_LDFLAGS=-L$(STAGING_DIR)/usr/lib \
 	INSTALL_DIR=$(STAGING_DIR)/usr/include \
@@ -29,27 +26,15 @@
 HFW_GLAUKUS_LINKMAN_MAKE=$(HFW_GLAUKUS_LINKMAN_ENV) $(MAKE) $(HFW_GLAUKUS_LINKMAN_MFLAGS)
 
 define HOST_HFW_GLAUKUS_LINKMAN_BUILD_CMDS
-	$(HOST_HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D)
+	$(HOST_HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) all
 endef
 
 define HFW_GLAUKUS_LINKMAN_BUILD_CMDS
-	$(HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D)
-endef
-
-define HOST_HFW_GLAUKUS_LINKMAN_TEST_CMDS
-	$(HOST_HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) test
-endef
-
-define HOST_HFW_GLAUKUS_LINKMAN_INSTALL_CMDS
-	$(HOST_HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) install
-endef
-
-define HFW_GLAUKUS_LINKMAN_INSTALL_STAGING_CMDS
-	$(HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) install
+	$(HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) all
 endef
 
 define HFW_GLAUKUS_LINKMAN_INSTALL_TARGET_CMDS
-	true $(HFW_GLAUKUS_LINKMAN_MAKE) -C $(@D) install
+	$(INSTALL) -m 755 -D $(@D)/build/glaukusd $(TARGET_DIR)/usr/bin/glaukusd
 endef
 
 $(eval $(call GENTARGETS))
diff --git a/package/hfw/hfw_surprise_diagnostics/hfw_surprise_diagnostics.mk b/package/hfw/hfw_surprise_diagnostics/hfw_surprise_diagnostics.mk
index 2e9ac2d..6d43605 100644
--- a/package/hfw/hfw_surprise_diagnostics/hfw_surprise_diagnostics.mk
+++ b/package/hfw/hfw_surprise_diagnostics/hfw_surprise_diagnostics.mk
@@ -16,10 +16,7 @@
 	XLDFLAGS=-L$(HOST_DIR)/usr/lib \
 
 HFW_SURPRISE_DIAGNOSTICS_MFLAGS= \
-	PCC="$(HOST_DIR)/usr/bin/protoc" \
-	CC="$(TARGET_CC)" \
-	CXX="$(TARGET_CXX)" \
-	LD="$(TARGET_CC)" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
 	TARGET_CFLAGS=-I$(STAGING_DIR)/usr/include \
 	XTARGET_LDFLAGS=-L$(STAGING_DIR)/usr/lib \
 	INSTALL_DIR=$(STAGING_DIR)/usr/include \
@@ -29,23 +26,23 @@
 HFW_SURPRISE_DIAGNOSTICS_MAKE=$(HFW_SURPRISE_DIAGNOSTICS_ENV) $(MAKE) $(HFW_SURPRISE_DIAGNOSTICS_MFLAGS)
 
 define HOST_HFW_SURPRISE_DIAGNOSTICS_BUILD_CMDS
-	$(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D)
+	$(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) all
 endef
 
 define HFW_SURPRISE_DIAGNOSTICS_BUILD_CMDS
-	$(HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D)
+	$(HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) all
 endef
 
 define HOST_HFW_SURPRISE_DIAGNOSTICS_TEST_CMDS
-	$(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) test
+	true $(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) test
 endef
 
 define HOST_HFW_SURPRISE_DIAGNOSTICS_INSTALL_CMDS
-	$(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) install
+	true $(HOST_HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) install
 endef
 
 define HFW_SURPRISE_DIAGNOSTICS_INSTALL_STAGING_CMDS
-	$(HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) install
+	true $(HFW_SURPRISE_DIAGNOSTICS_MAKE) -C $(@D) install
 endef
 
 define HFW_SURPRISE_DIAGNOSTICS_INSTALL_TARGET_CMDS
diff --git a/package/iw/iw-001-bitrates.patch b/package/iw/iw-001-bitrates.patch
new file mode 100644
index 0000000..bed897a
--- /dev/null
+++ b/package/iw/iw-001-bitrates.patch
@@ -0,0 +1,48 @@
+From 7f148561a4d36f9d3f2574285a488717d83e7e0c Mon Sep 17 00:00:00 2001
+From: Denton Gentry <dgentry@google.com>
+Date: Wed, 18 Nov 2015 05:58:46 -0800
+Subject: [PATCH] output something rational for tx bitrate.
+
+1. Ensure the buffer will always be initialized.
+   parse_bitrates is passed a pointer to a buffer on the stack. If the
+   rate is zero and no other attributes are set, nothing is printed to
+   the buffer and iw ends up outputting whatever garbage was on the
+   stack.
+
+2. Print *something*
+   If there ss a NL80211_STA_INFO_[TR]X_BITRATE present, then print
+   something for thetx/rx bitrate even if the rate is zero. It is useful
+   to know the difference between no-rate-present and rate-is-zero.
+
+Fixes b/25737028
+---
+ station.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/station.c b/station.c
+index 2b2eef8..51532fa 100644
+--- a/station.c
++++ b/station.c
+@@ -56,6 +56,7 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
+ 		[NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+ 	};
+ 
++	buf[0] = '\0';
+ 	if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+ 			     bitrate_attr, rate_policy)) {
+ 		snprintf(buf, buflen, "failed to parse nested rate attributes!");
+@@ -66,9 +67,8 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
+ 		rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
+ 	else if (rinfo[NL80211_RATE_INFO_BITRATE])
+ 		rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+-	if (rate > 0)
+-		pos += snprintf(pos, buflen - (pos - buf),
+-				"%d.%d MBit/s", rate / 10, rate % 10);
++	pos += snprintf(pos, buflen - (pos - buf),
++			"%d.%d MBit/s", rate / 10, rate % 10);
+ 
+ 	if (rinfo[NL80211_RATE_INFO_MCS])
+ 		pos += snprintf(pos, buflen - (pos - buf),
+-- 
+2.6.0.rc2.230.g3dd15c0
+
diff --git a/package/mv_cpss/Config.in b/package/mv_cpss/Config.in
new file mode 100644
index 0000000..608e81f
--- /dev/null
+++ b/package/mv_cpss/Config.in
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_MV_CPSS
+	bool "mv_cpss"
+	depends on !BR2_PACKAGE_GOOGLE_OPENBOX
+	help
+	  Builds cpss switch config tool for Marvell boards
diff --git a/package/mv_cpss/mv_app.mk b/package/mv_cpss/mv_app.mk
new file mode 100644
index 0000000..3630882
--- /dev/null
+++ b/package/mv_cpss/mv_app.mk
@@ -0,0 +1,21 @@
+MV_CPSS_SITE=repo://vendor/marvell/cpss
+MV_CPSS_DEPENDENCIES=linux
+
+MV_CPSS_ENV = \
+	TARGET_CROSS=$(TARGET_CROSS) \
+	STAGING_DIR=$(STAGING_DIR) \
+	BR2_JLEVEL=$(BR2_JLEVEL) \
+
+define MV_CPSS_CONFIGURE_CMDS
+	$(MV_CPSS_ENV) $(MAKE) -C $(@D) configure
+endef
+
+define MV_CPSS_BUILD_CMDS
+	$(MV_CPSS_ENV) $(MAKE) -C $(@D) build
+endef
+
+define MV_CPSS_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(@D)/cpss $(TARGET_DIR)/usr/bin/cpss
+endef
+
+$(eval $(call GENTARGETS))
diff --git a/package/poco/poco.mk b/package/poco/poco.mk
index 2397424..f8f5229 100644
--- a/package/poco/poco.mk
+++ b/package/poco/poco.mk
@@ -45,17 +45,17 @@
 endef
 
 define POCO_BUILD_CMDS
-	$(MAKE) POCO_TARGET_OSARCH=$(ARCH) CROSSENV=$(TARGET_CROSS) \
+	$(MAKE1) POCO_TARGET_OSARCH=$(ARCH) CROSSENV=$(TARGET_CROSS) \
 		MYSQL_LIBDIR=$(STAGING_DIR)/usr/lib/mysql \
 		MYSQL_INCDIR=$(STAGING_DIR)/usr/include/mysql -C $(@D)
 endef
 
 define POCO_INSTALL_STAGING_CMDS
-	$(MAKE) DESTDIR=$(STAGING_DIR) POCO_TARGET_OSARCH=$(ARCH) install -C $(@D)
+	$(MAKE1) DESTDIR=$(STAGING_DIR) POCO_TARGET_OSARCH=$(ARCH) install -C $(@D)
 endef
 
 define POCO_INSTALL_TARGET_CMDS
-	$(MAKE) DESTDIR=$(TARGET_DIR) POCO_TARGET_OSARCH=$(ARCH) install -C $(@D)
+	$(MAKE1) DESTDIR=$(TARGET_DIR) POCO_TARGET_OSARCH=$(ARCH) install -C $(@D)
 endef
 
 $(eval $(call GENTARGETS))
diff --git a/package/prelink-cross/Config.in b/package/prelink-cross/Config.in
new file mode 100644
index 0000000..69100a5
--- /dev/null
+++ b/package/prelink-cross/Config.in
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_PRELINK_CROSS
+	bool "prelink-cross"
+	help
+	  Prelinking is the process of pre-computing the load addresses and link
+	  tables generated by the dynamic linker as compared to doing this at
+	  runtime. Doing this ahead of time results in performance improvements
+	  when the application is launched.
+
+	  By providing an emulated runtime dynamic linker, the cross-prelink
+	  project extends the prelink software's ability to prelink a sysroot
+	  environment. Additionally, the cross-prelink software enables the
+	  ability to work in sysroot style environments.
diff --git a/package/prelink-cross/prelink-cross.mk b/package/prelink-cross/prelink-cross.mk
new file mode 100644
index 0000000..a987647
--- /dev/null
+++ b/package/prelink-cross/prelink-cross.mk
@@ -0,0 +1,30 @@
+# prelink-cross
+#
+# A prelinker which can run on the host and emulate ld.so of
+# the target, to support prelinking of cross-compiled binaries.
+#
+# https://www.yoctoproject.org/tools-resources/projects/cross-prelink
+
+PRELINK_CROSS_VERSION=20151030_cross
+PRELINK_CROSS_SITE=http://git.yoctoproject.org/cgit/cgit.cgi/prelink-cross/snapshot/
+PRELINK_CROSS_SOURCE=prelink-cross-${PRELINK_CROSS_VERSION}.tar.bz2
+
+HOST_PRELINK_CROSS_AUTORECONF = YES
+HOST_PRELINK_CROSS_DEPENDENCIES = host-libelf host-binutils
+PRELINK_CROSS_INSTALL_HOST=YES
+
+define PRELINK_CROSS_INSTALL_CONF
+	$(INSTALL) -m 0755 -D package/prelink-cross/prelink.conf ${TARGET_DIR}/etc/prelink.conf
+endef
+
+ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
+PRELINK_CMD="${HOST_DIR}/usr/sbin/prelink --verbose --config-file /etc/prelink.conf --cache-file /etc/prelink.cache --root=${TARGET_DIR} --ld-library-path=/lib:/usr/lib:/usr/local/lib:/chrome/lib:/chrome:/usr/local/lib/webkitGl3:/app/client --dynamic-linker=/lib/ld-uClibc.so.0 --all"
+else
+PRELINK_CMD="${HOST_DIR}/usr/sbin/prelink --verbose --config-file /etc/prelink.conf --cache-file /etc/prelink.cache --root=${TARGET_DIR} --ld-library-path=/lib:/usr/lib:/usr/local/lib:/chrome/lib:/chrome:/usr/local/lib/webkitGl3:/app/client --all"
+endif
+
+HOST_PRELINK_CROSS_POST_INSTALL_HOOKS += PRELINK_CROSS_INSTALL_CONF
+
+# The point of prelink-cross is to run it on the host. We deliberately do not
+# provide a way to compile it for the target, only the host.
+$(eval $(call AUTOTARGETS,host))
diff --git a/package/prelink-cross/prelink.conf b/package/prelink-cross/prelink.conf
new file mode 100644
index 0000000..085d474
--- /dev/null
+++ b/package/prelink-cross/prelink.conf
@@ -0,0 +1,12 @@
+-l /lib
+-l /usr/lib
+-l /usr/local/lib
+-l /bin
+-l /sbin
+-l /usr/bin
+-l /usr/sbin
+-l /usr/local/bin
+-l /chrome/lib
+-l /usr/local/lib/webkitGl3
+-l /usr/local/bin/webkitGl3
+-l /app/client
diff --git a/package/simpleramfs/helpers.sh b/package/simpleramfs/helpers.sh
index a0ed73a..f952dd2 100644
--- a/package/simpleramfs/helpers.sh
+++ b/package/simpleramfs/helpers.sh
@@ -1,12 +1,30 @@
+# Returns true if the string $1 contains the string $2.
+contains() {
+  case "$1" in
+    *"$2"*)
+      return 0
+  esac
+  return 1
+}
+
 log()
 {
   echo "$*" >&2
 }
 
-REG_FAILURE_COUNT="0x104083FC"
+# The address we signal back to the bootloader is the
+# same for 7425 and 7429 chips but different for 7252.
+# The register we're using is the last word in
+# SYSTEM_DATA_RAMi_ARRAY_BASE.
+read x y armplatform platform junk </proc/cpuinfo
+if contains "$platform" "BCM742"; then
+  REG_FAILURE_COUNT="0x104083FC"
+fi
 
 signal_failure() {
-  devmem $REG_FAILURE_COUNT 32 1
+  if [ -n "$REG_FAILURE_COUNT" ]; then
+    devmem $REG_FAILURE_COUNT 32 1
+  fi
 }