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:
13
target/linux/ipq806x/base-files/lib/preinit/04_reorder_eth
Normal file
13
target/linux/ipq806x/base-files/lib/preinit/04_reorder_eth
Normal file
@@ -0,0 +1,13 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
preinit_reorder_eth() {
|
||||
case $(board_name) in
|
||||
ubnt,unifi-ac-hd)
|
||||
ip link set eth0 name ethtmp
|
||||
ip link set eth1 name eth0
|
||||
ip link set ethtmp name eth1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_reorder_eth
|
||||
54
target/linux/ipq806x/base-files/lib/upgrade/asrock.sh
Normal file
54
target/linux/ipq806x/base-files/lib/upgrade/asrock.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
. "$IPKG_INSTROOT/lib/functions.sh"
|
||||
|
||||
asrock_bootconfig_mangle() {
|
||||
local mtdnum="$(find_mtd_index 0:bootconfig)"
|
||||
|
||||
if [ -z "$mtdnum" ]; then
|
||||
echo "cannot find bootconfig mtd partition"
|
||||
return 1
|
||||
fi
|
||||
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k
|
||||
|
||||
local partition_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
|
||||
local upgrade_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"
|
||||
|
||||
if [ $1 = "bootcheck" ]; then
|
||||
if [ ! -s $upgrade_byte ]; then
|
||||
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
elif [ $1 = "sysupgrade" ]; then
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
|
||||
fi
|
||||
|
||||
if [ -s $partition_byte ]; then
|
||||
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
|
||||
else
|
||||
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
|
||||
fi
|
||||
|
||||
mtd write /tmp/mtd$mtdnum /dev/mtd$mtdnum
|
||||
return 0
|
||||
}
|
||||
|
||||
asrock_upgrade_prepare() {
|
||||
local ubidev="$( nand_find_ubi ubi )"
|
||||
|
||||
#Set upgrade flag. If something goes wrong, router will boot with
|
||||
#factory firmware.
|
||||
asrock_bootconfig_mangle 'sysupgrade'
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "cannot find bootconfig mtd partition"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Just delete these partitions if present and use
|
||||
# OpenWrt's standard names for those.
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs &> /dev/null || true
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
|
||||
}
|
||||
44
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
44
target/linux/ipq806x/base-files/lib/upgrade/buffalo.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (C) 2018 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# The mtd partition 'ubi' and 'rootfs_1' on NAND flash are os-image
|
||||
# partitions. These partitions are called as "Bank1/Bank2" in U-Boot
|
||||
# on WXR-2533DHP, and they are checked conditions when booting.
|
||||
# Then, U-Boot checks kernel and rootfs volumes in ubi, but U-Boot
|
||||
# needs "ubi_rootfs" as rootfs volume name. And, U-Boot checks the
|
||||
# checksum at the end of rootfs (ubi_rootfs).
|
||||
# When U-Boot writes os-image into the Bank, only kernel, rootfs
|
||||
# (ubi_rootfs) and rootfs_data (ubi_rootfs_data) volumes are wrote
|
||||
# into the Bank. (not full ubi image)
|
||||
#
|
||||
# == U-Boot Behaviors ==
|
||||
# - Bank1/Bank2 images are good, images are different
|
||||
# -> writes os-image to Bank1 from Bank2
|
||||
# (this behavior is used to firmware upgrade in stock firmware)
|
||||
# - Bank1 image is broken (or checksum error)
|
||||
# -> writes os-image to Bank1 from Bank2
|
||||
# - Bank2 image is broken (or checksum error)
|
||||
# -> writes os-image to Bank2 from Bank1
|
||||
# - Bank1/Bank2 images are broken (or checksum error)
|
||||
# -> start tftp
|
||||
|
||||
buffalo_upgrade_prepare_ubi() {
|
||||
local ubidev="$( nand_find_ubi ubi )"
|
||||
local mtdnum2="$( find_mtd_index rootfs_1 )"
|
||||
|
||||
if [ ! "$mtdnum2" ]; then
|
||||
echo "cannot find second ubi mtd partition rootfs_1"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ubidev2="$( nand_find_ubi rootfs_1 )"
|
||||
if [ ! "$ubidev2" ] && [ -n "$mtdnum2" ]; then
|
||||
ubiattach -m "$mtdnum2"
|
||||
ubidev2="$( nand_find_ubi rootfs_1 )"
|
||||
fi
|
||||
|
||||
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
|
||||
ubirmvol /dev/$ubidev2 -N kernel &> /dev/null || true
|
||||
}
|
||||
107
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
107
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
Normal file
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
#
|
||||
|
||||
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
|
||||
kernel1|rootfs1)
|
||||
cur_boot_part=1
|
||||
;;
|
||||
kernel2|rootfs2)
|
||||
cur_boot_part=2
|
||||
;;
|
||||
esac
|
||||
>&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \
|
||||
"${cur_boot_part}" "${mtd_ubi0}"
|
||||
fi
|
||||
|
||||
case $cur_boot_part in
|
||||
1)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 2
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "kernel2"
|
||||
return
|
||||
;;
|
||||
2)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 1
|
||||
auto_recovery yes
|
||||
EOF
|
||||
printf "kernel1"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_do_upgrade_linksys() {
|
||||
local magic_long="$(get_magic_long "$1")"
|
||||
|
||||
mkdir -p /var/lock
|
||||
local part_label="$(linksys_get_target_firmware)"
|
||||
touch /var/lock/fw_printenv.lock
|
||||
|
||||
if [ ! -n "$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" = "kernel1" ]
|
||||
then
|
||||
CI_UBIPART="rootfs1"
|
||||
else
|
||||
CI_UBIPART="rootfs2"
|
||||
fi
|
||||
|
||||
|
||||
# remove "squashfs" vol (in case we are flashing over a stock image, which is also UBI)
|
||||
|
||||
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
|
||||
|
||||
local squash_ubivol="$( nand_find_volume $ubidev squashfs )"
|
||||
|
||||
# kill volume
|
||||
[ "$squash_ubivol" ] && ubirmvol /dev/$ubidev -N squashfs || true
|
||||
fi
|
||||
|
||||
|
||||
# complete std upgrade
|
||||
if nand_upgrade_tar "$1" ; then
|
||||
nand_do_upgrade_success
|
||||
else
|
||||
nand_do_upgrade_failed
|
||||
fi
|
||||
|
||||
}
|
||||
[ "$magic_long" = "27051956" ] && {
|
||||
get_image "$1" | mtd write - $part_label
|
||||
}
|
||||
}
|
||||
99
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
99
target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Normal file
@@ -0,0 +1,99 @@
|
||||
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() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
case "$(board_name)" in
|
||||
arris,tr4400-v2 |\
|
||||
askey,rt4230w-rev6 |\
|
||||
compex,wpq864|\
|
||||
fortinet,fap-421e|\
|
||||
linksys,e8350-v1|\
|
||||
netgear,d7800 |\
|
||||
netgear,r7500 |\
|
||||
netgear,r7500v2 |\
|
||||
netgear,r7800 |\
|
||||
netgear,xr450 |\
|
||||
netgear,xr500 |\
|
||||
nokia,ac400i |\
|
||||
qcom,ipq8064-ap148 |\
|
||||
qcom,ipq8064-ap161)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
asrock,g10)
|
||||
asrock_upgrade_prepare
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
buffalo,wxr-2533dhp)
|
||||
buffalo_upgrade_prepare_ubi
|
||||
CI_ROOTPART="ubi_rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
edgecore,ecw5410)
|
||||
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"
|
||||
;;
|
||||
extreme,ap3935)
|
||||
CI_ROOTPART="nand_flash"
|
||||
CI_KERNPART="PriImg"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
linksys,ea7500-v1 |\
|
||||
linksys,ea8500)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
meraki,mr42 |\
|
||||
meraki,mr52)
|
||||
CI_KERNPART="bootkernel2"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
tplink,ad7200 |\
|
||||
tplink,c2600)
|
||||
PART_NAME="os-image:rootfs"
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
asus,onhub |\
|
||||
tplink,onhub)
|
||||
export_bootdevice
|
||||
export_partdevice CI_ROOTDEV 0
|
||||
CI_KERNPART="kernel"
|
||||
CI_ROOTPART="rootfs"
|
||||
CI_DATAPART="rootfs_data"
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
tplink,vr2600v)
|
||||
MTD_CONFIG_ARGS="-s 0x200000"
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,nbg6817)
|
||||
zyxel_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
asus,onhub |\
|
||||
tplink,onhub)
|
||||
emmc_copy_config
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
124
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
124
target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh
Normal file
@@ -0,0 +1,124 @@
|
||||
#
|
||||
# Copyright (C) 2016 lede-project.org
|
||||
#
|
||||
|
||||
zyxel_get_rootfs() {
|
||||
local rootfsdev
|
||||
|
||||
if read cmdline < /proc/cmdline; then
|
||||
case "$cmdline" in
|
||||
*root=*)
|
||||
rootfsdev="${cmdline##*root=}"
|
||||
rootfsdev="${rootfsdev%% *}"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${rootfsdev}"
|
||||
fi
|
||||
}
|
||||
|
||||
zyxel_do_flash() {
|
||||
local tar_file=$1
|
||||
local kernel=$2
|
||||
local rootfs=$3
|
||||
local dualflagmtd=$4
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# flashing successful, toggle the dualflag
|
||||
case "$rootfs" in
|
||||
"/dev/mmcblk0p5")
|
||||
printf "\xff" >$dualflagmtd
|
||||
;;
|
||||
"/dev/mmcblk0p8")
|
||||
printf "\x01" >$dualflagmtd
|
||||
;;
|
||||
esac
|
||||
|
||||
# Cleanup
|
||||
losetup -d $loopdev >/dev/null 2>&1
|
||||
sync
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
zyxel_do_upgrade() {
|
||||
local tar_file="$1"
|
||||
local board=$(board_name)
|
||||
local rootfs="$(zyxel_get_rootfs)"
|
||||
local kernel=
|
||||
|
||||
[ -b "${rootfs}" ] || return 1
|
||||
case "$board" in
|
||||
zyxel,nbg6817)
|
||||
local dualflagmtd="$(find_mtd_part 0:dual_flag)"
|
||||
[ -b $dualflagmtd ] || return 1
|
||||
|
||||
case "$rootfs" in
|
||||
"/dev/mmcblk0p5")
|
||||
# booted from the primary partition set
|
||||
# write to the alternative set
|
||||
kernel="/dev/mmcblk0p7"
|
||||
rootfs="/dev/mmcblk0p8"
|
||||
;;
|
||||
"/dev/mmcblk0p8")
|
||||
# booted from the alternative partition set
|
||||
# write to the primary set
|
||||
kernel="/dev/mmcblk0p4"
|
||||
rootfs="/dev/mmcblk0p5"
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
|
||||
|
||||
nand_do_upgrade "$1"
|
||||
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user