Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
preinit_set_mac_address() {
|
||||
case $(board_name) in
|
||||
asus,map-ac2200)
|
||||
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
|
||||
ip link set dev eth0 address $(macaddr_add "$base_mac" 1)
|
||||
ip link set dev eth1 address $(macaddr_add "$base_mac" 3)
|
||||
;;
|
||||
asus,rt-ac42u)
|
||||
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
|
||||
ip link set dev eth0 address $base_mac
|
||||
ip link set dev lan1 address $base_mac
|
||||
ip link set dev lan2 address $base_mac
|
||||
ip link set dev lan3 address $base_mac
|
||||
ip link set dev lan4 address $base_mac
|
||||
ip link set dev wan address $(mtd_get_mac_binary_ubi Factory 0x9006)
|
||||
;;
|
||||
engenius,eap2200)
|
||||
base_mac=$(cat /sys/class/net/eth0/address)
|
||||
ip link set dev eth1 address $(macaddr_add "$base_mac" 1)
|
||||
;;
|
||||
extreme-networks,ws-ap3915i|\
|
||||
extreme-networks,ws-ap391x)
|
||||
ip link set dev eth0 address $(mtd_get_mac_ascii CFG1 ethaddr)
|
||||
;;
|
||||
linksys,ea8300|\
|
||||
linksys,mr8300)
|
||||
base_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ip link set dev lan1 address $(macaddr_add "$base_mac" 1)
|
||||
ip link set dev eth0 address $(macaddr_setbit "$base_mac" 7)
|
||||
;;
|
||||
linksys,whw03)
|
||||
base_mac=$(mmc_get_mac_ascii devinfo hw_mac_addr)
|
||||
ip link set dev eth0 address "$base_mac"
|
||||
ip link set dev lan address "$base_mac"
|
||||
ip link set dev wan address "$base_mac"
|
||||
;;
|
||||
mikrotik,wap-ac|\
|
||||
mikrotik,wap-ac-lte|\
|
||||
mikrotik,wap-r-ac)
|
||||
base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
|
||||
ip link set dev sw-eth1 address "$base_mac"
|
||||
ip link set dev sw-eth2 address $(macaddr_add "$base_mac" 1)
|
||||
;;
|
||||
zyxel,nbg6617)
|
||||
base_mac=$(cat /sys/class/net/eth0/address)
|
||||
ip link set dev eth0 address $(macaddr_add "$base_mac" 2)
|
||||
ip link set dev eth1 address $(macaddr_add "$base_mac" 3)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_set_mac_address
|
||||
108
target/linux/ipq40xx/base-files/lib/upgrade/dualboot_datachk.sh
Normal file
108
target/linux/ipq40xx/base-files/lib/upgrade/dualboot_datachk.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
# The U-Boot loader with the datachk patchset for dualbooting requires image
|
||||
# sizes and checksums to be provided in the U-Boot environment.
|
||||
# The devices come with 2 main partitions - while one is active
|
||||
# sysupgrade will flash the other. The boot order is changed to boot the
|
||||
# newly flashed partition. If the new partition can't be booted due to
|
||||
# upgrade failures the previously used partition is loaded.
|
||||
|
||||
platform_do_upgrade_dualboot_datachk() {
|
||||
local tar_file="$1"
|
||||
local restore_backup
|
||||
local primary_kernel_mtd
|
||||
|
||||
local setenv_script="/tmp/fw_env_upgrade"
|
||||
|
||||
local kernel_mtd="$(find_mtd_index $PART_NAME)"
|
||||
local kernel_offset="$(cat /sys/class/mtd/mtd${kernel_mtd}/offset)"
|
||||
local total_size="$(cat /sys/class/mtd/mtd${kernel_mtd}/size)"
|
||||
|
||||
# detect to which flash region the new image is written to.
|
||||
#
|
||||
# 1. check what is the mtd index for the first flash region on this
|
||||
# device
|
||||
# 2. check if the target partition ("inactive") has the mtd index of
|
||||
# the first flash region
|
||||
#
|
||||
# - when it is: the new bootseq will be 1,2 and the first region is
|
||||
# modified
|
||||
# - when it isnt: bootseq will be 2,1 and the second region is
|
||||
# modified
|
||||
#
|
||||
# The detection has to be done via the hardcoded mtd partition because
|
||||
# the current boot might be done with the fallback region. Let us
|
||||
# assume that the current bootseq is 1,2. The bootloader detected that
|
||||
# the image in flash region 1 is corrupt and thus switches to flash
|
||||
# region 2. The bootseq in the u-boot-env is now still the same and
|
||||
# the sysupgrade code can now only rely on the actual mtd indexes and
|
||||
# not the bootseq variable to detect the currently booted flash
|
||||
# region/image.
|
||||
#
|
||||
# In the above example, an implementation which uses bootseq ("1,2") to
|
||||
# detect the currently booted image would assume that region 1 is booted
|
||||
# and then overwrite the variables for the wrong flash region (aka the
|
||||
# one which isn't modified). This could result in a device which doesn't
|
||||
# boot anymore to Linux until it was reflashed with ap51-flash.
|
||||
local next_boot_part="1"
|
||||
case "$(board_name)" in
|
||||
plasmacloud,pa1200|\
|
||||
openmesh,a42)
|
||||
primary_kernel_mtd=8
|
||||
;;
|
||||
plasmacloud,pa2200|\
|
||||
openmesh,a62)
|
||||
primary_kernel_mtd=10
|
||||
;;
|
||||
*)
|
||||
echo "failed to detect primary kernel mtd partition for board"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
[ "$kernel_mtd" = "$primary_kernel_mtd" ] || next_boot_part="2"
|
||||
|
||||
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
local kernel_length=$(tar xf $tar_file ${board_dir}/kernel -O | wc -c)
|
||||
local rootfs_length=$(tar xf $tar_file ${board_dir}/root -O | wc -c)
|
||||
# rootfs without EOF marker
|
||||
rootfs_length=$((rootfs_length-4))
|
||||
|
||||
local kernel_md5=$(tar xf $tar_file ${board_dir}/kernel -O | md5sum); kernel_md5="${kernel_md5%% *}"
|
||||
# md5 checksum of rootfs with EOF marker
|
||||
local rootfs_md5=$(tar xf $tar_file ${board_dir}/root -O | dd bs=1 count=$rootfs_length | md5sum); rootfs_md5="${rootfs_md5%% *}"
|
||||
|
||||
#
|
||||
# add tar support to get_image() to use default_do_upgrade() instead?
|
||||
#
|
||||
|
||||
# take care of restoring a saved config
|
||||
[ -n "$UPGRADE_BACKUP" ] && restore_backup="${MTD_CONFIG_ARGS} -j ${UPGRADE_BACKUP}"
|
||||
|
||||
mtd -q erase inactive
|
||||
tar xf $tar_file ${board_dir}/root -O | mtd -n -p $kernel_length $restore_backup write - $PART_NAME
|
||||
tar xf $tar_file ${board_dir}/kernel -O | mtd -n write - $PART_NAME
|
||||
|
||||
# prepare new u-boot env
|
||||
if [ "$next_boot_part" = "1" ]; then
|
||||
echo "bootseq 1,2" > $setenv_script
|
||||
else
|
||||
echo "bootseq 2,1" > $setenv_script
|
||||
fi
|
||||
|
||||
printf "kernel_size_%i 0x%08x\n" $next_boot_part $kernel_length >> $setenv_script
|
||||
printf "vmlinux_start_addr 0x%08x\n" ${kernel_offset} >> $setenv_script
|
||||
printf "vmlinux_size 0x%08x\n" ${kernel_length} >> $setenv_script
|
||||
printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
|
||||
|
||||
printf "rootfs_size_%i 0x%08x\n" $next_boot_part $((total_size-kernel_length)) >> $setenv_script
|
||||
printf "rootfs_start_addr 0x%08x\n" $((kernel_offset+kernel_length)) >> $setenv_script
|
||||
printf "rootfs_size 0x%08x\n" ${rootfs_length} >> $setenv_script
|
||||
printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
|
||||
|
||||
# store u-boot env changes
|
||||
mkdir -p /var/lock
|
||||
fw_setenv -s $setenv_script || {
|
||||
echo "failed to update U-Boot environment"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
193
target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Normal file
193
target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Normal file
@@ -0,0 +1,193 @@
|
||||
linksys_get_target_firmware() {
|
||||
local cur_boot_part mtd_ubi0
|
||||
|
||||
cur_boot_part="$(/usr/sbin/fw_printenv -n boot_part)"
|
||||
if [ -z "${cur_boot_part}" ]; then
|
||||
mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
|
||||
case "$(grep -E "^mtd${mtd_ubi0}:" /proc/mtd | cut -d '"' -f 2)" in
|
||||
kernel|rootfs)
|
||||
cur_boot_part=1
|
||||
;;
|
||||
alt_kernel|alt_rootfs)
|
||||
cur_boot_part=2
|
||||
;;
|
||||
esac
|
||||
>&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \
|
||||
"${cur_boot_part}" "${mtd_ubi0}"
|
||||
fi
|
||||
|
||||
# OEM U-Boot for EA6350v3, EA8300 and MR8300; bootcmd=
|
||||
# if test $auto_recovery = no;
|
||||
# then bootipq;
|
||||
# elif test $boot_part = 1;
|
||||
# then run bootpart1;
|
||||
# else run bootpart2;
|
||||
# fi
|
||||
|
||||
case "$cur_boot_part" in
|
||||
1)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 2
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "alt_kernel"
|
||||
return
|
||||
;;
|
||||
2)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 1
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "kernel"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
linksys_is_factory_image() {
|
||||
local board=$(board_name)
|
||||
board=${board##*,}
|
||||
|
||||
# check matching footer signature
|
||||
tail -c 256 $1 | grep -q -i "\.LINKSYS\.........${board}"
|
||||
}
|
||||
|
||||
platform_do_upgrade_linksys() {
|
||||
local magic_long="$(get_magic_long "$1")"
|
||||
|
||||
local rm_oem_fw_vols="squashfs ubifs" # from OEM [alt_]rootfs UBI
|
||||
local vol
|
||||
|
||||
mkdir -p /var/lock
|
||||
local part_label="$(linksys_get_target_firmware)"
|
||||
touch /var/lock/fw_printenv.lock
|
||||
|
||||
if [ -z "$part_label" ]; then
|
||||
echo "cannot find target partition"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local target_mtd=$(find_mtd_part "$part_label")
|
||||
|
||||
[ "$magic_long" = "73797375" ] && {
|
||||
CI_KERNPART="$part_label"
|
||||
if [ "$part_label" = "kernel" ]; then
|
||||
CI_UBIPART="rootfs"
|
||||
else
|
||||
CI_UBIPART="alt_rootfs"
|
||||
fi
|
||||
|
||||
local mtdnum="$(find_mtd_index "$CI_UBIPART")"
|
||||
if [ ! "$mtdnum" ]; then
|
||||
echo "cannot find ubi mtd partition $CI_UBIPART"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ubidev="$(nand_find_ubi "$CI_UBIPART")"
|
||||
if [ ! "$ubidev" ]; then
|
||||
ubiattach -m "$mtdnum"
|
||||
sync
|
||||
ubidev="$(nand_find_ubi "$CI_UBIPART")"
|
||||
fi
|
||||
|
||||
if [ "$ubidev" ]; then
|
||||
for vol in $rm_oem_fw_vols; do
|
||||
ubirmvol "/dev/$ubidev" -N "$vol" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
# complete std upgrade
|
||||
if nand_upgrade_tar "$1" ; then
|
||||
nand_do_upgrade_success
|
||||
else
|
||||
nand_do_upgrade_failed
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
[ "$magic_long" = "27051956" ] && {
|
||||
echo "writing \"$1\" image to \"$part_label\""
|
||||
get_image "$1" | mtd write - "$part_label"
|
||||
}
|
||||
|
||||
[ "$magic_long" = "d00dfeed" ] && {
|
||||
if ! linksys_is_factory_image "$1"; then
|
||||
echo "factory image doesn't match device"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "writing \"$1\" factory image to \"$part_label\""
|
||||
get_image "$1" | mtd -e "$part_label" write - "$part_label"
|
||||
}
|
||||
}
|
||||
|
||||
linksys_get_cmdline_rootfs_device() {
|
||||
if read cmdline < /proc/cmdline; then
|
||||
case "$cmdline" in
|
||||
*root=*)
|
||||
local str="${cmdline##*root=}"
|
||||
echo "${str%% *}"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
linksys_get_current_boot_part_emmc() {
|
||||
local boot_part="$(fw_printenv -n boot_part)"
|
||||
if [ "$boot_part" = 1 ] || [ "$boot_part" = 2 ]; then
|
||||
v "Current boot_part=$boot_part selected from bootloader environment"
|
||||
else
|
||||
local rootfs_device="$(linksys_get_cmdline_rootfs_device)"
|
||||
if [ "$rootfs_device" = "$(find_mmc_part "rootfs")" ]; then
|
||||
boot_part=1
|
||||
elif [ "$rootfs_device" = "$(find_mmc_part "alt_rootfs")" ]; then
|
||||
boot_part=2
|
||||
else
|
||||
v "Could not determine current boot_part"
|
||||
return 1
|
||||
fi
|
||||
v "Current boot_part=$boot_part selected from cmdline rootfs=$rootfs_device"
|
||||
fi
|
||||
echo $boot_part
|
||||
}
|
||||
|
||||
linksys_set_target_partitions_emmc() {
|
||||
local current_boot_part="$1"
|
||||
|
||||
if [ "$current_boot_part" = 1 ]; then
|
||||
CI_KERNPART="alt_kernel"
|
||||
CI_ROOTPART="alt_rootfs"
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 2
|
||||
auto_recovery yes
|
||||
EOF
|
||||
elif [ "$current_boot_part" = 2 ]; then
|
||||
CI_KERNPART="kernel"
|
||||
CI_ROOTPART="rootfs"
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 1
|
||||
auto_recovery yes
|
||||
EOF
|
||||
else
|
||||
v "Could not set target eMMC partitions"
|
||||
return 1
|
||||
fi
|
||||
|
||||
v "Target eMMC partitions: $CI_KERNPART, $CI_ROOTPART"
|
||||
}
|
||||
|
||||
platform_do_upgrade_linksys_emmc() {
|
||||
local file="$1"
|
||||
|
||||
mkdir -p /var/lock
|
||||
local current_boot_part="$(linksys_get_current_boot_part_emmc)"
|
||||
linksys_set_target_partitions_emmc "$current_boot_part" || exit 1
|
||||
touch /var/lock/fw_printenv.lock
|
||||
|
||||
emmc_do_upgrade "$file"
|
||||
}
|
||||
76
target/linux/ipq40xx/base-files/lib/upgrade/netgear.sh
Normal file
76
target/linux/ipq40xx/base-files/lib/upgrade/netgear.sh
Normal file
@@ -0,0 +1,76 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
. /lib/functions.sh
|
||||
|
||||
platform_do_upgrade_netgear_orbi_upgrade() {
|
||||
command -v losetup >/dev/null || {
|
||||
logger -s "Upgrade failed: 'losetup' not installed."
|
||||
return 1
|
||||
}
|
||||
|
||||
local tar_file=$1
|
||||
local kernel=$2
|
||||
local rootfs=$3
|
||||
|
||||
[ -z "$kernel" ] && kernel=$(find_mmc_part "kernel")
|
||||
[ -z "$rootfs" ] && rootfs=$(find_mmc_part "rootfs")
|
||||
|
||||
[ -z "$kernel" ] && echo "Upgrade failed: kernel partition not found! Rebooting..." && reboot -f
|
||||
[ -z "$rootfs" ] && echo "Upgrade failed: rootfs partition not found! Rebooting..." && reboot -f
|
||||
|
||||
netgear_orbi_do_flash $tar_file $kernel $rootfs
|
||||
|
||||
echo "sysupgrade successful"
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
netgear_orbi_do_flash() {
|
||||
local tar_file=$1
|
||||
local kernel=$2
|
||||
local rootfs=$3
|
||||
|
||||
# keep sure its unbound
|
||||
losetup --detach-all || {
|
||||
echo "Failed to detach all loop devices. Skip this try."
|
||||
reboot -f
|
||||
}
|
||||
|
||||
# use the first found directory in the tar archive
|
||||
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
echo "flashing kernel to $kernel"
|
||||
tar xf $tar_file ${board_dir}/kernel -O >$kernel
|
||||
|
||||
echo "flashing rootfs to ${rootfs}"
|
||||
tar xf $tar_file ${board_dir}/root -O >"${rootfs}"
|
||||
|
||||
# a padded rootfs is needed for overlay fs creation
|
||||
local offset=$(tar xf $tar_file ${board_dir}/root -O | wc -c)
|
||||
[ $offset -lt 65536 ] && {
|
||||
echo "Wrong size for rootfs: $offset"
|
||||
sleep 10
|
||||
reboot -f
|
||||
}
|
||||
|
||||
# Mount loop for rootfs_data
|
||||
local loopdev="$(losetup -f)"
|
||||
losetup -o $offset $loopdev $rootfs || {
|
||||
echo "Failed to mount looped rootfs_data."
|
||||
sleep 10
|
||||
reboot -f
|
||||
}
|
||||
|
||||
echo "Format new rootfs_data at position ${offset}."
|
||||
mkfs.ext4 -F -L rootfs_data $loopdev
|
||||
mkdir /tmp/new_root
|
||||
mount -t ext4 $loopdev /tmp/new_root && {
|
||||
echo "Saving config to rootfs_data at position ${offset}."
|
||||
cp -v "$UPGRADE_BACKUP" "/tmp/new_root/$BACKUP_FILE"
|
||||
umount /tmp/new_root
|
||||
}
|
||||
|
||||
# Cleanup
|
||||
losetup -d $loopdev >/dev/null 2>&1
|
||||
sync
|
||||
}
|
||||
248
target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Normal file
248
target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Normal file
@@ -0,0 +1,248 @@
|
||||
PART_NAME=firmware
|
||||
REQUIRE_IMAGE_METADATA=1
|
||||
|
||||
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||
|
||||
platform_check_image() {
|
||||
case "$(board_name)" in
|
||||
asus,rt-ac42u |\
|
||||
asus,rt-ac58u)
|
||||
local ubidev=$(nand_find_ubi $CI_UBIPART)
|
||||
local asus_root=$(nand_find_volume $ubidev jffs2)
|
||||
|
||||
[ -n "$asus_root" ] || return 0
|
||||
|
||||
cat << EOF
|
||||
jffs2 partition is still present.
|
||||
There's probably no space left
|
||||
to install the filesystem.
|
||||
|
||||
You need to delete the jffs2 partition first:
|
||||
# ubirmvol /dev/ubi0 --name=jffs2
|
||||
|
||||
Once this is done. Retry.
|
||||
EOF
|
||||
return 1
|
||||
;;
|
||||
zte,mf18a |\
|
||||
zte,mf282plus|\
|
||||
zte,mf286d |\
|
||||
zte,mf287|\
|
||||
zte,mf287plus |\
|
||||
zte,mf287pro |\
|
||||
zte,mf289f)
|
||||
CI_UBIPART="rootfs"
|
||||
local mtdnum="$( find_mtd_index $CI_UBIPART )"
|
||||
[ ! "$mtdnum" ] && return 1
|
||||
ubiattach -m "$mtdnum" || true
|
||||
local ubidev="$( nand_find_ubi $CI_UBIPART )"
|
||||
local ubi_rootfs=$(nand_find_volume $ubidev ubi_rootfs)
|
||||
local ubi_rootfs_data=$(nand_find_volume $ubidev ubi_rootfs_data)
|
||||
|
||||
[ -n "$ubi_rootfs" ] || [ -n "$ubi_rootfs_data" ] || return 0
|
||||
|
||||
cat << EOF
|
||||
ubi_rootfs partition is still present.
|
||||
|
||||
You need to delete the stock partition first:
|
||||
# ubirmvol /dev/ubi0 -N ubi_rootfs
|
||||
Please also delete ubi_rootfs_data, if exist:
|
||||
# ubirmvol /dev/ubi0 -N ubi_rootfs_data
|
||||
|
||||
Once this is done. Retry.
|
||||
EOF
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
return 0;
|
||||
}
|
||||
|
||||
askey_do_upgrade() {
|
||||
local tar_file="$1"
|
||||
|
||||
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
|
||||
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
|
||||
zyxel_do_upgrade() {
|
||||
local tar_file="$1"
|
||||
|
||||
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
|
||||
|
||||
if [ -n "$UPGRADE_BACKUP" ]; then
|
||||
tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
|
||||
else
|
||||
tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
|
||||
fi
|
||||
}
|
||||
|
||||
platform_do_upgrade_mikrotik_nand() {
|
||||
local fw_mtd=$(find_mtd_part kernel)
|
||||
fw_mtd="${fw_mtd/block/}"
|
||||
[ -n "$fw_mtd" ] || return
|
||||
|
||||
local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
[ -n "$board_dir" ] || return
|
||||
|
||||
local kernel_len=$(tar xf "$1" ${board_dir}/kernel -O | wc -c)
|
||||
[ -n "$kernel_len" ] || return
|
||||
|
||||
tar xf "$1" ${board_dir}/kernel -O | ubiformat "$fw_mtd" -y -S $kernel_len -f -
|
||||
|
||||
CI_KERNPART="none"
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
case "$(board_name)" in
|
||||
8dev,jalapeno |\
|
||||
aruba,ap-303 |\
|
||||
aruba,ap-303h |\
|
||||
aruba,ap-365 |\
|
||||
avm,fritzbox-7530 |\
|
||||
avm,fritzrepeater-1200 |\
|
||||
avm,fritzrepeater-3000 |\
|
||||
buffalo,wtr-m2133hp |\
|
||||
cilab,meshpoint-one |\
|
||||
edgecore,ecw5211 |\
|
||||
edgecore,oap100 |\
|
||||
engenius,eap2200 |\
|
||||
glinet,gl-a1300 |\
|
||||
glinet,gl-ap1300 |\
|
||||
luma,wrtq-329acn |\
|
||||
mobipromo,cm520-79f |\
|
||||
netgear,lbr20 |\
|
||||
netgear,wac510 |\
|
||||
p2w,r619ac-64m |\
|
||||
p2w,r619ac-128m |\
|
||||
qxwlan,e2600ac-c2 |\
|
||||
wallys,dr40x9)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
glinet,gl-b2200)
|
||||
CI_KERNPART="0:HLOS"
|
||||
CI_ROOTPART="rootfs"
|
||||
CI_DATAPART="rootfs_data"
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
alfa-network,ap120c-ac)
|
||||
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
|
||||
if [ "$part" = "rootfs1" ]; then
|
||||
fw_setenv active 2 || exit 1
|
||||
CI_UBIPART="rootfs2"
|
||||
else
|
||||
fw_setenv active 1 || exit 1
|
||||
CI_UBIPART="rootfs1"
|
||||
fi
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
asus,map-ac2200)
|
||||
CI_KERNPART="linux"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
asus,rt-ac42u |\
|
||||
asus,rt-ac58u)
|
||||
CI_KERNPART="linux"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
cellc,rtl30vw)
|
||||
CI_UBIPART="ubifs"
|
||||
askey_do_upgrade "$1"
|
||||
;;
|
||||
compex,wpj419)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
google,wifi)
|
||||
export_bootdevice
|
||||
export_partdevice CI_ROOTDEV 0
|
||||
CI_KERNPART="kernel"
|
||||
CI_ROOTPART="rootfs"
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
linksys,ea6350v3 |\
|
||||
linksys,ea8300 |\
|
||||
linksys,mr8300 |\
|
||||
linksys,whw01 |\
|
||||
linksys,whw03v2)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
linksys,whw03)
|
||||
platform_do_upgrade_linksys_emmc "$1"
|
||||
;;
|
||||
meraki,mr33 |\
|
||||
meraki,mr74)
|
||||
CI_KERNPART="part.safe"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
mikrotik,cap-ac|\
|
||||
mikrotik,hap-ac2|\
|
||||
mikrotik,hap-ac3-lte6-kit|\
|
||||
mikrotik,lhgg-60ad|\
|
||||
mikrotik,sxtsq-5-ac|\
|
||||
mikrotik,wap-ac|\
|
||||
mikrotik,wap-ac-lte|\
|
||||
mikrotik,wap-r-ac)
|
||||
[ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
mikrotik,hap-ac3)
|
||||
platform_do_upgrade_mikrotik_nand "$1"
|
||||
;;
|
||||
netgear,rbr40|\
|
||||
netgear,rbs40|\
|
||||
netgear,rbr50 |\
|
||||
netgear,rbs50 |\
|
||||
netgear,srr60 |\
|
||||
netgear,srs60)
|
||||
platform_do_upgrade_netgear_orbi_upgrade "$1"
|
||||
;;
|
||||
openmesh,a42 |\
|
||||
openmesh,a62 |\
|
||||
plasmacloud,pa1200 |\
|
||||
plasmacloud,pa2200)
|
||||
PART_NAME="inactive"
|
||||
platform_do_upgrade_dualboot_datachk "$1"
|
||||
;;
|
||||
sony,ncp-hg100-cellular)
|
||||
sony_emmc_do_upgrade "$1"
|
||||
;;
|
||||
teltonika,rutx10 |\
|
||||
teltonika,rutx50 |\
|
||||
zte,mf18a |\
|
||||
zte,mf282plus |\
|
||||
zte,mf286d |\
|
||||
zte,mf287 |\
|
||||
zte,mf287plus |\
|
||||
zte,mf287pro |\
|
||||
zte,mf289f)
|
||||
CI_UBIPART="rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,nbg6617)
|
||||
zyxel_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
glinet,gl-b2200 |\
|
||||
google,wifi |\
|
||||
linksys,whw03)
|
||||
emmc_copy_config
|
||||
;;
|
||||
esac
|
||||
return 0;
|
||||
}
|
||||
91
target/linux/ipq40xx/base-files/lib/upgrade/sony.sh
Normal file
91
target/linux/ipq40xx/base-files/lib/upgrade/sony.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
update_bootconfig() {
|
||||
local offset=$1
|
||||
local index="$2"
|
||||
local cfgpart=$(find_mmc_part "0:BOOTCONFIG")
|
||||
local cur_index
|
||||
|
||||
if [ -z "$cfgpart" ]; then
|
||||
echo "failed to get the partition: \"0:BOOTCONFIG\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
cur_index=$(dd if=${cfgpart} bs=1 count=1 skip=$offset 2> /dev/null | hexdump -e '"%d"')
|
||||
if [ ${index} != ${cur_index} ]; then
|
||||
echo "updating \"0:BOOTCONFIG\""
|
||||
echo -en "\x0${index}" | \
|
||||
dd of=${cfgpart} bs=1 count=1 seek=$offset conv=notrunc 2>/dev/null
|
||||
fi
|
||||
|
||||
# also update 0:BOOTCONFIG1 if exists
|
||||
cfgpart=$(find_mmc_part "0:BOOTCONFIG1")
|
||||
[ -z "$cfgpart" ] && return
|
||||
|
||||
cur_index=$(dd if=${cfgpart} bs=1 count=1 skip=$offset 2> /dev/null | hexdump -e '"%d"')
|
||||
if [ ${index} != ${cur_index} ]; then
|
||||
echo "updating \"0:BOOTCONFIG1\""
|
||||
echo -en "\x0${index}" | \
|
||||
dd of=${cfgpart} bs=1 count=1 seek=$offset conv=notrunc 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
### Note ###
|
||||
# After the commit bad1835f27ec31dbc30060b03cc714212275168a in fstools,
|
||||
# p17 (label: "rootfs_data") is mounted as a rootfs_data on boot instead
|
||||
# of the loop device labeled as "rootfs_data" in p15 (label: "rootfs").
|
||||
#
|
||||
# cmdline flag is added to avoid mount "rootfs_data" partition by the
|
||||
# commit 964d1e3af0e111bad6d393f8a3be702e334c2398 in fstools, but
|
||||
# NCP-HG100 doesn't use it because it has a large (abount 1.6GB)
|
||||
# "rootfs_data" partition and the advantage is larger than the
|
||||
# disadvantages, such as overwriting the stock data in "rootfs_data"
|
||||
# partition.
|
||||
sony_emmc_do_upgrade() {
|
||||
local tar_file=$1
|
||||
local kernel_dev
|
||||
local rootfs_dev
|
||||
local board_dir
|
||||
|
||||
kernel_dev=$(find_mmc_part "0:HLOS")
|
||||
rootfs_dev=$(find_mmc_part "rootfs")
|
||||
rootfs_data_dev=$(find_mmc_part "rootfs_data")
|
||||
|
||||
if [ -z "$kernel_dev" ] || [ -z "$rootfs_dev" ] || [ -z "$rootfs_data_dev" ]; then
|
||||
echo "The partition name for kernel or rootfs or rootfs_data is not specified or failed to get the mmc device."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# use first partitions of kernel/rootfs for NCP-HG100
|
||||
# - offset 88 (0x58): 0:HLOS (kernel)
|
||||
# - offset 108 (0x6c): rootfs
|
||||
update_bootconfig 88 0 || exit 1
|
||||
update_bootconfig 108 0 || exit 1
|
||||
|
||||
board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
echo "Flashing kernel to ${kernel_dev}"
|
||||
tar xf $tar_file ${board_dir}/kernel -O > $kernel_dev
|
||||
|
||||
echo "Flashing rootfs to ${rootfs_dev}"
|
||||
tar xf $tar_file ${board_dir}/root -O > $rootfs_dev
|
||||
|
||||
echo "Format new rootfs_data"
|
||||
mkfs.ext4 -F -L rootfs_data $rootfs_data_dev
|
||||
|
||||
if [ -e "$UPGRADE_BACKUP" ]; then
|
||||
mkdir /tmp/new_root
|
||||
mount -t ext4 $rootfs_data_dev /tmp/new_root && {
|
||||
echo "Saving configurations to rootfs_data"
|
||||
cp "$UPGRADE_BACKUP" "/tmp/new_root/$BACKUP_FILE"
|
||||
umount /tmp/new_root
|
||||
}
|
||||
fi
|
||||
|
||||
echo "sysupgrade successful"
|
||||
|
||||
sync
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
Reference in New Issue
Block a user