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:
112
target/linux/ramips/mt7621/base-files/lib/upgrade/buffalo.sh
Normal file
112
target/linux/ramips/mt7621/base-files/lib/upgrade/buffalo.sh
Normal file
@@ -0,0 +1,112 @@
|
||||
# The mtd partitions "firmware" and "Kernel2" on NAND flash are os-image
|
||||
# partitions. These partitions are called as "Image1/Image2" in U-Boot
|
||||
# on WSR-2533DHPLx devices, and they are checked conditions when booting.
|
||||
# "Image1" is always used for booting.
|
||||
#
|
||||
# == U-Boot Behaviors ==
|
||||
#
|
||||
# - "Image1"/"Image2" images are good, images are different or
|
||||
# "Image2" image is broken
|
||||
# -> copy os-image to "Image2" from "Image1"
|
||||
#
|
||||
# - "Image1" image is broken
|
||||
# -> copy os-image to "Image1" from "Image2"
|
||||
#
|
||||
# - "Image1"/"Image2" images are broken
|
||||
# -> fall to U-Boot command line
|
||||
|
||||
# TRX magic numbers of each model
|
||||
case "$(board_name)" in
|
||||
buffalo,wsr-2533dhpl2)
|
||||
BUFFALO_TRX_MAGIC="50484c32" # "PHL2"
|
||||
;;
|
||||
buffalo,wsr-2533dhpls)
|
||||
BUFFALO_TRX_MAGIC="44484c53" # "DHLS"
|
||||
;;
|
||||
esac
|
||||
|
||||
buffalo_check_image() {
|
||||
local board="$1"
|
||||
local boardname="$(echo $board | tr ',' '_')"
|
||||
local magic="$2"
|
||||
local fw_image="$3"
|
||||
|
||||
# return error state if TRX + UBI formatted image specified
|
||||
# to notify about configurations
|
||||
if [ "$magic" = "$BUFFALO_TRX_MAGIC" ]; then
|
||||
echo "Your configurations won't be saved if factory-uboot.bin image specified."
|
||||
echo "But if you want to upgrade, please execute sysupgrade with \"-F\" option."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check if valid tar file specifed
|
||||
if ! tar tf "$fw_image" &>/dev/null; then
|
||||
echo "Specified file is not a tar archive: $fw_image"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local control_len=$( (tar xf $fw_image sysupgrade-$boardname/CONTROL -O | wc -c) 2> /dev/null)
|
||||
|
||||
# check if valid sysupgrade tar archive
|
||||
if [ "$control_len" = "0" ]; then
|
||||
echo "Invalid sysupgrade file: $fw_image"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local kern_part_len=$(grep "\"linux\"" /proc/mtd | sed "s/mtd[0-9]*:[ \t]*\([^ \t]*\).*/\1/")
|
||||
[ -z "$kern_part_len" ] && {
|
||||
echo "Unable to get \"linux\" partition size"
|
||||
return 1
|
||||
}
|
||||
kern_part_len=$((0x$kern_part_len))
|
||||
|
||||
# this also checks if the sysupgrade image is for correct models
|
||||
local kern_bin_len=$( (tar xf $fw_image sysupgrade-${boardname}/kernel -O | wc -c) 2> /dev/null)
|
||||
if [ -z "$kern_bin_len" ]; then
|
||||
echo "Failed to get new kernel size, is valid sysupgrade image specified for the device?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# kernel binary has a trx header (len: 28 (0x1c))
|
||||
kern_bin_len=$((kern_bin_len - 28))
|
||||
|
||||
if [ "$kern_bin_len" != "$kern_part_len" ]; then
|
||||
echo -n "The length of new kernel is invalid for current "
|
||||
echo "\"linux\" partition, please use factory-uboot.bin image."
|
||||
echo "\"linux\" partition: $kern_part_len, new kernel: $kern_bin_len"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# for TRX + UBI formatted image
|
||||
buffalo_upgrade_ubinized() {
|
||||
sync
|
||||
echo 3 > /proc/sys/vm/drop_caches
|
||||
|
||||
local mtdnum="$( find_mtd_index "ubi" )"
|
||||
# if no "ubi", don't return error for the purpose of recovery
|
||||
# ex: recovery after accidental erasing "firmware" partition
|
||||
if [ ! "$mtdnum" ]; then
|
||||
echo "cannot find ubi mtd partition \"ubi\", skip detachment"
|
||||
else
|
||||
ubidetach -m "$mtdnum"
|
||||
fi
|
||||
|
||||
# erase all data in "firmware"
|
||||
mtd erase "${PART_NAME}"
|
||||
# write TRX + UBI formatted image to "firmware"
|
||||
get_image "$1" | mtd $MTD_ARGS write - "${PART_NAME:-firmware}"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to write the specified image."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
buffalo_do_upgrade() {
|
||||
if [ "$(get_magic_long "$1")" = "$BUFFALO_TRX_MAGIC" ]; then
|
||||
buffalo_upgrade_ubinized "$1"
|
||||
else
|
||||
CI_KERNPART="firmware"
|
||||
nand_do_upgrade "$1"
|
||||
fi
|
||||
}
|
||||
44
target/linux/ramips/mt7621/base-files/lib/upgrade/dna.sh
Normal file
44
target/linux/ramips/mt7621/base-files/lib/upgrade/dna.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (C) 2023 Mauri Sandberg
|
||||
#
|
||||
|
||||
# The vendor UBI is split in volumes 0-3. Volumes 0 and 1 contain U-Boot
|
||||
# environments env1 and env2, respectively. The vendor root file systems
|
||||
# are in volumes 2 (rootfs_0) and 3 (rootfs_1). Drop the two roots and
|
||||
# explicitly use rootfs_0 as a boot partition that contains the dtb and the
|
||||
# OpenWrt kernel. This is because the vendor U-Boot expects to find them there.
|
||||
# Then continue upgrade with the default method - a SquashFS rootfs will be
|
||||
# installed and the rest of UBI will be used as an overlay.
|
||||
|
||||
# The 'kernel' inside the sysupgrage.tar is an UBIFS image that contains
|
||||
# /boot/dtb and /boot/kernel. The 'root' is an OpenWrt SquashFS root
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/upgrade/nand.sh
|
||||
|
||||
dna_do_upgrade () {
|
||||
tar -xaf $1
|
||||
|
||||
# get the size of the new bootfs
|
||||
local _bootfs_size=$(wc -c < ./sysupgrade-dna_valokuitu-plus-ex400/kernel)
|
||||
[ -n "$_bootfs_size" -a "$_bootfs_size" -gt "0" ] || nand_do_upgrade_failed
|
||||
|
||||
# remove existing rootfses and recreate rootfs_0
|
||||
ubirmvol /dev/ubi0 --name=rootfs_0 > /dev/null 2>&1
|
||||
ubirmvol /dev/ubi0 --name=rootfs_1 > /dev/null 2>&1
|
||||
ubirmvol /dev/ubi0 --name=rootfs > /dev/null 2>&1
|
||||
ubirmvol /dev/ubi0 --name=rootfs_data > /dev/null 2>&1
|
||||
ubimkvol /dev/ubi0 --type=static --size=${_bootfs_size} --name=rootfs_0
|
||||
|
||||
# update the rootfs_0 contents
|
||||
local _kern_ubivol=$( nand_find_volume "ubi0" "rootfs_0" )
|
||||
ubiupdatevol /dev/${_kern_ubivol} sysupgrade-dna_valokuitu-plus-ex400/kernel
|
||||
|
||||
fw_setenv root_vol rootfs_0
|
||||
fw_setenv boot_cnt_primary 0
|
||||
fw_setenv boot_cnt_alt 0
|
||||
|
||||
# proceed to upgrade the default way
|
||||
CI_KERNPART=none
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
88
target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
Normal file
88
target/linux/ramips/mt7621/base-files/lib/upgrade/iodata.sh
Normal file
@@ -0,0 +1,88 @@
|
||||
#
|
||||
# Copyright (C) 2019 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
iodata_mstc_prepare_fail() {
|
||||
echo "failed to check and prepare the environment, rebooting..."
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
# read/write 1byte in mtd device
|
||||
#
|
||||
# parameters:
|
||||
# $1: target mtd device ("/dev/mtdblockN")
|
||||
# $2: offset of target value (decimal or hex)
|
||||
# $3: value to set (decimal or hex, don't set when reading)
|
||||
iodata_mstc_rw_byte() {
|
||||
local mtd="$1"
|
||||
local offset="$2"
|
||||
local setval="$3"
|
||||
local _val=$(hexdump -s $offset -n 1 -e '"%d"' $mtd)
|
||||
|
||||
if [ -z "$setval" ]; then
|
||||
echo $_val
|
||||
return 0
|
||||
fi
|
||||
|
||||
# decimal or hex -> decimal
|
||||
setval=$((setval))
|
||||
[ "$_val" = "$setval" ] && return 0
|
||||
setval="$(printf '%02x' $setval)"
|
||||
|
||||
if ! (printf "\x$setval" | dd bs=1 seek=$((offset)) conv=notrunc of=$mtd 2>/dev/null); then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# set flag in mtd device on I-O DATA devices manufactured by MSTC
|
||||
# (MitraStar Technology Corp.)
|
||||
#
|
||||
# parameters:
|
||||
# $1: parameter name
|
||||
# $2: mtd name contains target flag
|
||||
# $3: offset of flag
|
||||
# $4: valid flag values ("n,n,...", ex:"0,1" or "1,2")
|
||||
# $5: value to set to the flag
|
||||
iodata_mstc_set_flag() {
|
||||
local name="$1"
|
||||
local mtddev="$(find_mtd_part $2)"
|
||||
local offset="$3"
|
||||
local valid="$4"
|
||||
local setval="$5"
|
||||
|
||||
if [ -z "$offset" ]; then
|
||||
echo "no $name flag offset provided"
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
|
||||
if [ -z "$mtddev" ]; then
|
||||
echo "cannot find \"$2\" mtd partition"
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
|
||||
local flag=$(iodata_mstc_rw_byte "$mtddev" "$offset")
|
||||
local _tmp
|
||||
for i in ${valid//,/ }; do
|
||||
if [ "$flag" = "$((i))" ]; then
|
||||
_tmp=$flag
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$_tmp" ]; then
|
||||
echo "failed to get valid $name flag, please check the value at $offset in $mtddev"
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
echo "current: $name => $flag"
|
||||
|
||||
if [ "$flag" != "$((setval))" ]; then
|
||||
if ! iodata_mstc_rw_byte "$mtddev" "$offset" "$setval"; then
|
||||
echo "failed to set \"$name\" flag"
|
||||
iodata_mstc_prepare_fail
|
||||
fi
|
||||
echo " --> set \"$name\" flag to $setval (valid: $valid)"
|
||||
fi
|
||||
}
|
||||
222
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
Executable file
222
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
Executable file
@@ -0,0 +1,222 @@
|
||||
#
|
||||
# Copyright (C) 2010 OpenWrt.org
|
||||
#
|
||||
|
||||
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() {
|
||||
local board=$(board_name)
|
||||
local magic="$(get_magic_long "$1")"
|
||||
|
||||
[ "$#" -gt 1 ] && return 1
|
||||
|
||||
case "$board" in
|
||||
buffalo,wsr-2533dhpl2|\
|
||||
buffalo,wsr-2533dhpls)
|
||||
buffalo_check_image "$board" "$magic" "$1" || return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
local board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
alfa-network,quad-e4g)
|
||||
[ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\
|
||||
[ -n "$(find_mtd_part backup)" ] && {
|
||||
PART_NAME=backup
|
||||
if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then
|
||||
fw_setenv bootactive 2 || exit 1
|
||||
else
|
||||
fw_setenv bootactive 1 || exit 1
|
||||
fi
|
||||
}
|
||||
;;
|
||||
ampedwireless,ally-00x19k|\
|
||||
ampedwireless,ally-r1900k)
|
||||
if [ "$(fw_printenv --lock / -n bootImage 2>/dev/null)" != "0" ]; then
|
||||
fw_setenv --lock / bootImage 0 || exit 1
|
||||
fi
|
||||
;;
|
||||
iptime,ax2004m)
|
||||
if [ "$(fw_printenv -n boot_from 2>/dev/null)" != "firmware1" ]; then
|
||||
fw_setenv boot_from firmware1 || exit 1
|
||||
fi
|
||||
;;
|
||||
mikrotik,ltap-2hnd|\
|
||||
mikrotik,routerboard-750gr3|\
|
||||
mikrotik,routerboard-760igs|\
|
||||
mikrotik,routerboard-m11g|\
|
||||
mikrotik,routerboard-m33g)
|
||||
[ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
|
||||
;;
|
||||
asus,rt-ac65p|\
|
||||
asus,rt-ac85p)
|
||||
echo "Backing up firmware"
|
||||
dd if=/dev/mtd4 bs=1024 count=4096 > /tmp/backup_firmware.bin
|
||||
dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
|
||||
mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$board" in
|
||||
ampedwireless,ally-00x19k|\
|
||||
ampedwireless,ally-r1900k|\
|
||||
arcadyan,we420223-99|\
|
||||
asus,rt-ac65p|\
|
||||
asus,rt-ac85p|\
|
||||
asus,rt-ax53u|\
|
||||
asus,rt-ax54|\
|
||||
asus,4g-ax56|\
|
||||
beeline,smartbox-flash|\
|
||||
beeline,smartbox-giga|\
|
||||
beeline,smartbox-pro|\
|
||||
beeline,smartbox-turbo|\
|
||||
beeline,smartbox-turbo-plus|\
|
||||
belkin,rt1800|\
|
||||
dlink,covr-x1860-a1|\
|
||||
dlink,dap-x1860-a1|\
|
||||
dlink,dir-1960-a1|\
|
||||
dlink,dir-2055-a1|\
|
||||
dlink,dir-2150-a1|\
|
||||
dlink,dir-2150-r1|\
|
||||
dlink,dir-2640-a1|\
|
||||
dlink,dir-2660-a1|\
|
||||
dlink,dir-3040-a1|\
|
||||
dlink,dir-3060-a1|\
|
||||
dlink,dir-853-a3|\
|
||||
elecom,wmc-x1800gst|\
|
||||
elecom,wsc-x1800gs|\
|
||||
etisalat,s3|\
|
||||
h3c,tx1800-plus|\
|
||||
h3c,tx1801-plus|\
|
||||
h3c,tx1806|\
|
||||
haier,har-20s2u1|\
|
||||
hiwifi,hc5962|\
|
||||
gemtek,wvrtm-127acn|\
|
||||
gemtek,wvrtm-130acn|\
|
||||
iptime,a3004t|\
|
||||
iptime,ax2004m|\
|
||||
iptime,t5004|\
|
||||
jcg,q20|\
|
||||
keenetic,kn-3510|\
|
||||
linksys,e5600|\
|
||||
linksys,e7350|\
|
||||
linksys,ea6350-v4|\
|
||||
linksys,ea7300-v1|\
|
||||
linksys,ea7300-v2|\
|
||||
linksys,ea7500-v2|\
|
||||
linksys,ea8100-v1|\
|
||||
linksys,ea8100-v2|\
|
||||
mts,wg430223|\
|
||||
netgear,eax12|\
|
||||
netgear,r6220|\
|
||||
netgear,r6260|\
|
||||
netgear,r6350|\
|
||||
netgear,r6700-v2|\
|
||||
netgear,r6800|\
|
||||
netgear,r6850|\
|
||||
netgear,r6900-v2|\
|
||||
netgear,r7200|\
|
||||
netgear,r7450|\
|
||||
netgear,wac104|\
|
||||
netgear,wac124|\
|
||||
netgear,wax202|\
|
||||
netgear,wax214v2|\
|
||||
netis,n6|\
|
||||
netis,wf2881|\
|
||||
raisecom,msg1500-x-00|\
|
||||
rostelecom,rt-fe-1a|\
|
||||
rostelecom,rt-sf-1|\
|
||||
sercomm,na502|\
|
||||
sercomm,na502s|\
|
||||
sim,simax1800t|\
|
||||
tplink,ec330-g5u-v1|\
|
||||
wifire,s1500-nbn|\
|
||||
xiaomi,mi-router-3g|\
|
||||
xiaomi,mi-router-3-pro|\
|
||||
xiaomi,mi-router-4|\
|
||||
xiaomi,mi-router-ac2100|\
|
||||
xiaomi,mi-router-cr6606|\
|
||||
xiaomi,mi-router-cr6608|\
|
||||
xiaomi,mi-router-cr6609|\
|
||||
xiaomi,redmi-router-ac2100|\
|
||||
z-router,zr-2660|\
|
||||
zyxel,nwa50ax|\
|
||||
zyxel,nwa55axe)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
buffalo,wsr-2533dhpl2|\
|
||||
buffalo,wsr-2533dhpls)
|
||||
buffalo_do_upgrade "$1"
|
||||
;;
|
||||
dna,valokuitu-plus-ex400)
|
||||
dna_do_upgrade "$1"
|
||||
;;
|
||||
elecom,wrc-x1800gs)
|
||||
[ "$(fw_printenv -n bootmenu_delay)" != "0" ] || \
|
||||
fw_setenv bootmenu_delay 3
|
||||
iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
iodata,wn-ax1167gr2|\
|
||||
iodata,wn-ax2033gr|\
|
||||
iodata,wn-dx1167r|\
|
||||
iodata,wn-dx2033gr)
|
||||
iodata_mstc_set_flag "debugflag" "factory" "0xfe75" "0,1" "1"
|
||||
iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
iodata,wn-deax1800gr)
|
||||
iodata_mstc_set_flag "bootnum" "working" "0x4" "0,1" "0"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
iodata,wn-dx1200gr)
|
||||
iodata_mstc_set_flag "debugflag" "factory" "0x1fe75" "0,1" "1"
|
||||
iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
tplink,er605-v2)
|
||||
echo "Upgrading tplink,er605-v2"
|
||||
CI_UBIPART="firmware"
|
||||
CI_KERNPART="kernel"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
ubnt,edgerouter-x|\
|
||||
ubnt,edgerouter-x-sfp)
|
||||
platform_upgrade_ubnt_erx "$1"
|
||||
;;
|
||||
zyxel,lte3301-plus|\
|
||||
zyxel,lte5398-m904|\
|
||||
zyxel,nr7101)
|
||||
fw_setenv CheckBypass 0
|
||||
fw_setenv Image1Stable 0
|
||||
[ "$(fw_printenv -n BootingFlag)" = "0" ] || fw_setenv BootingFlag 0
|
||||
CI_KERNPART="Kernel"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,wap6805)
|
||||
local kernel2_mtd="$(find_mtd_part Kernel2)"
|
||||
[ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\
|
||||
[ "$(hexdump -n 4 -s 104 -e '"%x"' $kernel2_mtd)" != "0" ] &&\
|
||||
dd bs=4 count=1 seek=26 conv=notrunc if=/dev/zero of=$kernel2_mtd 2>/dev/null &&\
|
||||
echo "Kernel2 sequence number was reset to 0"
|
||||
CI_KERNPART="Kernel"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,wsm20)
|
||||
zyxel_mstc_upgrade_prepare
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
53
target/linux/ramips/mt7621/base-files/lib/upgrade/ubnt.sh
Normal file
53
target/linux/ramips/mt7621/base-files/lib/upgrade/ubnt.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
#Note: this code also uses some functions from nand.sh, but it is expected to be run by nand.sh, so we are not
|
||||
#sourcing it explicitly here
|
||||
|
||||
UBNT_ERX_KERNEL_INDEX_OFFSET=160
|
||||
|
||||
ubnt_update_kernel_flag() {
|
||||
local factory_mtd=$1
|
||||
local kernel_index=$(hexdump -s $UBNT_ERX_KERNEL_INDEX_OFFSET -n 1 -e '/1 "%X "' ${factory_mtd})
|
||||
|
||||
if [ $kernel_index = "0" ]; then
|
||||
echo "Kernel flag already set to kernel slot 1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! (echo -e "\x00" | dd of=${factory_mtd} bs=1 count=1 seek=$UBNT_ERX_KERNEL_INDEX_OFFSET); then
|
||||
echo 'Failed to update kernel bootup index' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
platform_upgrade_ubnt_erx() {
|
||||
local factory_mtd=$(find_mtd_part factory)
|
||||
if [ -z "$factory_mtd" ]; then
|
||||
echo "cannot find factory partition" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Remove volume possibly left over from stock firmware
|
||||
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
if [ -z "$ubidev" ]; then
|
||||
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
|
||||
if [ -z "$mtdnum" ]; then
|
||||
echo "cannot find ubi mtd partition $CI_UBIPART" >&2
|
||||
exit 1
|
||||
fi
|
||||
ubiattach -m "$mtdnum"
|
||||
sync
|
||||
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||
fi
|
||||
if [ -n "$ubidev" ]; then
|
||||
local troot_ubivol="$( nand_find_volume $ubidev troot )"
|
||||
[ -n "$troot_ubivol" ] && ubirmvol /dev/$ubidev -N troot || true
|
||||
fi
|
||||
|
||||
ubnt_update_kernel_flag ${factory_mtd} || exit 1
|
||||
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
39
target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh
Normal file
39
target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright (C) 2023 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
zyxel_mstc_prepare_fail() {
|
||||
echo "failed to check and prepare the environment, rebooting..."
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
zyxel_mstc_upgrade_prepare() {
|
||||
local persist_mtd="$(find_mtd_part persist)"
|
||||
local firmware_mtd="$(find_mtd_part firmware)"
|
||||
|
||||
if [ -z "$persist_mtd" ] || [ -z "$firmware_mtd" ]; then
|
||||
echo 'cannot find mtd partition(s) "persist" or "firmware"'
|
||||
zyxel_mstc_prepare_fail
|
||||
fi
|
||||
|
||||
local bootnum=$(hexdump -s 4 -n 1 -e '"%x"' ${persist_mtd})
|
||||
|
||||
if [ "$bootnum" != "1" ] && [ "$bootnum" != "2" ]; then
|
||||
echo "failed to get bootnum, please check the value at 0x4 in ${persist_mtd}"
|
||||
zyxel_mstc_prepare_fail
|
||||
fi
|
||||
echo "current: bootnum => ${bootnum}"
|
||||
|
||||
[ "$(fw_printenv -n bootmenu_delay)" = "3" ] || fw_setenv bootmenu_delay 3
|
||||
|
||||
if [ "$bootnum" = "2" ]; then
|
||||
if ! ( echo -ne "\x01" | dd of=${persist_mtd} count=1 bs=1 seek=4 conv=notrunc 2>/dev/null ); then
|
||||
echo "failed to set new boot partition"
|
||||
zyxel_mstc_prepare_fail
|
||||
fi
|
||||
echo "### switch to 1st os-image on next boot ###"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user