blob: 0120f78cfe840919f93926d88725c000dcef6474 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/bin/sh /etc/rc.common
START=99
mmc_resetbc() {
local part_label="$1"
. /lib/functions.sh
local part_device="$(find_mmc_part "$part_label")"
if [ "$part_device" = "" ]; then
>&2 echo "mmc_resetbc: Unknown partition label: $part_label"
return 1
fi
local magic_number="$(hexdump -e '"0x%02x\n"' -n 4 "$part_device")"
if [ "$magic_number" != "0x20110811" ]; then
>&2 echo "mmc_resetbc: Unexpected partition magic: $magic_number"
return 1
fi
local last_count=$(hexdump -e '"0x%02x\n"' -n 4 -s 4 "$part_device")
if [ "$last_count" != "0x00" ]; then
printf "\x00" | dd of="$part_device" bs=4 seek=1 count=1 conv=notrunc 2>/dev/null
last_count=$(hexdump -e '"0x%02x\n"' -n 4 -s 4 "$part_device")
if [ "$last_count" != "0x00" ]; then
>&2 echo "mmc_resetbc: Unable to reset boot counter"
return 1
fi
fi
}
boot() {
case $(board_name) in
alfa-network,ap120c-ac)
[ -n "$(fw_printenv bootcount changed 2>/dev/null)" ] &&\
echo -e "bootcount\nchanged\n" | /usr/sbin/fw_setenv -s -
;;
linksys,ea6350v3|\
linksys,ea8300|\
linksys,mr8300|\
linksys,whw01|\
linksys,whw03v2)
mtd resetbc s_env || true
;;
linksys,whw03)
mmc_resetbc s_env || true
;;
netgear,wac510)
fw_setenv boot_cnt=0
;;
esac
}
|