Skip to content

Commit 4d6f294

Browse files
authored
Updated flash.sh for AFM0002 (#209)
1 parent 3fa548c commit 4d6f294

1 file changed

Lines changed: 153 additions & 32 deletions

File tree

_ont/ont-technicolor-afm0002.md

Lines changed: 153 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -127,38 +127,159 @@ The following commands are used to flash a new rootfs to image1 and then boot to
127127
{% include alert.html content="This section is based on the `V1_7_8_210412` version of the stick's firmware " alert="Info" icon="svg-info" color="blue" %}
128128

129129
## Adding support to configurable SW and HW versions, Vendor ID and much more
130-
`/etc/scripts/flash` can be flashed in order to add support for some variables implemented in `omci_app` but removed from `xmlconfig`. The patch is below (change the values to suit your needs)
131-
```patch
132-
--- squashfs-root/etc/scripts/flash 2021-09-28 10:38:52.000000000 +0200
133-
+++ squashfs-root.new/etc/scripts/flash 2022-08-04 00:00:29.769605000 +0200
134-
@@ -62,7 +62,26 @@
135-
if [ `echo $para | egrep $specific_mib_patten` ]; then
136-
/bin/xmlconfig -g $para | sed -r "s/$rename_mib_name+/$2/g" | sed -r "s/,+//g"
137-
else
138-
- /bin/xmlconfig -g $para | sed -r "s/$rename_mib_name+/$2/g"
139-
+ case "$para" in
140-
+ "OMCI_EQID")
141-
+ echo "$para=MY_EQID"
142-
+ ;;
143-
+ "OMCI_VENDOR_ID")
144-
+ echo "$para=MY_VENDOR"
145-
+ ;;
146-
+ "OMCI_SW_VER1")
147-
+ echo "$para=MY_SW_VER1"
148-
+ ;;
149-
+ "OMCI_SW_VER2")
150-
+ echo "$para=MY_SW_VER2"
151-
+ ;;
152-
+ "OMCI_ONT_VER")
153-
+ echo "$para=MY_HW_VER"
154-
+ ;;
155-
+ *)
156-
+ /bin/xmlconfig -g $para | sed -r "s/$rename_mib_name+/$2/g"
157-
+ ;;
158-
+ esac
159-
fi
160-
if [ "$?" = "0" ]; then
161-
exit 0
130+
`/etc/scripts/flash` can be modified in order to add support for some variables implemented in `omci_app` but removed from `xmlconfig`. The modified file is below.
131+
132+
`flash set` will still print an error but the change wil be persisted. You can check that by running the relative `flash get` command
133+
134+
```sh
135+
#!/bin/ash
136+
#
137+
# usage: flash.sh [cmd] ...
138+
#
139+
140+
DEFAULT_FILE="/etc/config_default.xml"
141+
DEFAULT_HS_FILE="/etc/config_default_hs.xml"
142+
LASTGOOD_FILE="/var/config/lastgood.xml"
143+
LASTGOOD_HS_FILE="/var/config/lastgood_hs.xml"
144+
145+
# for array type in hw_setting
146+
specific_mib_patten="(^HW(_|_WLAN0_|_WLAN1_)TX_POWER*)|(^HW_FON_KEYWORD$)"
147+
148+
rename_mib_patten="^HW_(NIC[0-1]|WLAN[0-1]_WLAN)_ADDR"
149+
rename_mib_name="ELAN_MAC_ADDR"
150+
151+
hw_mib="^HW_|^SUPER_NAME$|^SUPER_PASSWORD$|^BOOT_MODE$|^ELAN_MAC_ADDR#|^WLAN_MAC_ADD$|^WAN_PHY_PORT$|^WIFI_SUPPORT$|^BYTE$|^WORD$|^DWORD$|^INT1$|^INT2$"
152+
var=""
153+
154+
155+
case "$1" in
156+
"all")
157+
# echo "------ [$1] Display all settings ------"
158+
if [ $# -eq 1 ] || [ "$2" = "hs" ]; then
159+
/bin/xmlconfig -os -hs
160+
fi
161+
if [ $# -eq 1 ] || [ "$2" = "cs" ]; then
162+
/bin/xmlconfig -os
163+
fi
164+
exit 0
165+
;;
166+
"default")
167+
# echo "------ [$1] Restore to default configurationg ------"
168+
if [ "$2" = "cs" ]; then
169+
/bin/xmlconfig -def_mib
170+
/bin/xmlconfig -if $DEFAULT_FILE -nodef && /bin/xmlconfig -of $LASTGOOD_FILE
171+
echo "Reset CS to default configuration success."
172+
elif [ "$2" = "hs" ]; then
173+
/bin/xmlconfig -def_mib -hs
174+
/bin/xmlconfig -if $DEFAULT_HS_FILE -nodef && /bin/xmlconfig -of $LASTGOOD_HS_FILE
175+
echo "Reset HS to default configuration success."
176+
elif [ "$2" = "voip" ]; then
177+
/bin/xmlconfig -def_voip_mib
178+
/bin/xmlconfig -of $LASTGOOD_FILE
179+
echo "Reset VoIP to default configuration success."
180+
else
181+
echo "Restore to default configurationg fail."
182+
/bin/sh $0 -h
183+
exit 1
184+
fi
185+
echo "Please reboot system."
186+
exit 0
187+
;;
188+
"get" | "gethw")
189+
# echo "------ [$1] Get a specific mib parameter from flash memory. ------"
190+
if [ "$2" != "" ]; then
191+
para=$2
192+
if [ `echo $para | egrep $rename_mib_patten` ]; then
193+
para=$rename_mib_name
194+
fi
195+
#echo "/bin/xmlconfig -g $para"
196+
if [ `echo $para | egrep $specific_mib_patten` ]; then
197+
/bin/xmlconfig -g $para | sed -r "s/$rename_mib_name+/$2/g" | sed -r "s/,+//g"
198+
else
199+
local_nv_getenv=`nv getenv $para`
200+
if [ -z "${local_nv_getenv}" ]; then
201+
/bin/xmlconfig -g $para | sed -r "s/$rename_mib_name+/$2/g"
202+
else
203+
echo "${local_nv_getenv}" | sed -r "s/$rename_mib_name+/$2/g"
204+
fi
205+
fi
206+
if [ "$?" = "0" ]; then
207+
exit 0
208+
fi
209+
else
210+
/bin/sh $0 -h
211+
exit 1
212+
fi
213+
;;
214+
"set" | "sethw")
215+
# echo "------ [$1] Set a specific mib parameter into flash memory. ------"
216+
if [ "$2" != "" ] && [ "$3" != "" ]; then
217+
para=$2
218+
if [ `echo $para | egrep $rename_mib_patten` ]; then
219+
$para=$rename_mib_name
220+
fi
221+
222+
if [ $# -eq 3 ]; then
223+
var=$3
224+
else
225+
while [ $# -ge 3 ]
226+
do
227+
# for multiple decimal values: dec2hex and concatenate all setting value
228+
if [ "$3" = "08" ] || [ "$3" = "09" ]; then
229+
# 08 & 09 are not invalid octal number
230+
var=$var$3
231+
else
232+
var=$var`printf "%02x" $3`
233+
fi
234+
235+
shift
236+
if [ $# -ge 3 ]; then var=$var","; fi
237+
done
238+
fi
239+
#echo "/bin/xmlconfig -s $para $var"
240+
241+
/bin/xmlconfig -s $para $var | egrep "[ERR]"
242+
if [ $? == 0 ]; then
243+
nv setenv $para $var
244+
else
245+
# Clear the ovveride from nv if it is there since we wrote it to xmlconfig
246+
nv setenv $para
247+
fi
248+
if [ "`echo $2 | egrep $hw_mib`" = "" ]; then
249+
/bin/xmlconfig -of $LASTGOOD_FILE
250+
fi
251+
/bin/xmlconfig -of -hs $LASTGOOD_HS_FILE && exit 0
252+
else
253+
/bin/sh $0 -h
254+
exit 1
255+
fi
256+
;;
257+
"-h")
258+
echo 'Usage: flash.sh [cmd]'
259+
echo 'cmd:'
260+
echo ' all <cs/hs> : Show all settings.'
261+
echo ' default <cs/hs> : Restore to default configuration.'
262+
echo ' get MIB-NAME : get a specific mib parameter from flash memory.'
263+
echo ' set MIB-NAME MIB-VALUE : set a specific mib parameter into flash memory.'
264+
echo
265+
echo ' Note: When set the MIB_ARRAY or MIB_VALUE overflowed,'
266+
echo ' xmlconfig will truncate the redundant part.'
267+
echo ' Take signed integer for example:'
268+
echo ' 1. Set value=-6442450944(0xfffffffe80000000),'
269+
echo ' and get value=-2147483648(0x80000000)'
270+
echo ' 2. Set value=-2147483649(0xffffffff7fffffff),'
271+
echo ' and get value=2147483647(0x7fffffff)'
272+
echo ' 3. Set value=2147483648(0x80000000),'
273+
echo ' and get value=-2147483648(0x80000000)'
274+
echo ' 4. Set value=4294967296(0x100000000), and get value=0(0x0)'
275+
echo
276+
;;
277+
*)
278+
/bin/sh $0 -h
279+
exit 1
280+
;;
281+
esac
282+
162283
```
163284
## Increasing the length of the software version from 13 to 14 characters
164285
`omci_app` has an hard-coded limit of 13 characters for the software version, which is too low. We can binary patch it to increase it to 14 (or more, if you dare/need)

0 commit comments

Comments
 (0)