mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-07-02 22:57:07 +08:00
152 lines
3.1 KiB
Bash
152 lines
3.1 KiB
Bash
PART_NAME=firmware
|
|
REQUIRE_IMAGE_METADATA=1
|
|
|
|
RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head seq'
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
linksys_mx_pre_upgrade() {
|
|
local setenv_script="/tmp/fw_env_upgrade"
|
|
|
|
CI_UBIPART="rootfs"
|
|
boot_part="$(fw_printenv -n boot_part)"
|
|
if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then
|
|
if [ "$boot_part" -eq "2" ]; then
|
|
CI_KERNPART="alt_kernel"
|
|
CI_UBIPART="alt_rootfs"
|
|
fi
|
|
else
|
|
if [ "$boot_part" -eq "1" ]; then
|
|
echo "boot_part 2" >> $setenv_script
|
|
CI_KERNPART="alt_kernel"
|
|
CI_UBIPART="alt_rootfs"
|
|
else
|
|
echo "boot_part 1" >> $setenv_script
|
|
fi
|
|
fi
|
|
|
|
boot_part_ready="$(fw_printenv -n boot_part_ready)"
|
|
if [ "$boot_part_ready" -ne "3" ]; then
|
|
echo "boot_part_ready 3" >> $setenv_script
|
|
fi
|
|
|
|
auto_recovery="$(fw_printenv -n auto_recovery)"
|
|
if [ "$auto_recovery" != "yes" ]; then
|
|
echo "auto_recovery yes" >> $setenv_script
|
|
fi
|
|
|
|
if [ -f "$setenv_script" ]; then
|
|
fw_setenv -s $setenv_script || {
|
|
echo "failed to update U-Boot environment"
|
|
return 1
|
|
}
|
|
fi
|
|
}
|
|
|
|
platform_check_image() {
|
|
return 0;
|
|
}
|
|
|
|
platform_pre_upgrade() {
|
|
case "$(board_name)" in
|
|
xiaomi,ax6000)
|
|
xiaomi_initramfs_prepare
|
|
;;
|
|
esac
|
|
}
|
|
|
|
platform_do_upgrade() {
|
|
case "$(board_name)" in
|
|
glinet,gl-b3000)
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
jdcloud,re-cs-03)
|
|
CI_KERNPART="0:HLOS"
|
|
CI_ROOTPART="rootfs"
|
|
emmc_do_upgrade "$1"
|
|
;;
|
|
linksys,mr5500|\
|
|
linksys,mx2000|\
|
|
linksys,mx5500|\
|
|
linksys,spnmx56)
|
|
linksys_mx_pre_upgrade "$1"
|
|
remove_oem_ubi_volume squashfs
|
|
nand_do_upgrade "$1"
|
|
;;
|
|
xiaomi,ax6000)
|
|
# 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"
|
|
;;
|
|
*)
|
|
default_do_upgrade "$1"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
platform_copy_config() {
|
|
case "$(board_name)" in
|
|
jdcloud,re-cs-03)
|
|
emmc_copy_config
|
|
;;
|
|
esac
|
|
return 0;
|
|
}
|