3 # Netgear WNCE2001 has does a checksum check on boot and goes into recovery
4 # tftp mode when the check fails. Initializing the JFFS2 partition triggers
5 # this, so we make sure to zero checksum and size to be checksummed before
6 # that happens, so this needs to run very early during boot.
8 do_wnce2001_checksumming_disable
() {
11 local board
=$
(ramips_board_name
)
15 echo "Board is WNCE2001, updating checksum partition..."
16 local zeroes
=/dev
/zero
17 local tmpfile
=/tmp
/wnce2001_checksum
18 local partname
=checksum
19 local mtd
=$
(find_mtd_part
$partname)
20 dd if=$mtd of
=$tmpfile bs
=80 count
=1 2>/dev
/null
21 signature
=$
(dd if=$tmpfile bs
=1 skip
=24 count
=20 2>/dev
/null
)
22 checksum
=$
(dd if=$tmpfile bs
=1 count
=4 2>/dev
/null |
hexdump -v -n 4 -e '1/1 "%02x"')
23 if [ "$signature" != "RT3052-AP-WNCE2001-3" ]; then
24 echo "Signature of checksum partition is wrong, bailing."
27 if [ "$checksum" != "00000000" ]; then
28 echo "Checksum is set, zeroing."
30 dd if=$zeroes of
=$tmpfile conv
=notrunc bs
=1 seek
=0 count
=4 2>/dev
/null
31 # zero out bytecount to be checksummed
32 dd if=$zeroes of
=$tmpfile conv
=notrunc bs
=1 seek
=60 count
=4 2>/dev
/null
33 mtd
write $tmpfile $partname
35 echo "Checksum is already zero, nothing to do."
43 boot_hook_add preinit_main do_wnce2001_checksumming_disable