Skip to content

Commit 9ec0678

Browse files
committedJul 11, 2013
nandinstall script for cubieboard1
0 parents  commit 9ec0678

File tree

8 files changed

+169
-0
lines changed

8 files changed

+169
-0
lines changed
 

‎LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2013 cubieplayer@github.com. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎bootloader/boot.axf

82.2 KB
Binary file not shown.

‎bootloader/boot.ini

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[system]
2+
start_os_name = linux
3+
timeout = -1
4+
display_device= -1
5+
display_mode = 0
6+
erase_flash = 1
7+
8+
9+
[linux]
10+

‎bootloader/linux/linux.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[segment]
2+
img_name = c:\u-boot.bin
3+
img_size = 0x80000
4+
img_base = 0x4A000000
5+
6+
[script_info]
7+
script_base = 0x43000000
8+
script_size = 0x10000

‎bootloader/u-boot.bin

353 KB
Binary file not shown.

‎bootloader/uEnv.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
console=tty0
2+
extraargs=console=ttyS0,115200 hdmi.audio=EDID:0 disp.screen0_output_mode=EDID:1280x800p60 root=/dev/nandb rootwait panic=10

‎exclude.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/home/cubie/*
2+
/boot/*
3+
/dev/*
4+
/proc/*
5+
/sys/*
6+
/media/*
7+
/mnt/*
8+
/run/*
9+
/tmp/*

‎install.sh

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
#Author: cubieplayer(cubieplayer@github.com)
3+
#Copyright (c) 2013, cubieplayer. All rights reserved.
4+
5+
set -e
6+
7+
PWD="`pwd`"
8+
CWD=$(cd "$(dirname "$0")"; pwd)
9+
10+
NAND="/dev/nand"
11+
NANDA="/dev/nanda"
12+
NANDB="/dev/nandb"
13+
NANDC="/dev/nandc"
14+
15+
BOOT="/mnt/nanda"
16+
ROOTFS="/mnt/nandb"
17+
18+
BOOTLOADER="${CWD}/bootloader"
19+
20+
NANDPART="${CWD}/sunxi-tools/nand-part2"
21+
22+
EXCLUDE="${CWD}/exclude.txt"
23+
24+
isRoot() {
25+
if [ "`id -u`" -ne "0" ]; then
26+
echo "this script needs to be run as root, try again with sudo"
27+
return 1
28+
fi
29+
return 0
30+
}
31+
32+
promptyn () {
33+
while true; do
34+
read -p "$1 " yn
35+
case $yn in
36+
[Yy]* ) return 0;;
37+
[Nn]* ) return 1;;
38+
* ) echo "Please answer yes or no.";;
39+
esac
40+
done
41+
}
42+
43+
umountNand() {
44+
sync
45+
sleep 5
46+
for n in ${NAND}*;do
47+
if [ "${NAND}" != "$n" ];then
48+
if mount|grep ${n};then
49+
echo "umounting ${n}"
50+
umount -l $n
51+
sleep 2
52+
fi
53+
fi
54+
done
55+
}
56+
57+
formatNand () {
58+
$NANDPART $NAND 16 "boot 2048" "linux 4000000" "data 0"
59+
}
60+
61+
mkFS(){
62+
mkfs.msdos $NANDA
63+
mkfs.ext4 $NANDB
64+
mkfs.ext4 $NANDC
65+
}
66+
67+
mountDevice(){
68+
69+
if [ ! -d $BOOT ];then
70+
mkdir $BOOT
71+
fi
72+
mount $NANDA $BOOT
73+
74+
if [ ! -d $ROOTFS ];then
75+
mkdir $ROOTFS
76+
fi
77+
mount $NANDB $ROOTFS
78+
}
79+
80+
installBootloader(){
81+
cd $BOOT
82+
rm -rf *
83+
rsync -avc $BOOTLOADER/* $BOOT
84+
cp /boot/script.bin $BOOT
85+
cd $PWD
86+
}
87+
88+
installRootfs(){
89+
rsync -avc --exclude-from=$EXCLUDE / $ROOTFS
90+
rsync -avc /boot/uImage $ROOTFS/boot/
91+
echo "please wait"
92+
sync
93+
}
94+
95+
patchRootfs(){
96+
cat > ${ROOTFS}/etc/fstab <<END
97+
#<file system> <mount point> <type> <options> <dump> <pass>
98+
/dev/nandb / ext4 defaults 0 1
99+
/dev/nandc /mnt/nandc ext4 defaults 0 1
100+
END
101+
mkdir ${ROOTFS}/mnt/nandc
102+
}
103+
104+
isRoot
105+
if promptyn "This will completely destory your data on $NAND, Are you sure to continue?"; then
106+
umountNand
107+
formatNand
108+
echo "please wait for a moment"
109+
echo "waiting 20 seconds"
110+
sleep 10
111+
echo "waiting 10 seconds"
112+
sleep 5
113+
echo "waiting 5 seconds"
114+
sleep 5
115+
partprobe $NAND
116+
mkFS
117+
echo "waiting 5 seconds"
118+
sleep 5
119+
echo "mount NAND partitions"
120+
mountDevice
121+
echo "install bootloader"
122+
installBootloader
123+
echo "install rootfs"
124+
installRootfs
125+
patchRootfs
126+
umountNand
127+
echo "success! remember to remove your SD card then reboot"
128+
if promptyn "shutdown now?";then
129+
shutdown -h now
130+
fi
131+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.