bcm53xx: use iflag=skip_bytes for dd command during sysupgrade
[openwrt/openwrt.git] / target / linux / bcm53xx / base-files / lib / upgrade / platform.sh
index 3e4eae5a82fba979e4f50b51646cb93ce610b1f1..06451f17fd91a50e4ab4d358200347b94afbaeb7 100644 (file)
@@ -1,3 +1,5 @@
+RAMFS_COPY_BIN='osafeloader oseama'
+
 PART_NAME=firmware
 
 # $(1): file to read magic from
@@ -6,10 +8,6 @@ get_magic_long_at() {
        dd if="$1" skip=$2 bs=1 count=4 2>/dev/null | hexdump -v -e '1/1 "%02x"'
 }
 
-platform_machine() {
-       cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1
-}
-
 platform_flash_type() {
        # On NAND devices "rootfs" is UBI volume, so won't be find in /proc/mtd
        grep -q "\"rootfs\"" /proc/mtd && {
@@ -21,7 +19,7 @@ platform_flash_type() {
 }
 
 platform_expected_image() {
-       local machine=$(platform_machine)
+       local machine=$(board_name)
 
        case "$machine" in
                "dlink,dir-885l")       echo "seama wrgac42_dlink.2015_dir885l"; return;;
@@ -31,6 +29,7 @@ platform_expected_image() {
                "netgear,r7900")        echo "chk U12H315T30_NETGEAR"; return;;
                "netgear,r8000")        echo "chk U12H315T00_NETGEAR"; return;;
                "netgear,r8500")        echo "chk U12H334T00_NETGEAR"; return;;
+               "tplink,archer-c9-v1")  echo "safeloader"; return;;
        esac
 }
 
@@ -59,7 +58,7 @@ platform_identify() {
                return
        }
 
-       if osafeloader info "$1" > /dev/null; then
+       if osafeloader info "$1" > /dev/null 2>&1; then
                echo "safeloader"
                return
        fi
@@ -259,8 +258,6 @@ platform_pre_upgrade_seama() {
 }
 
 platform_pre_upgrade() {
-       export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/bin/osafeloader /usr/bin/oseama /bin/sed"
-
        local file_type=$(platform_identify "$1")
 
        [ "$(platform_flash_type)" != "nand" ] && return
@@ -277,11 +274,11 @@ platform_pre_upgrade() {
 platform_trx_from_chk_cmd() {
        local header_len=$((0x$(get_magic_long_at "$1" 4)))
 
-       echo -n dd bs=$header_len skip=1
+       echo -n dd skip=$header_len iflag=skip_bytes
 }
 
 platform_trx_from_cybertan_cmd() {
-       echo -n dd bs=32 skip=1
+       echo -n dd skip=32 iflag=skip_bytes
 }
 
 platform_img_from_safeloader() {