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_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."
39 echo "Board is ASUS RT-N56U, replacing uImage header..."
40 local firmware_mtd
=$
(find_mtd_part firmware
)
41 local rootfs_mtd
=$
(find_mtd_part rootfs
)
42 local rootfs_data_mtd
=$
(find_mtd_part rootfs_data
)
43 local rootfs_len
=$
(grep \"rootfs
\" /proc
/mtd |
awk -F' ' '{print "0x"$2}')
44 local rootfs_data_len
=$
(grep \"rootfs_data
\" /proc
/mtd |
awk -F' ' '{print "0x"$2}')
45 local offset
=$
(echo "$rootfs_len $rootfs_data_len 0x40" |
awk -F' ' '{printf "%i",$1-$2-$3}')
46 local signature
=$
(dd if=$rootfs_mtd skip
=$offset bs
=1 count
=4 2>/dev
/null |
hexdump -v -n 4 -e '1/1 "%02x"')
47 if [ "$signature" = "27051956" ]; then
48 dd conv
=notrunc
if=$rootfs_mtd skip
=$offset of
=$firmware_mtd bs
=1 count
=64 2>/dev
/null
56 boot_hook_add preinit_main do_checksumming_disable