GTA04Installation » History » Version 2
Paul Kocialkowski, 05/18/2012 08:47 PM
1 | 1 | Paul Kocialkowski | h1. GTA04 Installation |
---|---|---|---|
2 | |||
3 | h2. Creating a system tarball |
||
4 | |||
5 | Once your Replicant build is ready (bootimage and systemimage), you need to create a system tarball: |
||
6 | <pre> |
||
7 | cd out/target/product/gta04/system |
||
8 | tar -cf ../system.tar . |
||
9 | cd .. |
||
10 | </pre> |
||
11 | |||
12 | h2. Flashing the kernel |
||
13 | |||
14 | You need to flash the kernel to the place your boot.scr will try to load it (usually from NAND). |
||
15 | |||
16 | h2. Setting up the sdcard |
||
17 | |||
18 | Connect the sdcard to your pc (running GNU/Linux) and run the following script (with nor arguments to see usage): |
||
19 | |||
20 | <pre> |
||
21 | #!/bin/sh |
||
22 | |||
23 | # Replicant GTA04 Install script |
||
24 | # |
||
25 | # Copyright (C) 2012 Paul Kocialkowski, GPLv2 |
||
26 | # |
||
27 | # Based on mkcard.sh v0.5 |
||
28 | # Copyright (C) 2009 Graeme Gregory <dp@xora.org.uk>, GPLv2 |
||
29 | # Parts of the procudure base on the work of Denys Dmytriyenko |
||
30 | # http://wiki.omap.com/index.php/MMC_Boot_Format |
||
31 | # |
||
32 | # This program is free software: you can redistribute it and/or modify |
||
33 | # it under the terms of the GNU General Public License as published by |
||
34 | # the Free Software Foundation, either version 2 of the License, or |
||
35 | # (at your option) any later version. |
||
36 | # |
||
37 | # You should have received a copy of the GNU General Public License |
||
38 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
39 | |||
40 | # Env vars |
||
41 | |||
42 | export LC_ALL=C |
||
43 | |||
44 | # Global vars |
||
45 | |||
46 | DRIVE="" |
||
47 | DRIVE_NAME="" |
||
48 | DRIVE_SIZE="" |
||
49 | DRIVE_CYLINDERS="" |
||
50 | DRIVE_PART="" |
||
51 | |||
52 | SYSTEM_AR="" |
||
53 | MOUNT_BASE="/media" |
||
54 | |||
55 | # Functions |
||
56 | |||
57 | display_banner() { |
||
58 | echo "Replicant GTA04 installer" |
||
59 | echo "" |
||
60 | } |
||
61 | |||
62 | display_help() { |
||
63 | echo "Usage: $0 [DRIVE] [SYSTEM]" |
||
64 | echo "" |
||
65 | echo "Notes: " |
||
66 | echo "- The [DRIVE] argument can be omitted" |
||
67 | echo "- The [SYSTEM] argument must be a tar archive" |
||
68 | } |
||
69 | |||
70 | drive_select_list() |
||
71 | { |
||
72 | drives_dir="/dev/disk/by-id/" |
||
73 | count=0 |
||
74 | |||
75 | list=$( ls "$drives_dir" ) |
||
76 | |||
77 | for drive in $list |
||
78 | do |
||
79 | drive_nopart=$( echo "$drive" | sed "s/-part[0-9]*$//g" ) |
||
80 | if [ "$drive" = "$drive_nopart" ] |
||
81 | then |
||
82 | ls $drives_dir/$drive-part* 2> /dev/null > /dev/null |
||
83 | |||
84 | if [ $? -eq 0 ] |
||
85 | then |
||
86 | count=$(( $count + 1 )) |
||
87 | name=$( echo "$drive" | sed "s/^[^-]*-\(.*\)$/\1/g" ) |
||
88 | |||
89 | case "$1" in |
||
90 | "show") |
||
91 | echo "$count - $name" |
||
92 | ;; |
||
93 | "store") |
||
94 | if [ $count -eq $2 ] |
||
95 | then |
||
96 | DRIVE=$( readlink -f "$drives_dir/$drive" ) |
||
97 | DRIVE_NAME="$name" |
||
98 | fi |
||
99 | ;; |
||
100 | esac |
||
101 | fi |
||
102 | fi |
||
103 | done |
||
104 | } |
||
105 | |||
106 | drive_select() |
||
107 | { |
||
108 | echo "Available devices:" |
||
109 | drive_select_list "show" |
||
110 | |||
111 | echo -n "Choice: " |
||
112 | read choice |
||
113 | |||
114 | drive_select_list "store" $choice |
||
115 | echo "" |
||
116 | } |
||
117 | |||
118 | drive_write_confirm() { |
||
119 | if [ "$DRIVE" = "" ] |
||
120 | then |
||
121 | echo "Wrong drive block" |
||
122 | exit 1 |
||
123 | fi |
||
124 | |||
125 | echo "This is going to erase the following drive:" |
||
126 | |||
127 | if [ "$DRIVE_NAME" != "" ] |
||
128 | then |
||
129 | echo "- $DRIVE_NAME ($DRIVE)" |
||
130 | else |
||
131 | echo "- $DRIVE" |
||
132 | fi |
||
133 | |||
134 | echo "" |
||
135 | echo -n "Are you sure? " |
||
136 | read confirm |
||
137 | |||
138 | if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ] |
||
139 | then |
||
140 | echo "" |
||
141 | return |
||
142 | else |
||
143 | exit 0 |
||
144 | fi |
||
145 | } |
||
146 | |||
147 | drive_umount() { |
||
148 | umount $DRIVE* 2> /dev/null |
||
149 | } |
||
150 | |||
151 | drive_empty() { |
||
152 | dd if=/dev/zero of="$DRIVE" bs=1024 count=1024 |
||
153 | } |
||
154 | |||
155 | drive_infos_get() { |
||
156 | DRIVE_SIZE=$( fdisk -l "$DRIVE" | grep Disk | grep bytes | awk '{print $5}' ) |
||
157 | DRIVE_CYLINDERS=$( echo "$DRIVE_SIZE/255/63/512" | bc ) |
||
158 | } |
||
159 | |||
160 | drive_partitions_set() { |
||
161 | system_size=$( echo "(250 * 1024 * 1024) / ($DRIVE_SIZE/$DRIVE_CYLINDERS)" | bc ) |
||
162 | data_size=$( echo "(250 * 1024 * 1024) / ($DRIVE_SIZE/$DRIVE_CYLINDERS)" | bc ) |
||
163 | cache_size=$( echo "(100 * 1024 * 1024) / ($DRIVE_SIZE/$DRIVE_CYLINDERS)" | bc ) |
||
164 | |||
165 | { |
||
166 | echo ",$system_size,83" |
||
167 | echo ",$data_size,83" |
||
168 | echo ",$cache_size,83" |
||
169 | echo ",,0c" |
||
170 | } | sfdisk -D -H 255 -S 63 -C "$DRIVE_CYLINDERS" "$DRIVE" |
||
171 | |||
172 | mkfs.ext2 -L "system" "${DRIVE}1" |
||
173 | mkfs.ext2 -L "data" "${DRIVE}2" |
||
174 | mkfs.ext2 -L "cache" "${DRIVE}3" |
||
175 | mkfs.vfat -F 32 -n "storage" "${DRIVE}4" |
||
176 | } |
||
177 | |||
178 | system_write() { |
||
179 | echo "Writing system files" |
||
180 | |||
181 | mkdir -p "$MOUNT_BASE/system" |
||
182 | mount "${DRIVE}1" "$MOUNT_BASE/system" |
||
183 | 2 | Paul Kocialkowski | tar -p -xf $SYSTEM_AR -C "$MOUNT_BASE/system" |
184 | 1 | Paul Kocialkowski | dir=$( pwd ) |
185 | |||
186 | echo "Syncing files" |
||
187 | cd "$MOUNT_BASE/system" |
||
188 | sync |
||
189 | cd "$dir" |
||
190 | } |
||
191 | |||
192 | display_end() { |
||
193 | echo "" |
||
194 | echo "Your drive is now ready to be used!" |
||
195 | } |
||
196 | |||
197 | drive_eject() { |
||
198 | eject "$DRIVE" |
||
199 | } |
||
200 | |||
201 | # Script start |
||
202 | |||
203 | if [ $# -eq 0 ] |
||
204 | then |
||
205 | display_help |
||
206 | exit 1 |
||
207 | fi |
||
208 | |||
209 | if [ $# -eq 1 ] |
||
210 | then |
||
211 | SYSTEM_AR=$1 |
||
212 | fi |
||
213 | |||
214 | if [ $# -eq 2 ] |
||
215 | then |
||
216 | DRIVE=$1 |
||
217 | SYSTEM_AR=$2 |
||
218 | fi |
||
219 | |||
220 | display_banner |
||
221 | |||
222 | if [ "$DRIVE" = "" ] |
||
223 | then |
||
224 | drive_select |
||
225 | fi |
||
226 | |||
227 | drive_write_confirm |
||
228 | drive_umount |
||
229 | drive_empty |
||
230 | drive_infos_get |
||
231 | drive_partitions_set |
||
232 | system_write |
||
233 | display_end |
||
234 | drive_eject |
||
235 | </pre> |