nanonote-files/script-files/usr/bin/mtd.nn |
1 | 1 | #!/bin/bash |
| 2 | |
| 3 | __VERSION__=2011-02-02 |
2 | 4 | |
3 | 5 | if [ "$1" == "flash" ] && [ "$#" == "3" ]; then |
4 | 6 | case "$2" in |
5 | 7 | "bootloader") |
6 | | echo "not implenment" |
| 8 | echo "not implenment" |
7 | 9 | #flash_eraseall /dev/mtd0 |
8 | 10 | exit 0 |
9 | 11 | ;; |
... | ... | |
27 | 29 | fi |
28 | 30 | |
29 | 31 | if [ "$1" == "mount" ] && [ "$#" == "3" ]; then |
30 | | MOUNT_POINT="$3" |
| 32 | if [ "$2" == "rootfs" ] || [ "$2" == "data" ]; then |
| 33 | MOUNT_POINT="$3" |
| 34 | if [ "$2" == "rootfs" ]; then |
| 35 | PARTITION="2" |
| 36 | elif [ "$2" == "data" ]; then |
| 37 | PARTITION="3" |
| 38 | fi |
31 | 39 | |
32 | | if [ "$2" == "rootfs" ]; then |
33 | | PARTITION="2" |
34 | | elif [ "$2" == "data" ]; then |
35 | | PARTITION="3" |
36 | | fi |
| 40 | mkdir -p $MOUNT_POINT |
| 41 | if [ "$?" != "0" ]; then |
| 42 | echo "mkdir -p $MOUNT_POINT Fail" |
| 43 | exit 1 |
| 44 | fi |
37 | 45 | |
38 | | ubiattach /dev/ubi_ctrl -m ${PARTITION} |
39 | | DEV_UBI=`dmesg | grep "UBI: attached mtd${PARTITION} to" | cut -d ":" -f 2 | cut -d " " -f 5` |
40 | | mkdir -p $MOUNT_POINT |
41 | | if [ -d "$3" ]; then |
42 | | echo "$3 not a folder" |
43 | | exit 1 |
| 46 | ubiattach /dev/ubi_ctrl -m ${PARTITION} |
| 47 | DEV_UBI=`dmesg | grep "UBI: attached mtd${PARTITION} to" | cut -d ":" -f 2 | cut -d " " -f 5` |
| 48 | mount -t ubifs ${DEV_UBI}_0 $MOUNT_POINT |
| 49 | exit 0 |
44 | 50 | fi |
45 | | |
46 | | mount -t ubifs ${DEV_UBI}_0 $MOUNT_POINT |
47 | 51 | fi |
48 | 52 | |
49 | | |
50 | | if [ "$1" == "format_data" ]; then |
| 53 | if [ "$1" == "format_data_default" ]; then |
51 | 54 | ubiformat /dev/mtd3 -y |
52 | 55 | ubiattach /dev/ubi_ctrl -m 3 |
53 | | ubimkvol /dev/ubi1 -s 1730MiB -N data |
| 56 | ubimkvol /dev/ubi1 -s 1400MiB -N data |
54 | 57 | exit 0 |
55 | 58 | fi |
56 | 59 | |
... | ... | |
77 | 80 | fi |
78 | 81 | |
79 | 82 | echo "\ |
80 | | Usage: $0 [-d <version>] [-l <path to local images>] [-h] |
81 | | -d <> I will download and flash a specific version of OpenWrt images |
| 83 | Usage: $0 [ command ] [ <para1> <para2> <para3> ] |
| 84 | flash bootloader|kernel|rootfs|data image_file |
| 85 | flash nand partition using <image_file> |
82 | 86 | |
83 | | -l <> I will flash images present in <arg> |
84 | | (missing files will be skipped) |
| 87 | mount rootfs|data mount_point |
| 88 | mount nand partition |
85 | 89 | |
86 | | -h you already found out |
| 90 | format_data_default |
| 91 | lookinside for more detari |
| 92 | NOTICE: |
| 93 | this command will format data |
| 94 | partition, create a default |
| 95 | 1400MB volume, named 'data', |
| 96 | ALL data will lost after run. |
87 | 97 | |
88 | | OpenWrt reflash script for qi-hardware Ben NanoNote |
89 | | written by: Xiangfu Liu (xiangfu@sharism.cc) |
| 98 | fw_setenv_default |
| 99 | reset bootloader default variable |
| 100 | lookinside for more detail |
| 101 | NOTICE: |
| 102 | this command write hardcode |
| 103 | variables to nand, so it must |
| 104 | run once before you want change |
| 105 | change it. |
90 | 106 | |
91 | | version: ${__VERSION__} |
92 | | Please report bugs to developer@lists.qi-hardware.com" |
93 | | exit 1 |
| 107 | script file for Qi Hardware Ben NanoNote |
| 108 | written by: Xiangfu Liu (xiangfu@sharism.cc) |
| 109 | written with Emacs in Ben NanoNote |
| 110 | version: ${__VERSION__} |
| 111 | Report bugs to developer@lists.qi-hardware.com" |
| 112 | exit 0 |