6417eb1a3a76d982c3b80a109f7a541aaffb9ace
1 REQUIRE_IMAGE_METADATA
=1
2 RAMFS_COPY_BIN
='fitblk'
4 platform_get_bootdev
() {
5 local rootdisk
="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)"
7 for handle
in /sys
/class
/block
/*/of_node
/phandle
/sys
/class
/block
/*/device
/of_node
/phandle
; do
8 [ ! -e "$handle" ] && continue
9 if [ "$rootdisk" = "$(cat $handle)" ]; then
10 bootdev
="${handle%/of_node/phandle}"
11 bootdev
="${bootdev%/device}"
12 bootdev
="${bootdev#/sys/class/block/}"
19 platform_do_upgrade
() {
20 local board
=$
(board_name
)
21 local file_type
=$
(identify
$1)
25 ubnt
,unifi-6-lr-v1-ubootmod|\
26 ubnt
,unifi-6-lr-v2-ubootmod|\
27 ubnt
,unifi-6-lr-v3-ubootmod
)
28 [ -e /dev
/fit0
] && fitblk
/dev
/fit0
29 [ -e /dev
/fitrw
] && fitblk
/dev
/fitrw
30 bootdev
="$(platform_get_bootdev)"
33 EMMC_KERN_DEV
="/dev/$bootdev"
37 PART_NAME
="/dev/mtd${bootdev:8}"
38 default_do_upgrade
"$1"
47 buffalo
,wsr-2533dhp2|\
49 local magic
="$(get_magic_long "$1")"
51 # use "mtd write" if the magic is "DHP2 (0x44485032)"
52 # or "DHP3 (0x44485033)"
53 if [ "$magic" = "44485032" -o "$magic" = "44485033" ]; then
54 buffalo_upgrade_ubinized
"$1"
56 CI_KERNPART
="firmware"
60 dlink
,eagle-pro-ai-m32-a1|\
61 dlink
,eagle-pro-ai-r32-a1|\
62 elecom
,wrc-x3200gst3|\
63 mediatek
,mt7622-rfb1-ubi|\
66 xiaomi
,redmi-router-ax6s
)
74 if grep -q mtdparts
=slave
/proc
/cmdline
; then
79 default_do_upgrade
"$1"
82 default_do_upgrade
"$1"
89 platform_check_image
() {
90 local board
=$
(board_name
)
91 local magic
="$(get_magic_long "$1")"
93 [ "$#" -gt 1 ] && return 1
96 buffalo
,wsr-2533dhp2|\
98 buffalo_check_image
"$board" "$magic" "$1" ||
return 1
100 dlink
,eagle-pro-ai-m32-a1|\
101 dlink
,eagle-pro-ai-r32-a1|\
102 elecom
,wrc-x3200gst3|\
103 mediatek
,mt7622-rfb1-ubi|\
106 xiaomi
,redmi-router-ax6s
)
107 nand_do_platform_check
"$board" "$1"
111 [ "$magic" != "d00dfeed" ] && {
112 echo "Invalid image type."
122 platform_copy_config
() {
123 case "$(board_name)" in
125 if platform_get_bootdev |
grep -q mmc
; then