mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-09-03 21:44:37 +03:00
ar71xx: improve wget2nand script
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20094 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
9023573294
commit
3f2b898918
@ -8,13 +8,14 @@
|
|||||||
# Based on cf2nand from RB532 support
|
# Based on cf2nand from RB532 support
|
||||||
. /etc/functions.sh
|
. /etc/functions.sh
|
||||||
|
|
||||||
[ -d /tmp/wget2nand-rootfs ] && {
|
wget2nand_dir=/tmp/wget2nand
|
||||||
echo "/tmp/wget2nand-rootfs already exists"
|
mnt_kernel=$wget2nand_dir/mnt_kernel
|
||||||
exit 1
|
mnt_rootfs=$wget2nand_dir/mnt_rootfs
|
||||||
}
|
src_rootfs=$wget2nand_dir/rootfs.tgz
|
||||||
|
src_kernel=$wget2nand_dir/kernel
|
||||||
|
|
||||||
[ -d /tmp/wget2nand-kernel ] && {
|
[ -d "$wget2nand_dir" ] && {
|
||||||
echo "/tmp/wget2nand-kernel already exists"
|
echo "$wget2nand_dir already exists"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,9 +27,8 @@ url=$1
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# first get an address for br-lan using udhcpc
|
url_kernel=$url/openwrt-ar71xx-vmlinux.elf
|
||||||
killall udhcpc
|
url_rootfs=$url/openwrt-ar71xx-rootfs.tgz
|
||||||
/sbin/udhcpc -i br-lan
|
|
||||||
|
|
||||||
mtd_kernel="$(find_mtd_part 'kernel')"
|
mtd_kernel="$(find_mtd_part 'kernel')"
|
||||||
mtd_rootfs="$(find_mtd_part 'rootfs')"
|
mtd_rootfs="$(find_mtd_part 'rootfs')"
|
||||||
@ -37,37 +37,50 @@ mtd_rootfs="$(find_mtd_part 'rootfs')"
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# first get an address for br-lan using udhcpc
|
||||||
|
killall udhcpc
|
||||||
|
/sbin/udhcpc -i br-lan
|
||||||
|
|
||||||
|
mkdir "$wget2nand_dir"
|
||||||
|
wget $url_kernel -O "$src_kernel" || {
|
||||||
|
echo "Unable to download $url_kernel"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
wget $url_rootfs -O "$src_rootfs" || {
|
||||||
|
echo "Unable to download $url_rootfs"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
echo "Erasing filesystem..."
|
echo "Erasing filesystem..."
|
||||||
mtd erase kernel 2>/dev/null >/dev/null
|
mtd erase kernel 2>/dev/null >/dev/null
|
||||||
mtd erase rootfs 2>/dev/null >/dev/null
|
mtd erase rootfs 2>/dev/null >/dev/null
|
||||||
|
|
||||||
echo "Mounting $mtd_rootfs as new root and $mtd_kernel as kernel partition"
|
echo "Mounting $mtd_rootfs as new root and $mtd_kernel as kernel partition"
|
||||||
|
|
||||||
mkdir /tmp/wget2nand-rootfs
|
mkdir "$mnt_kernel"
|
||||||
mkdir /tmp/wget2nand-kernel
|
mkdir "$mnt_rootfs"
|
||||||
mount -t yaffs2 "$mtd_rootfs" /tmp/wget2nand-rootfs
|
mount -t yaffs2 "$mtd_kernel" "$mnt_kernel"
|
||||||
mount -t yaffs2 "$mtd_kernel" /tmp/wget2nand-kernel
|
mount -t yaffs2 "$mtd_rootfs" "$mnt_rootfs"
|
||||||
|
|
||||||
echo "Erasing existing files..."
|
echo "Copying kernel..."
|
||||||
rm -rf /tmp/wget2nand-rootfs/*
|
cp $src_kernel $mnt_kernel/kernel
|
||||||
|
chmod +x $mnt_kernel/kernel
|
||||||
|
|
||||||
echo "Copying filesystem..."
|
echo "Preparing filesystem..."
|
||||||
( wget -O - $url/openwrt-ar71xx-rootfs.tgz) | ( cd /tmp/wget2nand-rootfs/; tar xvz )
|
( cd "$mnt_rootfs"; tar xvz -f "$src_rootfs" )
|
||||||
# RouterBOOT is looking for a kernel named "kernel"
|
|
||||||
wget -O /tmp/wget2nand-kernel/kernel $url/openwrt-ar71xx-vmlinux.elf
|
|
||||||
|
|
||||||
chmod +x /tmp/wget2nand-kernel/kernel
|
|
||||||
|
|
||||||
# make sure everything is written before we unmount the partitions
|
# make sure everything is written before we unmount the partitions
|
||||||
echo "chmod ugo+x /" > /tmp/wget2nand-rootfs/etc/uci-defaults/set_root_permission
|
echo "chmod ugo+x /" > $mnt_rootfs/etc/uci-defaults/set_root_permission
|
||||||
sync
|
sync
|
||||||
ls /tmp/wget2nand-kernel/
|
ls $mnt_kernel >/dev/null
|
||||||
ls /tmp/wget2nand-rootfs/
|
ls $mnt_rootfs >/dev/null
|
||||||
|
|
||||||
|
echo "Cleaning up..."
|
||||||
# unmount the partitions and remove the directories into which they were mounted
|
# unmount the partitions and remove the directories into which they were mounted
|
||||||
umount /tmp/wget2nand-kernel
|
umount $mnt_kernel
|
||||||
umount /tmp/wget2nand-rootfs
|
umount $mnt_rootfs
|
||||||
rmdir /tmp/wget2nand-kernel
|
rm -rf $wget2nand_dir
|
||||||
rmdir /tmp/wget2nand-rootfs
|
|
||||||
|
|
||||||
# all done
|
# all done
|
||||||
echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand"
|
echo "Image written, you can now reboot. Remember to change the boot source to Boot from Nand"
|
||||||
|
Loading…
Reference in New Issue
Block a user