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,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
preinit_mount_factory_data() {
|
||||
local mtd_path
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
case $(board_name) in
|
||||
tplink,eap660hd-v1)
|
||||
mtd_path=$(find_mtd_chardev "factory_data")
|
||||
ubiattach --dev-path="$mtd_path" --devn=1
|
||||
mkdir /tmp/factory_data
|
||||
mount -o ro,noatime -t ubifs ubi1:ubi_factory_data /tmp/factory_data
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_mount_factory_data
|
||||
@@ -0,0 +1,55 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
# Prepare UBI devices for OpenWrt installation
|
||||
# - rootfs (mtd22)
|
||||
# - remove "ubi_rootfs" volume (rootfs on stock)
|
||||
# - remove "fw_hash" volume (firmware hash)
|
||||
# - user_property (mtd24)
|
||||
# - remove "user_property_ubi" volume (user configuration)
|
||||
# - remove "extra_property" volume (gzipped syslog)
|
||||
buffalo_upgrade_prepare() {
|
||||
local ubi_rootdev ubi_propdev
|
||||
|
||||
if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \
|
||||
! ubi_propdev="$(nand_attach_ubi user_property)"; then
|
||||
echo "failed to attach UBI volume \"rootfs\" or \"user_property\", rebooting..."
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
ubirmvol /dev/$ubi_rootdev -N ubi_rootfs &> /dev/null || true
|
||||
ubirmvol /dev/$ubi_rootdev -N fw_hash &> /dev/null || true
|
||||
|
||||
ubirmvol /dev/$ubi_propdev -N user_property_ubi &> /dev/null || true
|
||||
ubirmvol /dev/$ubi_propdev -N extra_property &> /dev/null || true
|
||||
}
|
||||
|
||||
# Re-create small dummy ubi_rootfs volume and update
|
||||
# fw_hash volume to pass the checking by U-Boot
|
||||
# - rootfs (mtd22)
|
||||
# - re-create "ubi_rootfs" volume
|
||||
# - re-create and update "fw_hash" volume
|
||||
# - rootfs_recover (mtd23)
|
||||
# - update "fw_hash" volume
|
||||
buffalo_upgrade_optvol() {
|
||||
local ubi_rootdev ubi_rcvrdev
|
||||
local hashvol_root hashvol_rcvr
|
||||
|
||||
if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \
|
||||
! ubi_rcvrdev="$(nand_attach_ubi rootfs_recover)"; then
|
||||
echo "failed to attach UBI volume \"rootfs\" or \"rootfs_recover\", rebooting..."
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
ubimkvol /dev/$ubi_rootdev -N ubi_rootfs -S 1
|
||||
ubimkvol /dev/$ubi_rootdev -N fw_hash -S 1 -t static
|
||||
|
||||
if ! hashvol_root="$(nand_find_volume $ubi_rootdev fw_hash)" || \
|
||||
! hashvol_rcvr="$(nand_find_volume $ubi_rcvrdev fw_hash)"; then
|
||||
echo "\"fw_hash\" volume in \"rootfs\" or \"rootfs_recover\" not found, rebooting..."
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
echo -n "00000000000000000000000000000000" > /tmp/dummyhash.txt
|
||||
ubiupdatevol /dev/$hashvol_root /tmp/dummyhash.txt
|
||||
ubiupdatevol /dev/$hashvol_rcvr /tmp/dummyhash.txt
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
PART_NAME=firmware
|
||||
REQUIRE_IMAGE_METADATA=1
|
||||
|
||||
RAMFS_COPY_BIN='fw_printenv fw_setenv head'
|
||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||
|
||||
xiaomi_initramfs_prepare() {
|
||||
# Wipe UBI if running initramfs
|
||||
[ "$(rootfs_type)" = "tmpfs" ] || return 0
|
||||
|
||||
local rootfs_mtdnum="$( find_mtd_index rootfs )"
|
||||
if [ ! "$rootfs_mtdnum" ]; then
|
||||
echo "unable to find mtd partition rootfs"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local kern_mtdnum="$( find_mtd_index ubi_kernel )"
|
||||
if [ ! "$kern_mtdnum" ]; then
|
||||
echo "unable to find mtd partition ubi_kernel"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ubidetach -m "$rootfs_mtdnum"
|
||||
ubiformat /dev/mtd$rootfs_mtdnum -y
|
||||
|
||||
ubidetach -m "$kern_mtdnum"
|
||||
ubiformat /dev/mtd$kern_mtdnum -y
|
||||
}
|
||||
|
||||
asus_initial_setup() {
|
||||
# Remove existing linux and jffs2 volumes
|
||||
[ "$(rootfs_type)" = "tmpfs" ] || return 0
|
||||
|
||||
ubirmvol /dev/ubi0 -N linux
|
||||
ubirmvol /dev/ubi0 -N jffs2
|
||||
}
|
||||
|
||||
remove_oem_ubi_volume() {
|
||||
local oem_volume_name="$1"
|
||||
local oem_ubivol
|
||||
local mtdnum
|
||||
local ubidev
|
||||
|
||||
mtdnum=$(find_mtd_index "$CI_UBIPART")
|
||||
if [ ! "$mtdnum" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
ubidev=$(nand_find_ubi "$CI_UBIPART")
|
||||
if [ ! "$ubidev" ]; then
|
||||
ubiattach --mtdn="$mtdnum"
|
||||
ubidev=$(nand_find_ubi "$CI_UBIPART")
|
||||
fi
|
||||
|
||||
if [ "$ubidev" ]; then
|
||||
oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name")
|
||||
[ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name"
|
||||
fi
|
||||
}
|
||||
|
||||
tplink_get_boot_part() {
|
||||
local cur_boot_part
|
||||
local args
|
||||
|
||||
# Try to find rootfs from kernel arguments
|
||||
read -r args < /proc/cmdline
|
||||
for arg in $args; do
|
||||
local ubi_mtd_arg=${arg#ubi.mtd=}
|
||||
case "$ubi_mtd_arg" in
|
||||
rootfs|rootfs_1)
|
||||
echo "$ubi_mtd_arg"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Fallback to u-boot env (e.g. when running initramfs)
|
||||
cur_boot_part="$(/usr/sbin/fw_printenv -n tp_boot_idx)"
|
||||
case $cur_boot_part in
|
||||
1)
|
||||
echo rootfs_1
|
||||
;;
|
||||
0|*)
|
||||
echo rootfs
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
tplink_do_upgrade() {
|
||||
local new_boot_part
|
||||
|
||||
case $(tplink_get_boot_part) in
|
||||
rootfs)
|
||||
CI_UBIPART="rootfs_1"
|
||||
new_boot_part=1
|
||||
;;
|
||||
rootfs_1)
|
||||
CI_UBIPART="rootfs"
|
||||
new_boot_part=0
|
||||
;;
|
||||
esac
|
||||
|
||||
fw_setenv -s - <<-EOF
|
||||
tp_boot_idx $new_boot_part
|
||||
EOF
|
||||
|
||||
remove_oem_ubi_volume ubi_rootfs
|
||||
nand_do_upgrade "$1"
|
||||
}
|
||||
|
||||
platform_check_image() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
platform_pre_upgrade() {
|
||||
case "$(board_name)" in
|
||||
asus,rt-ax89x)
|
||||
asus_initial_setup
|
||||
;;
|
||||
redmi,ax6|\
|
||||
xiaomi,ax3600|\
|
||||
xiaomi,ax9000)
|
||||
xiaomi_initramfs_prepare
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
case "$(board_name)" in
|
||||
arcadyan,aw1000|\
|
||||
cmcc,rm2-6|\
|
||||
compex,wpq873|\
|
||||
dynalink,dl-wrx36|\
|
||||
edimax,cax1800|\
|
||||
netgear,rax120v2|\
|
||||
netgear,sxr80|\
|
||||
netgear,sxs80|\
|
||||
netgear,wax218|\
|
||||
netgear,wax620|\
|
||||
netgear,wax630)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
asus,rt-ax89x)
|
||||
CI_UBIPART="UBI_DEV"
|
||||
CI_KERNPART="linux"
|
||||
CI_ROOTPART="jffs2"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
buffalo,wxr-5950ax12)
|
||||
CI_KERN_UBIPART="rootfs"
|
||||
CI_ROOT_UBIPART="user_property"
|
||||
buffalo_upgrade_prepare
|
||||
nand_do_flash_file "$1" || nand_do_upgrade_failed
|
||||
nand_do_restore_config || nand_do_upgrade_failed
|
||||
buffalo_upgrade_optvol
|
||||
;;
|
||||
edgecore,eap102)
|
||||
active="$(fw_printenv -n active)"
|
||||
if [ "$active" -eq "1" ]; then
|
||||
CI_UBIPART="rootfs2"
|
||||
else
|
||||
CI_UBIPART="rootfs1"
|
||||
fi
|
||||
# force altbootcmd which handles partition change in u-boot
|
||||
fw_setenv bootcount 3
|
||||
fw_setenv upgrade_available 1
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
linksys,mx4200v1|\
|
||||
linksys,mx4200v2|\
|
||||
linksys,mx5300|\
|
||||
linksys,mx8500)
|
||||
boot_part="$(fw_printenv -n boot_part)"
|
||||
if [ "$boot_part" -eq "1" ]; then
|
||||
fw_setenv boot_part 2
|
||||
CI_KERNPART="alt_kernel"
|
||||
CI_UBIPART="alt_rootfs"
|
||||
else
|
||||
fw_setenv boot_part 1
|
||||
CI_UBIPART="rootfs"
|
||||
fi
|
||||
fw_setenv boot_part_ready 3
|
||||
fw_setenv auto_recovery yes
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
prpl,haze|\
|
||||
qnap,301w)
|
||||
CI_KERNPART="0:HLOS"
|
||||
CI_ROOTPART="rootfs"
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
redmi,ax6|\
|
||||
xiaomi,ax3600|\
|
||||
xiaomi,ax9000)
|
||||
# Make sure that UART is enabled
|
||||
fw_setenv boot_wait on
|
||||
fw_setenv uart_en 1
|
||||
|
||||
# Enforce single partition.
|
||||
fw_setenv flag_boot_rootfs 0
|
||||
fw_setenv flag_last_success 0
|
||||
fw_setenv flag_boot_success 1
|
||||
fw_setenv flag_try_sys1_failed 8
|
||||
fw_setenv flag_try_sys2_failed 8
|
||||
|
||||
# Kernel and rootfs are placed in 2 different UBI
|
||||
CI_KERN_UBIPART="ubi_kernel"
|
||||
CI_ROOT_UBIPART="rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
spectrum,sax1v1k)
|
||||
CI_KERNPART="0:HLOS"
|
||||
CI_ROOTPART="rootfs"
|
||||
CI_DATAPART="rootfs_data"
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
tplink,eap660hd-v1)
|
||||
tplink_do_upgrade "$1"
|
||||
;;
|
||||
yuncore,ax880)
|
||||
active="$(fw_printenv -n active)"
|
||||
if [ "$active" -eq "1" ]; then
|
||||
CI_UBIPART="rootfs_1"
|
||||
else
|
||||
CI_UBIPART="rootfs"
|
||||
fi
|
||||
# force altbootcmd which handles partition change in u-boot
|
||||
fw_setenv bootcount 3
|
||||
fw_setenv upgrade_available 1
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zbtlink,zbt-z800ax)
|
||||
local mtdnum="$(find_mtd_index 0:bootconfig)"
|
||||
local alt_mtdnum="$(find_mtd_index 0:bootconfig1)"
|
||||
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$mtdnum | cut -f 1 -d "|" | head -n1)"
|
||||
# vendor firmware may swap the rootfs partition location, u-boot append: ubi.mtd=rootfs
|
||||
# since we use fixed-partitions, need to force boot from the first rootfs partition
|
||||
if [ "$part_num" -eq "1" ]; then
|
||||
mtd erase /dev/mtd$mtdnum
|
||||
mtd erase /dev/mtd$alt_mtdnum
|
||||
fi
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zte,mf269)
|
||||
CI_KERN_UBIPART="ubi_kernel"
|
||||
CI_ROOT_UBIPART="rootfs"
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
zyxel,nbg7815)
|
||||
local config_mtdnum="$(find_mtd_index 0:bootconfig)"
|
||||
[ -z "$config_mtdnum" ] && reboot
|
||||
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|" | head -n1)"
|
||||
if [ "$part_num" -eq "0" ]; then
|
||||
CI_KERNPART="0:HLOS"
|
||||
CI_ROOTPART="rootfs"
|
||||
else
|
||||
CI_KERNPART="0:HLOS_1"
|
||||
CI_ROOTPART="rootfs_1"
|
||||
fi
|
||||
emmc_do_upgrade "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
prpl,haze|\
|
||||
qnap,301w|\
|
||||
spectrum,sax1v1k|\
|
||||
zyxel,nbg7815)
|
||||
emmc_copy_config
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Reference in New Issue
Block a user