Root/nanonote-files/script-files/usr/bin/mtd.nn

Source at commit ebafec917a21eac69bc11bd2eb1c62e7592f1d5e created 13 years 8 days ago.
By Xiangfu Liu, increase the data partition size to 1480MB
1#!/bin/bash
2 
3__VERSION__=2011-02-02
4
5if [ "$1" == "flash" ] && [ "$#" == "3" ]; then
6    case "$2" in
7    "bootloader")
8        echo "not implenment"
9    #flash_eraseall /dev/mtd0
10    exit 0
11    ;;
12    "kernel")
13    echo "flashing kernel ..."
14    flash_eraseall /dev/mtd1
15    nandwrite -p /dev/mtd1 "$3"
16    exit 0
17    ;;
18    "rootfs")
19    echo "flashing rootfs ..."
20    ubiformat /dev/mtd2 -f "$3"
21    exit 0
22    ;;
23    "data")
24    echo "flashing data partition ..."
25    ubiformat /dev/mtd3 -f "$3"
26    exit 0
27    ;;
28    esac
29fi
30
31if [ "$1" == "mount" ] && [ "$#" == "3" ]; then
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
39
40    mkdir -p $MOUNT_POINT
41    if [ "$?" != "0" ]; then
42        echo "mkdir -p $MOUNT_POINT Fail"
43        exit 1
44    fi
45
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
50    fi
51fi
52
53if [ "$1" == "format_data_default" ]; then
54    ubiformat /dev/mtd3 -y
55    ubiattach /dev/ubi_ctrl -m 3
56    ubimkvol /dev/ubi1 -s 1480MiB -N data
57# test in xiangfu's nanonote. 1486 is the MAX size we can make
58# so we using 1480 for now
59    exit 0
60fi
61
62if [ "$1" == "fw_setenv_default" ]; then
63    fw_setenv bootargs mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
64    fw_setenv bootcmd nand read 0x80600000 0x400000 0x200000\;bootm
65    fw_setenv bootargsfromsd mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
66    fw_setenv bootcmdfromsd mmc init\; ext2load mmc 0 0x80600000 /boot/uImage\; bootm
67    fw_setenv bootdelay 0
68    fw_setenv baudrate 57600
69    fw_setenv loads_echo 1
70    fw_setenv stdin serial
71    fw_setenv stderr serial
72    fw_setenv stdout serial
73    fw_setenv bootcmdf1 mmc init\; ext2load mmc 0:1 0x80600000 /boot/uImage\; bootm
74    fw_setenv bootargsf1 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
75    fw_setenv bootcmdf2 mmc init\; ext2load mmc 0:2 0x80600000 /boot/uImage\; bootm
76    fw_setenv bootargsf2 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait
77    fw_setenv bootcmdf3 mmc init\; ext2load mmc 0:3 0x80600000 /boot/uImage\; bootm
78    fw_setenv bootargsf3 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait
79    fw_setenv bootcmdf4 mtdparts default\;ubi part rootfs\;ubifsmount rootfs\;ubifsload 0x80600000 /boot/uImage\; bootm
80    fw_setenv bootargsf4 mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
81    exit 0
82fi
83
84echo "\
85Usage: $0 [ command ] [ <para1> <para2> <para3> ]
86     flash bootloader|kernel|rootfs|data image_file
87             flash nand partition using <image_file>
88
89     mount rootfs|data mount_point
90             mount nand partition
91
92     format_data_default
93             lookinside for more detari
94             NOTICE:
95                     this command will format data
96                     partition, create a default
97                     1400MB volume, named 'data',
98                     ALL data will lost after run.
99
100     fw_setenv_default
101             reset bootloader default variable
102             lookinside for more detail
103             NOTICE:
104                     this command write hardcode
105                     variables to nand, so it must
106                     run once before you want change
107                     change it.
108
109script file for Qi Hardware Ben NanoNote
110written by: Xiangfu Liu (xiangfu@sharism.cc)
111written with Emacs in Ben NanoNote
112                             version: ${__VERSION__}
113Report bugs to developer@lists.qi-hardware.com"
114exit 0
115

Archive Download this file



interactive