blob: b24cbf979e7c9e42525da5262d02b592dfdf478b [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh
2#
3# Copyright (C) 2016 LEDE
4#
5
6[ -e /etc/config/ubootenv ] && exit 0
7
8touch /etc/config/ubootenv
9
10. /lib/uboot-envtools.sh
11. /lib/functions.sh
12
13board=$(board_name)
14
15ubootenv_mtdinfo () {
16 UBOOTENV_PART=$(cat /proc/mtd | grep APPSBLENV)
17 mtd_dev=$(echo $UBOOTENV_PART | awk '{print $1}' | sed 's/:$//')
18 mtd_size=$(echo $UBOOTENV_PART | awk '{print "0x"$2}')
19 mtd_erase=$(echo $UBOOTENV_PART | awk '{print "0x"$3}')
20 nor_flash=$(find /sys/bus/spi/devices/*/mtd -name ${mtd_dev})
21
22 if [ -n "$nor_flash" ]; then
23 ubootenv_size=$mtd_size
24 else
25 # size is fixed to 0x40000 in u-boot
26 ubootenv_size=0x40000
27 fi
28
29 sectors=$(( $ubootenv_size / $mtd_erase ))
30 echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
31}
32
33case "$board" in
34alfa-network,ap120c-ac |\
35devolo,magic-2-wifi-next |\
36edgecore,ecw5211 |\
37glinet,gl-ap1300 |\
38glinet,gl-b1300 |\
39luma,wrtq-329acn |\
40openmesh,a42 |\
41openmesh,a62 |\
42plasmacloud,pa1200 |\
43plasmacloud,pa2200)
44 ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
45 ;;
46aruba,ap-303)
47 ubootenv_add_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
48 ;;
49aruba,ap-365)
50 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
51 ;;
52buffalo,wtr-m2133hp)
53 ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
54 ;;
55linksys,ea6350v3)
56 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
57 ;;
58linksys,ea8300 |\
59linksys,mr8300)
60 ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
61 ;;
62zyxel,nbg6617)
63 ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
64 ;;
65esac
66
67config_load ubootenv
68config_foreach ubootenv_add_app_config ubootenv
69
70exit 0