mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
fix
This commit is contained in:
parent
c97e0555e1
commit
b89c4f4039
12 changed files with 252 additions and 0 deletions
0
root/target/linux/ipq40xx/base-files/etc/board.d/01_leds
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/board.d/01_leds
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/board.d/03_gpio_switches
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/hotplug.d/net/21_adjust_network
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/hotplug.d/net/21_adjust_network
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/init.d/bootcount
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/etc/init.d/bootcount
Normal file → Executable file
5
root/target/linux/ipq40xx/base-files/etc/inittab
Executable file
5
root/target/linux/ipq40xx/base-files/etc/inittab
Executable file
|
@ -0,0 +1,5 @@
|
|||
# Copyright (c) 2013 The Linux Foundation. All rights reserved.
|
||||
::sysinit:/etc/init.d/rcS S boot
|
||||
::shutdown:/etc/init.d/rcS K shutdown
|
||||
ttyMSM0::askfirst:/usr/libexec/login.sh
|
||||
ttyMSM1::askfirst:/usr/libexec/login.sh
|
19
root/target/linux/ipq40xx/base-files/etc/uci-defaults/04_led_migration
Executable file
19
root/target/linux/ipq40xx/base-files/etc/uci-defaults/04_led_migration
Executable file
|
@ -0,0 +1,19 @@
|
|||
. /lib/functions/migrations.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
engenius,emr3500)
|
||||
migrate_leds "emr3500:="
|
||||
;;
|
||||
engenius,ens620ext|\
|
||||
zyxel,nbg6617)
|
||||
migrate_leds ":wlan2G=:wlan2g" ":wlan5G=:wlan5g"
|
||||
;;
|
||||
esac
|
||||
|
||||
remove_devicename_leds
|
||||
|
||||
migrations_apply system
|
||||
|
||||
exit 0
|
0
root/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/lib/preinit/06_set_preinit_iface_ipq40xx.sh
Normal file → Executable file
122
root/target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Executable file
122
root/target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Executable file
|
@ -0,0 +1,122 @@
|
|||
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/devices/virtual/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_get_root_magic() {
|
||||
(get_image "$@" | dd skip=786432 bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null
|
||||
}
|
||||
|
||||
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
|
||||
nand_upgrade_tar "$1"
|
||||
}
|
||||
|
||||
[ "$magic_long" = "27051956" ] && {
|
||||
# This magic is for a uImage (which is a sysupgrade image)
|
||||
# check firmwares' rootfs types
|
||||
local oldroot="$(linksys_get_root_magic "$target_mtd")"
|
||||
local newroot="$(linksys_get_root_magic "$1")"
|
||||
|
||||
if [ "$newroot" = "55424923" ] && [ "$oldroot" = "55424923" ]; then
|
||||
# we're upgrading from a firmware with UBI to one with UBI
|
||||
# erase everything to be safe
|
||||
# - Is that really needed? Won't remove (or comment) the if,
|
||||
# because it may be needed in a future device.
|
||||
#mtd erase $part_label
|
||||
#get_image "$1" | mtd -n write - $part_label
|
||||
echo "writing \"$1\" UBI image to \"$part_label\" (UBI)..."
|
||||
get_image "$1" | mtd write - "$part_label"
|
||||
else
|
||||
echo "writing \"$1\" image to \"$part_label\""
|
||||
get_image "$1" | mtd write - "$part_label"
|
||||
fi
|
||||
}
|
||||
}
|
106
root/target/linux/ipq40xx/base-files/lib/upgrade/openmesh.sh
Executable file
106
root/target/linux/ipq40xx/base-files/lib/upgrade/openmesh.sh
Executable file
|
@ -0,0 +1,106 @@
|
|||
# The U-Boot loader of the OpenMesh devices requires image sizes and
|
||||
# checksums to be provided in the U-Boot environment.
|
||||
# The OpenMesh 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_openmesh() {
|
||||
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
|
||||
openmesh,a42)
|
||||
primary_kernel_mtd=8
|
||||
;;
|
||||
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
|
||||
}
|
||||
}
|
0
root/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Normal file → Executable file
0
root/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue