[kernel] update ocf-linux to 20080917
[openwrt.git] / target / linux / ar71xx / base-files / sbin / wget2nand
1 #!/bin/sh
2 # wget2nand
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.
6 # Licence GPL V2
7 # Author david.goodenough@linkchoose.co.uk
8 # Based on cf2nand from RB532 support
9 . /etc/functions.sh
10
11 [ -d /tmp/wget2nand-rootfs ] && {
12 echo "/tmp/wget2nand-rootfs already exists"
13 exit 1
14 }
15
16 [ -d /tmp/wget2nand-kernel ] && {
17 echo "/tmp/wget2nand-kernel already exists"
18 exit 1
19 }
20
21 # need to find the wget server from the command line
22 url=$1
23 [ -z "$url" ] && {
24 echo "No URL specified for image TGZ"
25 echo "Usage : $0 URL"
26 exit 1
27 }
28
29 # first get an address for br-lan using udhcpc
30 killall udhcpc
31 /sbin/udhcpc -i br-lan
32
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"
37 exit 1
38 }
39
40 echo "Erasing filesystem..."
41 mtd erase kernel 2>/dev/null >/dev/null
42 mtd erase rootfs 2>/dev/null >/dev/null
43
44 echo "Mounting $mtd_rootfs as new root and $mtd_kernel as kernel partition"
45
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
50
51 echo "Erasing existing files..."
52 rm -rf /tmp/wget2nand-rootfs/*
53
54 echo "Copying filesystem..."
55 ( wget -O - $url/openwrt-ar71xx-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-ar71xx-vmlinux.elf
58
59 chmod +x /tmp/wget2nand-kernel/kernel
60
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
63 sync
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
71
72 # all done
73 echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand"
This page took 0.045981 seconds and 5 git commands to generate.