blob: f3a94043c94efa723eab34b6be986ded0e0728fa [file] [log] [blame]
developer95b92632024-06-25 17:37:19 +08001From: Weijie Gao <weijie.gao@mediatek.com>
2Subject: [PATCH] mediatek: filogic: add support for MediaTek RFBs
3
4Support MediaTek RFBs by using env parameters passed by u-boot via FDT.
5
6Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
7
8--- a/package/boot/uboot-envtools/files/mediatek_filogic
9+++ b/package/boot/uboot-envtools/files/mediatek_filogic
10@@ -11,6 +11,26 @@ touch /etc/config/ubootenv
11
12 board=$(board_name)
13
14+block_dev_path() {
15+ local dev_path
16+
17+ case "$1" in
18+ /dev/mmcblk*)
19+ dev_path="$1"
20+ ;;
21+ PARTLABEL=* | PARTUUID=*)
22+ dev_path=$(blkid -t "$1" -o device)
23+ [ -z "${dev_path}" -o $? -ne 0 ] && return 1
24+ ;;
25+ *)
26+ return 1;
27+ ;;
28+ esac
29+
30+ echo "${dev_path}"
31+ return 0
32+}
33+
34 ubootenv_add_mmc_default() {
35 local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")"
36 ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
37@@ -33,6 +53,68 @@ ubootenv_add_ubi_default() {
38 }
39
40 case "$board" in
41+mediatek,mt7981-rfb|\
42+mediatek,mt7986a-rfb|\
43+mediatek,mt7986b-rfb|\
44+mediatek,mt7988a-rfb)
developerf2fbad62024-07-24 17:33:36 +080045+ . /lib/upgrade/fit.sh
developer95b92632024-06-25 17:37:19 +080046+
developerf2fbad62024-07-24 17:33:36 +080047+ export_fitblk_bootdev
48+ case "$CI_METHOD" in
49+ ubi)
developer95b92632024-06-25 17:37:19 +080050+ local env_ubi_vol=$(cat /sys/firmware/devicetree/base/mediatek,env-ubi-volume 2>/dev/null)
51+ local env_ubi_vol2=$(cat /sys/firmware/devicetree/base/mediatek,env-ubi-volume-redund 2>/dev/null)
52+ local env_size=$(cat /sys/firmware/devicetree/base/mediatek,env-size 2>/dev/null)
53+
54+ if [ x"${env_ubi_vol}" = x"ubootenv" -a x"${env_ubi_vol2}" = x"ubootenv2" ]; then
55+ ubootenv_add_ubi_default
56+ return
57+ fi
58+
59+ . /lib/upgrade/nand.sh
60+ local envubi=$(nand_find_ubi ubi)
61+
62+ if [ -n "${env_ubi_vol}" ]; then
63+ local envdev=/dev/$(nand_find_volume $envubi "${env_ubi_vol}")
64+ ubootenv_add_uci_config "$envdev" "0x0" "${env_size}" "${env_size}" "1"
65+ fi
66+
67+ if [ -n "${env_ubi_vol2}" ]; then
68+ local envdev2=/dev/$(nand_find_volume $envubi "${env_ubi_vol2}")
69+ ubootenv_add_uci_config "$envdev2" "0x0" "${env_size}" "${env_size}" "1"
70+ fi
71+ ;;
developerf2fbad62024-07-24 17:33:36 +080072+ emmc)
developer95b92632024-06-25 17:37:19 +080073+ local env_part=$(cat /sys/firmware/devicetree/base/mediatek,env-part 2>/dev/null)
74+ local env_size=$(cat /sys/firmware/devicetree/base/mediatek,env-size 2>/dev/null)
75+ local env_off=$(cat /sys/firmware/devicetree/base/mediatek,env-offset 2>/dev/null)
76+ local env_redund_off=$(cat /sys/firmware/devicetree/base/mediatek,env-redund-offset 2>/dev/null)
77+
78+ if [ -n "${env_part}" -a -n "${env_size}" -a -n "${env_off}" ]; then
79+ env_dev=$(block_dev_path "${env_part}")
80+
81+ ubootenv_add_uci_config "${env_dev}" "${env_off}" "${env_size}" "${env_size}" "1"
82+
83+ [ -n "${env_redund_off}" ] && \
84+ ubootenv_add_uci_config "${env_dev}" "${env_redund_off}" "${env_size}" "${env_size}" "1"
85+ fi
86+ ;;
developerf2fbad62024-07-24 17:33:36 +080087+ default)
developer95b92632024-06-25 17:37:19 +080088+ local env_part=$(cat /sys/firmware/devicetree/base/mediatek,env-part 2>/dev/null)
89+ local env_size=$(cat /sys/firmware/devicetree/base/mediatek,env-size 2>/dev/null)
90+ local env_redund_off=$(cat /sys/firmware/devicetree/base/mediatek,env-redund-offset 2>/dev/null)
91+
92+ if [ -n "${env_part}" -a -n "${env_size}" ]; then
93+ local env_dev="/dev/mtd$(find_mtd_index "${env_part}")"
94+
95+ ubootenv_add_uci_config "${env_dev}" "0x0" "${env_size}" "${env_size}" "1"
96+
97+ [ -n "${env_redund_off}" ] && \
98+ ubootenv_add_uci_config "${env_dev}" "${env_redund_off}" "${env_size}" "${env_size}" "1"
99+ fi
100+ ;;
101+ esac
102+ ;;
developerf2fbad62024-07-24 17:33:36 +0800103 abt,asr3000|\
104 h3c,magic-nx30-pro|\
105 jcg,q30-pro|\