1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-30 07:59:21 +02:00
openwrt-packages/nanonote-files/script-files/usr/bin/mtd.nn

115 lines
3.7 KiB
Plaintext
Raw Normal View History

2011-02-03 16:18:34 +02:00
#!/bin/bash
__VERSION__=2011-02-02
2011-02-03 16:18:34 +02:00
if [ "$1" == "flash" ] && [ "$#" == "3" ]; then
case "$2" in
"bootloader")
echo "not implenment"
2011-02-03 16:18:34 +02:00
#flash_eraseall /dev/mtd0
exit 0
;;
"kernel")
echo "flashing kernel ..."
flash_eraseall /dev/mtd1
nandwrite -p /dev/mtd1 "$3"
exit 0
;;
"rootfs")
echo "flashing rootfs ..."
ubiformat /dev/mtd2 -f "$3"
exit 0
;;
"data")
echo "flashing data partition ..."
ubiformat /dev/mtd3 -f "$3"
exit 0
;;
esac
fi
if [ "$1" == "mount" ] && [ "$#" == "3" ]; then
if [ "$2" == "rootfs" ] || [ "$2" == "data" ]; then
MOUNT_POINT="$3"
if [ "$2" == "rootfs" ]; then
PARTITION="2"
elif [ "$2" == "data" ]; then
PARTITION="3"
fi
2011-02-03 16:18:34 +02:00
mkdir -p $MOUNT_POINT
if [ "$?" != "0" ]; then
echo "mkdir -p $MOUNT_POINT Fail"
exit 1
fi
2011-02-03 16:18:34 +02:00
ubiattach /dev/ubi_ctrl -m ${PARTITION}
DEV_UBI=`dmesg | grep "UBI: attached mtd${PARTITION} to" | cut -d ":" -f 2 | cut -d " " -f 5`
mount -t ubifs ${DEV_UBI}_0 $MOUNT_POINT
exit 0
2011-02-03 16:18:34 +02:00
fi
fi
if [ "$1" == "format_data_default" ]; then
2011-02-03 16:18:34 +02:00
ubiformat /dev/mtd3 -y
ubiattach /dev/ubi_ctrl -m 3
ubimkvol /dev/ubi1 -s 1480MiB -N data
# test in xiangfu's nanonote. 1486 is the MAX size we can make
# so we using 1480 for now
2011-02-03 16:18:34 +02:00
exit 0
fi
if [ "$1" == "fw_setenv_default" ]; then
fw_setenv bootargs mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
fw_setenv bootcmd nand read 0x80600000 0x400000 0x200000\;bootm
fw_setenv bootargsfromsd mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
fw_setenv bootcmdfromsd mmc init\; ext2load mmc 0 0x80600000 /boot/uImage\; bootm
fw_setenv bootdelay 0
fw_setenv baudrate 57600
fw_setenv loads_echo 1
fw_setenv stdin serial
fw_setenv stderr serial
fw_setenv stdout serial
fw_setenv bootcmdf1 mmc init\; ext2load mmc 0:1 0x80600000 /boot/uImage\; bootm
fw_setenv bootargsf1 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
fw_setenv bootcmdf2 mmc init\; ext2load mmc 0:2 0x80600000 /boot/uImage\; bootm
fw_setenv bootargsf2 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait
fw_setenv bootcmdf3 mmc init\; ext2load mmc 0:3 0x80600000 /boot/uImage\; bootm
fw_setenv bootargsf3 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait
fw_setenv bootcmdf4 mtdparts default\;ubi part rootfs\;ubifsmount rootfs\;ubifsload 0x80600000 /boot/uImage\; bootm
fw_setenv bootargsf4 mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
2011-02-03 16:18:34 +02:00
exit 0
fi
echo "\
Usage: $0 [ command ] [ <para1> <para2> <para3> ]
flash bootloader|kernel|rootfs|data image_file
flash nand partition using <image_file>
2011-02-03 16:18:34 +02:00
mount rootfs|data mount_point
mount nand partition
2011-02-03 16:18:34 +02:00
format_data_default
lookinside for more detari
NOTICE:
this command will format data
partition, create a default
1400MB volume, named 'data',
ALL data will lost after run.
2011-02-03 16:18:34 +02:00
fw_setenv_default
reset bootloader default variable
lookinside for more detail
NOTICE:
this command write hardcode
variables to nand, so it must
run once before you want change
change it.
2011-02-03 16:18:34 +02:00
script file for Qi Hardware Ben NanoNote
written by: Xiangfu Liu (xiangfu@sharism.cc)
written with Emacs in Ben NanoNote
version: ${__VERSION__}
Report bugs to developer@lists.qi-hardware.com"
exit 0