ath79: initial support for Ubiquiti RouterStation and RouterStation Pro
[openwrt/staging/wigyori.git] / target / linux / ath79 / base-files / lib / upgrade / platform.sh
index 08039e00523853c76c7e2d49eb18fd10717637f0..806b3f07871dc37cc65fe8a13df60f9a0c008225 100644 (file)
@@ -5,6 +5,15 @@
 PART_NAME=firmware
 REQUIRE_IMAGE_METADATA=1
 
+routerstation_do_upgrade() {
+       local append
+       local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
+
+       [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
+       dd if="$1" bs=64k skip=1 2>/dev/null | \
+               mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs
+}
+
 platform_check_image() {
        return 0
 }
@@ -17,6 +26,10 @@ platform_do_upgrade() {
                PART_NAME="rootfs:kernel"
                default_do_upgrade "$ARGV"
                ;;
+       ubnt,routerstation|\
+       ubnt,routerstation-pro)
+               routerstation_do_upgrade "$ARGV"
+               ;;
        *)
                default_do_upgrade "$ARGV"
                ;;