3 # This script can be used to download a TGZ file from your build system which
4 # contains the files to be installed on the NAND flash on your RB1xx card.
5 # The one parameter is the URL of the TGZ file to be downloaded.
7 # Author david.goodenough@linkchoose.co.uk
8 # Based on cf2nand from RB532 support
11 [ -d /tmp
/wget2nand-rootfs
] && {
12 echo "/tmp/wget2nand-rootfs already exists"
16 [ -d /tmp
/wget2nand-kernel
] && {
17 echo "/tmp/wget2nand-kernel already exists"
21 # need to find the wget server from the command line
24 echo "No URL specified for image TGZ"
29 # first get an address for br-lan using udhcpc
31 /sbin
/udhcpc
-i br-lan
33 mtd_kernel
="$(find_mtd_part 'kernel')"
34 mtd_rootfs
="$(find_mtd_part 'rootfs')"
35 [ -z "$mtd_kernel" -o -z "$mtd_rootfs" ] && {
36 echo "Cannot find NAND Flash partitions"
40 echo "Erasing filesystem..."
41 mtd erase kernel
2>/dev
/null
>/dev
/null
42 mtd erase rootfs
2>/dev
/null
>/dev
/null
44 echo "Mounting $mtd_rootfs as new root and $mtd_kernel as kernel partition"
46 mkdir
/tmp
/wget2nand-rootfs
47 mkdir
/tmp
/wget2nand-kernel
48 mount
-t yaffs2
"$mtd_rootfs" /tmp
/wget2nand-rootfs
49 mount
-t yaffs2
"$mtd_kernel" /tmp
/wget2nand-kernel
51 echo "Erasing existing files..."
52 rm -rf /tmp
/wget2nand-rootfs
/*
54 echo "Copying filesystem..."
55 ( wget
-O - $url/openwrt-adm5120-2.6
-rootfs.tgz
) |
( cd /tmp
/wget2nand-rootfs
/; tar xvz
)
56 # RouterBOOT is looking for a kernel named "kernel"
57 wget
-O /tmp
/wget2nand-kernel
/kernel
$url/openwrt-adm5120-2.6
-rb1xx-kernel
59 chmod +x
/tmp
/wget2nand-kernel
/kernel
61 # make sure everything is written before we unmount the partitions
62 echo "chmod ugo+x /" > /tmp
/wget2nand-rootfs
/etc
/uci-defaults
/set_root_permission
64 ls /tmp
/wget2nand-kernel
/
65 ls /tmp
/wget2nand-rootfs
/
66 # unmount the partitions and remove the directories into which they were mounted
67 umount
/tmp
/wget2nand-kernel
68 umount
/tmp
/wget2nand-rootfs
69 rmdir /tmp
/wget2nand-kernel
70 rmdir /tmp
/wget2nand-rootfs
73 echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand"
This page took 0.044089 seconds and 5 git commands to generate.