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

Source at commit a0ee309f2a66d3a216330dde489faa2505bc8bb3 created 13 years 1 month ago.
By Xiangfu Liu, update-F4-loading-kernel-from-ubifs_rootfs-bin-uImag
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 1400MiB -N data
57    exit 0
58fi
59
60if [ "$1" == "fw_setenv_default" ]; then
61    fw_setenv bootargs mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
62    fw_setenv bootcmd nand read 0x80600000 0x400000 0x200000\;bootm
63    fw_setenv bootargsfromsd mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
64    fw_setenv bootcmdfromsd mmc init\; ext2load mmc 0 0x80600000 /boot/uImage\; bootm
65    fw_setenv bootdelay 0
66    fw_setenv baudrate 57600
67    fw_setenv loads_echo 1
68    fw_setenv stdin serial
69    fw_setenv stderr serial
70    fw_setenv stdout serial
71    fw_setenv bootcmdf1 mmc init\; ext2load mmc 0:1 0x80600000 /boot/uImage\; bootm
72    fw_setenv bootargsf1 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait
73    fw_setenv bootcmdf2 mmc init\; ext2load mmc 0:2 0x80600000 /boot/uImage\; bootm
74    fw_setenv bootargsf2 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait
75    fw_setenv bootcmdf3 mmc init\; ext2load mmc 0:3 0x80600000 /boot/uImage\; bootm
76    fw_setenv bootargsf3 mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait
77    fw_setenv bootcmdf4 mtdparts default\;ubi part rootfs\;ubifsmount rootfs\;ubifsload 0x80600000 /boot/uImage\; bootm
78    fw_setenv bootargsf4 mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait
79    exit 0
80fi
81
82echo "\
83Usage: $0 [ command ] [ <para1> <para2> <para3> ]
84     flash bootloader|kernel|rootfs|data image_file
85             flash nand partition using <image_file>
86
87     mount rootfs|data mount_point
88             mount nand partition
89
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.
97
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.
106
107script file for Qi Hardware Ben NanoNote
108written by: Xiangfu Liu (xiangfu@sharism.cc)
109written with Emacs in Ben NanoNote
110                             version: ${__VERSION__}
111Report bugs to developer@lists.qi-hardware.com"
112exit 0

Archive Download this file



interactive