|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
1 |
#!/bin/sh
|
2 |
||
3 |
# Copyright (C) 2006 Joey Hess <joeyh@debian.org>
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
4 |
# Copyright (C) 2006, 2007, 2008, 2009 Martin Michlmayr <tbm@cyrius.com>
|
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
5 |
# Copyright (C) 2009, 2010 Canonical Ltd
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
6 |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
7 |
# This program is free software; you can redistribute it and/or
|
8 |
# modify it under the terms of the GNU General Public License
|
|
9 |
# as published by the Free Software Foundation; either version 2
|
|
10 |
# of the License, or (at your option) any later version.
|
|
11 |
#
|
|
12 |
# This program is distributed in the hope that it will be useful,
|
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
# GNU General Public License for more details.
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License
|
|
18 |
# along with this program; if not, write to the Free Software
|
|
19 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
|
|
20 |
# USA.
|
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
21 |
|
22 |
set -e
|
|
23 |
||
24 |
error() { |
|
25 |
echo "$@" >&2 |
|
26 |
exit 1
|
|
27 |
}
|
|
28 |
||
29 |
check_mtd() { |
|
30 |
if [ ! -e /proc/mtd ]; then |
|
31 |
error "/proc/mtd doesn't exist" |
|
32 |
fi
|
|
33 |
}
|
|
34 |
||
35 |
mtdblock() { |
|
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
36 |
grep "\"$1\"" /proc/mtd | cut -d: -f 1 | sed 's/mtd/\/dev\/mtdblock/' |
37 |
}
|
|
38 |
||
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
39 |
check_dev_mtdblock() { |
40 |
if [ ! -b "$1" ]; then |
|
41 |
error "$1 is not a block device" |
|
42 |
fi
|
|
43 |
}
|
|
44 |
||
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
45 |
mtdsize() { |
46 |
size=$(grep "\"$1\"" /proc/mtd | cut -d " " -f 2) |
|
47 |
printf "%d" 0x$size |
|
48 |
}
|
|
49 |
||
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
50 |
check_subarch() { |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
51 |
if [ -n "$subarch" ] && [ "$subarch" != "$1" ]; then |
|
1.1.3
by Martin Michlmayr, Updated translations
* Convert the error about subarchitecture mismatches to a warning |
52 |
echo "Kernel $kfile does not match your subarchitecture" >&2 |
53 |
echo "$1, therefore not writing it to flash." >&2 |
|
54 |
exit 0
|
|
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
55 |
fi
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
56 |
}
|
57 |
||
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
58 |
check_size() { |
59 |
if [ $2 -gt $3 ]; then |
|
60 |
error "The $1 doesn't fit in flash." |
|
61 |
fi
|
|
62 |
}
|
|
63 |
||
|
4
by Loic Minier
flash-kernel: add support for Freescale MX51 Babbage Board; depend on |
64 |
check_fis() { |
65 |
if ! fis -d "$1" -o "$2" -s "$3" list >/dev/null; then |
|
66 |
error "fis list failed on device $1 at offset $2 with size $3" |
|
67 |
fi
|
|
68 |
}
|
|
69 |
||
70 |
# returns addr, size, and entry in hex, space separated; e.g. for the kernel
|
|
71 |
# partition, when fis list would return:
|
|
72 |
# kernel: addr = 0x00060000, size = 0x00400000, entry = 0x00100000, \
|
|
73 |
# length = 0x002144c0, cksum = 0xe9909335
|
|
74 |
# this function outputs:
|
|
75 |
# 00060000 00400000 00100000
|
|
76 |
fis_info() { |
|
77 |
LC_ALL=C fis -d "$1" -o "$2" -s "$3" list | sed -rn "s/^[[:space:]]*$4: addr = 0x([0-9a-f]{8}), size = 0x([0-9a-f]{8}), entry = 0x([0-9a-f]{8}), length = 0x[0-9a-f]{8}, cksum = 0x[0-9a-f]{8}\$/\1 \2 \3/p" |
|
78 |
}
|
|
79 |
||
80 |
# pass fis_info output in args and outputs the decimal offset
|
|
81 |
fis_offset() { |
|
82 |
printf %d 0x$1 |
|
83 |
}
|
|
84 |
||
85 |
# pass fis_info output in args and outputs the decimal size
|
|
86 |
fis_size() { |
|
87 |
printf %d 0x$2 |
|
88 |
}
|
|
89 |
||
90 |
# pass fis_info output in args and outputs the decimal entry point
|
|
91 |
fis_entry() { |
|
92 |
printf %d 0x$3 |
|
93 |
}
|
|
94 |
||
95 |
||
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
96 |
# See http://www.nslu2-linux.org/wiki/Info/BootFlash -- the NSLU2 uses a
|
|
2
by Martin Michlmayr, Joey Hess, Updated translations
[ Joey Hess ] |
97 |
# 16 byte MTD header, the first four bytes (big endian) give the length of
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
98 |
# the remainder of the image, and the remaining bytes are zero. Generate
|
99 |
# this header.
|
|
100 |
sercomm_header() { |
|
101 |
perl -e 'print pack("N4", shift)' "$1" |
|
102 |
}
|
|
103 |
||
104 |
nslu2_swap() { |
|
105 |
if [ "$little_endian" ]; then |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
106 |
devio "<<$1" "xp $,4" |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
107 |
else
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
108 |
cat "$1" |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
109 |
fi
|
110 |
}
|
|
111 |
||
|
6
by Loic Minier
* flash-kernel: fix generation of padded initramfs for imx51. |
112 |
# list of functions to call on cleanup
|
113 |
cleanup_funcs="" |
|
114 |
cleanup() { |
|
115 |
for f in $cleanup_funcs; do |
|
116 |
$f
|
|
117 |
done
|
|
118 |
}
|
|
119 |
||
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
120 |
# generic flash-kernel routines for specific subarchs
|
121 |
omap_flash_kernel() { |
|
|
24
by John Rigby
* changes to omap_flash_kernel() |
122 |
if [ -n "${UBOOT_PART}" ]; then |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
123 |
echo "Using u-boot partition: ${UBOOT_PART}" >&2 |
124 |
TMPMOUNT=$(mktemp -d) |
|
125 |
mount $UBOOT_PART $TMPMOUNT |
|
126 |
printf "Creating backups of uImage and uInitrd... " >&2 |
|
|
26
by Loïc Minier
* chmod +x flash-kernel in the source package, as in Debian. |
127 |
if [ -e $TMPMOUNT/uImage ]; then |
128 |
cp $TMPMOUNT/uImage $TMPMOUNT/uImage.bak |
|
129 |
fi
|
|
130 |
if [ -e $TMPMOUNT/uInitrd ]; then |
|
131 |
cp $TMPMOUNT/uInitrd $TMPMOUNT/uInitrd.bak |
|
132 |
fi
|
|
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
133 |
echo "done." >&2 |
134 |
printf "Generating kernel u-boot image... " >&2 |
|
135 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \
|
|
|
24
by John Rigby
* changes to omap_flash_kernel() |
136 |
-e 0x80008000 -n "Ubuntu Kernel" -d $kfile $TMPMOUNT/uImage >&2 1>/dev/null |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
137 |
echo "done." >&2 |
138 |
printf "Generating Initramfs u-boot image... " >&2 |
|
139 |
mkimage -A arm -O linux -T ramdisk -C none -a 0x0 -e 0x0 \
|
|
|
24
by John Rigby
* changes to omap_flash_kernel() |
140 |
-n "Ubuntu Initrd" -d $ifile $TMPMOUNT/uInitrd >&2 1>/dev/null |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
141 |
echo "done." >&2 |
142 |
if [ -e /boot/boot.script ];then |
|
143 |
printf "Generating u-boot configuration from /boot/boot.script... " >&2 |
|
144 |
cp $TMPMOUNT/boot.scr $TMPMOUNT/boot.scr.bak |
|
145 |
mkimage -A arm -T script -C none -n "Ubuntu boot script" -d /boot/boot.script \ |
|
146 |
$TMPMOUNT/boot.scr >&2 1>/dev/null
|
|
147 |
echo "done." >&2 |
|
148 |
fi
|
|
149 |
umount $TMPMOUNT |
|
150 |
rm -rf $TMPMOUNT
|
|
151 |
else
|
|
152 |
initrd_nand_size="16777216" |
|
153 |
check_mtd |
|
154 |
kmtd=$(mtdblock "Kernel") |
|
155 |
if [ -z "$kmtd" ]; then |
|
156 |
error "Cannot find mtd partition 'Kernel'" |
|
157 |
fi
|
|
158 |
check_dev_mtdblock "$kmtd" |
|
159 |
kmtdsize=$(mtdsize "Kernel") |
|
160 |
check_size "Kernel" $(($kfilesize + 8 + 64)) $kmtdsize |
|
161 |
||
162 |
printf "Generating kernel u-boot image... " >&2 |
|
163 |
tmp=$(tempfile) |
|
164 |
cat $kfile >> $tmp |
|
165 |
mkimage -A arm -O linux -T kernel -C none -a 0x80008000 \
|
|
166 |
-e 0x80008000 -n "Ubuntu Kernel" -d $tmp $tmp.uboot >&2 1>/dev/null |
|
167 |
echo "done." >&2 |
|
168 |
||
169 |
printf "Erasing Kernel NAND space... " >&2 |
|
170 |
dd if=/dev/zero of=$kmtd bs=$kmtdsize count=1 2>/dev/null |
|
171 |
echo "done." >&2 |
|
172 |
||
173 |
printf "Flashing kernel... " >&2 |
|
174 |
cat $tmp.uboot > $kmtd || error "failed." |
|
175 |
echo "done." >&2 |
|
176 |
rm -f $tmp.uboot $tmp |
|
177 |
||
178 |
imtd=$(mtdblock "File System") |
|
179 |
if [ -z "$imtd" ]; then |
|
180 |
error "Cannot find mtd partition for Initramfs" |
|
181 |
fi
|
|
182 |
check_dev_mtdblock "$imtd" |
|
183 |
check_size "Initramfs" $ifilesize $initrd_nand_size |
|
184 |
||
185 |
printf "Generating Initramfs u-boot image... " >&2 |
|
186 |
tmp=$(tempfile) |
|
187 |
cat $ifile >> $tmp |
|
188 |
mkimage -A arm -O linux -T ramdisk -C none -a 0x0 -e 0x0 \
|
|
189 |
-n "Ubuntu Initrd" -d $tmp $tmp.uboot >&2 1>/dev/null |
|
190 |
echo "done." >&2 |
|
191 |
||
192 |
printf "Erasing Initramfs NAND space... " >&2 |
|
193 |
dd if=/dev/zero of=$imtd bs=$initrd_nand_size count=1 2>/dev/null |
|
194 |
echo "done." >&2 |
|
195 |
||
196 |
printf "Flashing Initramfs... " >&2 |
|
197 |
cat $tmp.uboot > $imtd || error "failed." |
|
198 |
echo "done." >&2 |
|
199 |
rm -f $tmp.uboot $tmp |
|
200 |
fi
|
|
201 |
}
|
|
202 |
||
203 |
dove_flash_kernel() { |
|
204 |
tmp=$(tempfile) |
|
205 |
uboot_kernel_load_addr=0x00200000 |
|
206 |
uboot_initramfs_load_addr=0x01100000 |
|
207 |
script_load_addr=0x1000 |
|
208 |
||
209 |
printf "Generating kernel u-boot image... " >&2 |
|
210 |
cat $kfile >> $tmp |
|
211 |
mkimage -A arm -O linux -T kernel -C none -n "$desc" -a 0x00008000 \ |
|
212 |
-e 0x00008000 -d $tmp $tmp.uboot >&2 1>/dev/null |
|
213 |
echo "done." >&2 |
|
214 |
if [ -e /boot/uImage ]; then |
|
215 |
echo "Creating backup of /boot/uImage." >&2 |
|
216 |
mv /boot/uImage /boot/uImage.bak |
|
217 |
fi
|
|
218 |
echo "Creating new /boot/uImage." >&2 |
|
219 |
mv $tmp.uboot /boot/uImage
|
|
220 |
rm -f $tmp
|
|
221 |
printf "Generating initrd u-boot image... " >&2 |
|
222 |
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 \
|
|
223 |
-e 0x0 -n "$idesc" -d "$ifile" "$tmp.uboot" >&2 1>/dev/null |
|
224 |
echo "done." >&2 |
|
225 |
if [ -e /boot/uInitrd ]; then |
|
226 |
echo "Creating backup of /boot/uInitrd." >&2 |
|
227 |
mv /boot/uInitrd /boot/uInitrd.bak |
|
228 |
fi
|
|
229 |
echo "Creating new /boot/uInitrd." >&2 |
|
230 |
mv "$tmp.uboot" /boot/uInitrd
|
|
231 |
rm -f "$tmp.uboot"
|
|
232 |
printf "Generating new u-boot boot script..." >&2 |
|
233 |
# The UUID will come from the flash-kernel config file
|
|
234 |
cat >"$tmp.boot.script" <<EOF |
|
235 |
echo Starting Ubuntu...
|
|
236 |
if test -n \${fs} && test -n \${interface} && test -n \${device} && test -n \${prefix}; then
|
|
237 |
\${fs}load \${interface} \${device} $uboot_kernel_load_addr \${prefix}uImage
|
|
238 |
\${fs}load \${interface} \${device} $uboot_initramfs_load_addr \${prefix}uInitrd
|
|
239 |
setenv bootargs $rootfs ro quiet splash
|
|
240 |
bootm $uboot_kernel_load_addr $uboot_initramfs_load_addr
|
|
241 |
fi
|
|
242 |
||
243 |
echo boot information not recieved from u-boot, scanning for startup device
|
|
244 |
||
245 |
if test -e \${reinitalize_devices}; then
|
|
246 |
usb start;
|
|
247 |
ide reset;
|
|
248 |
fi
|
|
249 |
||
250 |
for i in usb ide; do
|
|
251 |
for j in 0 1; do
|
|
252 |
for l in / /boot/; do
|
|
253 |
for m in fat ext2; do
|
|
254 |
setenv interface \$i;
|
|
255 |
setenv device \$j;
|
|
256 |
setenv prefix \$l;
|
|
257 |
setenv fs \$m;
|
|
258 |
||
259 |
echo Scanning \${fs} \${interface} \${device} on prefix \${prefix} ...;
|
|
260 |
||
261 |
# This "if" avoids loading an old image but
|
|
262 |
# doesn't work in stock u-boot 1.3.4 and is
|
|
263 |
# only fixed in Canonical u-boot from October
|
|
264 |
# 1st or later
|
|
265 |
||
266 |
if \${fs}load \${interface} \${device} $script_load_addr \${prefix}boot.scr; then
|
|
267 |
if imi $script_load_addr; then
|
|
268 |
echo boot.scr found! Executing ...;
|
|
269 |
autoscr $script_load_addr;
|
|
270 |
fi;
|
|
271 |
fi
|
|
272 |
done;
|
|
273 |
done;
|
|
274 |
done;
|
|
275 |
done
|
|
276 |
echo No boot device found.;
|
|
277 |
EOF
|
|
278 |
mkimage -A arm -T script -C none -n "Ubuntu boot script" -d "$tmp.boot.script" \ |
|
279 |
"$tmp.boot.scr" >&2 1>/dev/null
|
|
280 |
echo "done." >&2 |
|
281 |
if [ -e /boot/boot.scr ]; then |
|
282 |
echo "Creating backup of /boot/boot.scr." >&2 |
|
283 |
mv /boot/boot.scr /boot/boot.scr.bak |
|
284 |
fi
|
|
285 |
echo "Creating new /boot/boot.scr." >&2 |
|
286 |
mv "$tmp.boot.scr" /boot/boot.scr
|
|
287 |
rm -f "$tmp.boot.script" "$tmp.boot.scr" |
|
288 |
}
|
|
289 |
||
|
7
by Loic Minier
* Used named signals for "trap". |
290 |
trap "cleanup" 0 HUP INT QUIT KILL SEGV PIPE TERM |
291 |
||
292 |
config="/etc/flash-kernel.conf" |
|
293 |
if [ -r "$config" ]; then |
|
294 |
. "$config"
|
|
295 |
fi
|
|
|
6
by Loic Minier
* flash-kernel: fix generation of padded initramfs for imx51. |
296 |
|
|
3.1.8
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
297 |
if [ "x$1" = "x--machine" ]; then |
298 |
machine=$2 |
|
299 |
shift 2
|
|
300 |
else
|
|
301 |
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') |
|
302 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
303 |
|
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
304 |
running_subarch=$(uname -r | sed -e 's/.*-//') |
305 |
||
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
306 |
if [ "x$1" = "x--supported" ]; then |
|
25
by Alexander Sack
skip flash-kernel with exit 0 if FLASH_KERNEL_SKIP env is set; in turn |
307 |
# if FLASH_KERNEL_SKIP is set, its always unsupported
|
308 |
if [ -n "$FLASH_KERNEL_SKIP" ]; then |
|
309 |
exit 1 |
|
310 |
fi
|
|
311 |
||
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
312 |
case "$machine" in |
|
29
by Oliver Grawert
merge versatile espress support from Matt Waddel <matt.waddel@linaro.org> |
313 |
"ARM-Versatile Express CA9x4") exit 0 ;; |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
314 |
"Buffalo Linkstation Pro/Live") exit 0 ;; |
315 |
"Buffalo/Revogear Kurobox Pro") exit 0 ;; |
|
316 |
"D-Link DNS-323") exit 0 ;; |
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
317 |
"Freescale MX51 Babbage Board") exit 0 ;; |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
318 |
"GLAN Tank") exit 0 ;; |
319 |
"HP Media Vault mv2120") exit 0 ;; |
|
|
28
by Oliver Grawert
merge Loïcs patch from bug 645659 to add IGEP2 support (not autoclosing |
320 |
"IGEP v2 board") exit 0 ;; |
|
13
by Loïc Minier, Loïc Minier, Michael Casadevall
[ Loïc Minier ] |
321 |
"Marvell DB-MV88F6781-BP Development Board") exit 0 ;; |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
322 |
"Linksys NSLU2") exit 0 ;; |
|
18
by Oliver Grawert
move uboot-envtools to a suggests, having it on the images will be handled |
323 |
"OMAP3 Beagle Board") exit 0 ;; |
|
21
by Oliver Grawert
add support for OMAP4 pandaboard |
324 |
"OMAP4430 Panda Board") exit 0 ;; |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
325 |
"OMAP4430 4430SDP board") exit 0 ;; |
|
3.1.5
by Martin Michlmayr, Colin Watson, Martin Michlmayr
[ Colin Watson ] |
326 |
"Marvell OpenRD Base Board") exit 0 ;; |
327 |
"Marvell OpenRD Client Board") exit 0 ;; |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
328 |
"Marvell SheevaPlug Reference Board") exit 0 ;; |
|
3.1.10
by Martin Michlmayr, John Holland, Updated translations
[ John Holland ] |
329 |
"Marvell eSATA SheevaPlug Reference Board") exit 0 ;; |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
330 |
"QNAP TS-109/TS-209" | "QNAP TS-409") exit 0 ;; |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
331 |
"QNAP TS-119/TS-219") exit 0 ;; |
|
3.1.9
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
332 |
"QNAP TS-41x") exit 0 ;; |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
333 |
"Thecus N2100") exit 0 ;; |
|
3.1.2
by Wouter Verhelst
Add support for Lanner EM7210 and compatibles (e.g., Intel SS4000-e) |
334 |
"Lanner EM7210") exit 0 ;; |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
335 |
*)
|
336 |
# we're supported if we have a generic fallback
|
|
337 |
case "$running_subarch" in |
|
338 |
"dove" | "omap" | "omap4") exit 0 ;; |
|
339 |
esac
|
|
340 |
exit 1 |
|
341 |
;; |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
342 |
esac
|
343 |
fi
|
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
344 |
|
|
25
by Alexander Sack
skip flash-kernel with exit 0 if FLASH_KERNEL_SKIP env is set; in turn |
345 |
if [ -n "$FLASH_KERNEL_SKIP" ]; then |
346 |
exit 0 |
|
347 |
fi
|
|
348 |
||
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
349 |
if [ -n "$1" ]; then |
350 |
kvers="$1" |
|
351 |
kfile=/boot/vmlinuz-$kvers |
|
352 |
ifile=/boot/initrd.img-$kvers |
|
|
13
by Loïc Minier, Loïc Minier, Michael Casadevall
[ Loïc Minier ] |
353 |
desc="Ubuntu kernel $1" |
354 |
idesc="Ubuntu ramdisk $1" |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
355 |
else
|
356 |
if [ -e /vmlinuz ]; then |
|
357 |
kfile=/vmlinuz |
|
358 |
ifile=/initrd.img |
|
359 |
elif [ -e /boot/vmlinuz ]; then |
|
360 |
kfile=/boot/vmlinuz |
|
361 |
ifile=/boot/initrd.img |
|
362 |
else
|
|
363 |
error "Cannot find a default kernel in /vmlinuz or /boot/vmlinuz" |
|
364 |
fi
|
|
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
365 |
desc="Debian kernel" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
366 |
idesc="Debian ramdisk" |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
367 |
fi
|
368 |
||
369 |
if [ ! -e $kfile ] || [ ! -e $ifile ]; then |
|
370 |
error "Can't find $kfile and $ifile" |
|
371 |
fi
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
372 |
kfilesize=$(wc -c "$kfile" | awk '{print $1}') |
373 |
ifilesize=$(wc -c "$ifile" | awk '{print $1}') |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
374 |
|
|
1.1.2
by Joey Hess, Otavio Salvador
[ Otavio Salvador ] |
375 |
# Extract the subarchitecture from the kernel name
|
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
376 |
if [ -L "$kfile" ]; then |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
377 |
kfile=$(readlink -e "$kfile") |
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
378 |
fi
|
379 |
subarch=$(echo "$kfile" | sed -e 's/.*-//') |
|
380 |
||
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
381 |
case "$machine" in |
|
29
by Oliver Grawert
merge versatile espress support from Matt Waddel <matt.waddel@linaro.org> |
382 |
"ARM-Versatile Express CA9x4") |
383 |
check_subarch "vexpress"
|
|
384 |
check_mtd |
|
385 |
||
386 |
kmtd=$(mtdblock "kernel") |
|
387 |
if [ -z "$kmtd" ]; then |
|
388 |
error "Cannot find mtd partition 'kernel'" |
|
389 |
fi
|
|
390 |
check_dev_mtdblock "$kmtd" |
|
391 |
kmtdsize=$(mtdsize "kernel") |
|
392 |
check_size "kernel" $(($kfilesize + 64)) $kmtdsize |
|
393 |
printf "Generating a u-boot compatible kernel image... " >&2 |
|
394 |
mkimage -A arm -O linux -T kernel -C none -a 0x60008000 \
|
|
395 |
-e 0x60008000 -n "$desc" -d $kfile $kfile.uboot \ |
|
396 |
>&2 1>/dev/null |
|
397 |
printf "Writing kernel to flash... " >&2 |
|
398 |
cat $kfile.uboot > $kmtd || error "failed." |
|
399 |
echo "done." >&2 |
|
400 |
rm -f $kfile.uboot
|
|
401 |
||
402 |
imtd=$(mtdblock "initrd") |
|
403 |
if [ -z "$imtd" ]; then |
|
404 |
error "Cannot find mtd partition for initrd" |
|
405 |
fi
|
|
406 |
check_dev_mtdblock "$imtd" |
|
407 |
imtdsize=$(mtdsize "initrd") |
|
408 |
check_size "initrd" $ifilesize $imtdsize |
|
409 |
printf "Generating u-boot compatible initrd image... " >&2 |
|
410 |
mkimage -A arm -O linux -T ramdisk -C none -a 0x81000000 \
|
|
411 |
-e 0x81000000 -n "$idesc" -d $ifile $ifile.uboot \ |
|
412 |
>&2 1>/dev/null |
|
413 |
printf "Writing initrd to flash... " >&2 |
|
414 |
cat $ifile.uboot > $imtd || error "failed." |
|
415 |
echo "done." >&2 |
|
416 |
rm -f $ifile.uboot
|
|
417 |
;; |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
418 |
"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro") |
419 |
check_subarch "orion5x"
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
420 |
tmp="$(tempfile)" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
421 |
printf "Generating kernel u-boot image... " >&2 |
422 |
case "$machine" in |
|
423 |
"Buffalo Linkstation Pro/Live") |
|
424 |
# Set machine id 1585 (0x0631)
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
425 |
devio > "$tmp" 'wl 0xe3a01c06,4' 'wl 0xe3811031,4' |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
426 |
;; |
427 |
"Buffalo/Revogear Kurobox Pro") |
|
428 |
# Set machine id 1509 (0x05e5)
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
429 |
devio > "$tmp" 'wl 0xe3a01c05,4' 'wl 0xe38110e5,4' |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
430 |
;; |
431 |
esac
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
432 |
cat "$kfile" >> "$tmp" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
433 |
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 \
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
434 |
-e 0x00008000 -n "$desc" -d "$tmp" "$tmp.uboot" >&2 1>/dev/null |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
435 |
echo "done." >&2 |
436 |
if [ -e /boot/uImage.buffalo ]; then |
|
437 |
echo "Creating backup of /boot/uImage.buffalo." >&2 |
|
438 |
mv /boot/uImage.buffalo /boot/uImage.buffalo.bak |
|
439 |
fi
|
|
440 |
echo "Creating new /boot/uImage.buffalo." >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
441 |
mv "$tmp.uboot" /boot/uImage.buffalo
|
442 |
rm -f "$tmp"
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
443 |
printf "Generating initrd u-boot image... " >&2 |
444 |
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 \
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
445 |
-e 0x0 -n "$idesc" -d "$ifile" "$tmp.uboot" >&2 1>/dev/null |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
446 |
echo "done." >&2 |
447 |
if [ -e /boot/initrd.buffalo ]; then |
|
448 |
echo "Creating backup of /boot/initrd.buffalo." >&2 |
|
449 |
mv /boot/initrd.buffalo /boot/initrd.buffalo.bak |
|
450 |
fi
|
|
451 |
echo "Creating new /boot/initrd.buffalo." >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
452 |
mv "$tmp.uboot" /boot/initrd.buffalo
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
453 |
;; |
454 |
"D-Link DNS-323") |
|
455 |
check_subarch "orion5x"
|
|
456 |
check_mtd |
|
457 |
imtd=$(mtdblock "File System") |
|
458 |
if [ -z "$imtd" ]; then |
|
459 |
error "Cannot find mtd partition 'File System'" |
|
460 |
fi
|
|
461 |
check_dev_mtdblock "$imtd" |
|
462 |
imtdsize=$(mtdsize "File System") |
|
463 |
check_size "File System" $((ifilesize + 64)) $imtdsize |
|
464 |
kmtd=$(mtdblock "Linux Kernel") |
|
465 |
if [ -z "$kmtd" ]; then |
|
466 |
error "Cannot find mtd partition 'Linux Kernel'" |
|
467 |
fi
|
|
468 |
check_dev_mtdblock "$kmtd" |
|
469 |
kmtdsize=$(mtdsize "Linux Kernel") |
|
470 |
check_size "Linux Kernel" $(($kfilesize + 8 + 64)) $kmtdsize |
|
471 |
printf "Generating kernel u-boot image... " >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
472 |
tmp="$(tempfile)" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
473 |
# Set machine id 1542 (0x0606)
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
474 |
devio > "$tmp" 'wl 0xe3a01c06,4' 'wl 0xe3811006,4' |
475 |
cat "$kfile" >> "$tmp" |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
476 |
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 \
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
477 |
-e 0x00008000 -n "$desc" -d "$tmp" "$tmp.uboot" >&2 1>/dev/null |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
478 |
echo "done." >&2 |
479 |
printf "Flashing kernel... " >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
480 |
cat "$tmp.uboot" > "$kmtd" || error "failed." |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
481 |
echo "done." >&2 |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
482 |
rm -f "$tmp.uboot" "$tmp" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
483 |
printf "Generating initramfs u-boot image... " >&2 |
484 |
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00800000 \
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
485 |
-e 0x00800000 -n "$idesc" -d "$ifile" "$tmp.uboot" >&2 1>/dev/null |
486 |
echo "done." >&2 |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
487 |
printf "Flashing initramfs... " >&2 |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
488 |
cat "$tmp.uboot" > "$imtd" || error "failed." |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
489 |
echo "done." >&2 |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
490 |
rm -f "$tmp.uboot"
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
491 |
;; |
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
492 |
"Freescale MX51 Babbage Board") |
493 |
check_subarch "imx51"
|
|
494 |
||
|
7
by Loic Minier
* Used named signals for "trap". |
495 |
for c in fis_dev fis_offset_hex fis_size_hex; do |
496 |
if [ -z "`eval echo \$$c`" ]; then |
|
497 |
error "$c not set in $config" |
|
498 |
fi
|
|
499 |
done
|
|
500 |
check_dev_mtdblock "$fis_dev" |
|
501 |
check_fis "$fis_dev" "$fis_offset_hex" "$fis_size_hex" |
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
502 |
|
503 |
# check for an "initrd" entry
|
|
504 |
initrd="initrd" |
|
|
7
by Loic Minier
* Used named signals for "trap". |
505 |
ifisinfo=$(fis_info "$fis_dev" "$fis_offset_hex" "$fis_size_hex" "initrd") |
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
506 |
# fallback on "initramfs"
|
507 |
if [ -z "$ifisinfo" ]; then |
|
508 |
initrd="initramfs" |
|
|
7
by Loic Minier
* Used named signals for "trap". |
509 |
ifisinfo=$(fis_info "$fis_dev" "$fis_offset_hex" "$fis_size_hex" "$initrd") |
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
510 |
if [ -z "$ifisinfo" ]; then |
511 |
error "Cannot find FIS partition '$initrd'" |
|
512 |
fi
|
|
513 |
fi
|
|
514 |
ifissize=$(fis_size $ifisinfo) |
|
515 |
check_size "$initrd" $ifilesize $ifissize |
|
516 |
||
|
7
by Loic Minier
* Used named signals for "trap". |
517 |
kfisinfo=$(fis_info "$fis_dev" "$fis_offset_hex" "$fis_size_hex" "kernel") |
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
518 |
if [ -z "$kfisinfo" ]; then |
519 |
error "Cannot find FIS partition 'kernel'" |
|
520 |
fi
|
|
521 |
kfissize=$(fis_size $kfisinfo) |
|
522 |
check_size "kernel" $kfilesize $kfissize |
|
523 |
||
524 |
kfisoffset=$(fis_offset $kfisinfo) |
|
525 |
kfisentry=$(fis_entry $kfisinfo) |
|
526 |
# the kernel is started at its load address so kfisram ==
|
|
527 |
# kfisentry
|
|
528 |
kfisram="$kfisentry" |
|
529 |
||
530 |
ifisoffset=$(fis_offset $ifisinfo) |
|
531 |
# not used
|
|
532 |
ifisentry=$(printf %d 0xffffffff) |
|
|
7
by Loic Minier
* Used named signals for "trap". |
533 |
# XXX hardcoded, should be read from RedBoot; but fis command
|
534 |
# currently doesn't return that info
|
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
535 |
ifisram=$(printf %d 0x1000000) |
536 |
||
537 |
printf "Flashing kernel... " >&2 |
|
|
7
by Loic Minier
* Used named signals for "trap". |
538 |
fis -d "$fis_dev" -o "$fis_offset_hex" -s "$fis_size_hex" create "kernel" -f $kfisoffset -l $kfissize -e $kfisentry -r $kfisram -c "$kfile" || error "FIS create failed." |
539 |
dd if="$kfile" of="$fis_dev" bs=$kfisoffset seek=1 2>/dev/null || error "update failed." |
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
540 |
echo "done." >&2 |
541 |
||
|
6
by Loic Minier
* flash-kernel: fix generation of padded initramfs for imx51. |
542 |
printf "Generating padded initramfs... " >&2 |
543 |
# padded initramfs; we need to use a temp file because of the
|
|
544 |
# fis command which needs to see a padded datalength
|
|
545 |
ipadded="" |
|
546 |
# cleanup handler which removes the generated temp file when
|
|
547 |
# this script finished
|
|
548 |
cleanup_ipadded() { |
|
549 |
if [ -n "$ipadded" ]; then |
|
550 |
rm -f "$ipadded" |
|
551 |
fi
|
|
552 |
}
|
|
553 |
cleanup_funcs="cleanup_ipadded $cleanup_funcs" |
|
554 |
ipadded=$(mktemp -t flash-kernel.XXXXXXXXXX) |
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
555 |
pad=$(expr $ifissize - $ifilesize) |
556 |
(
|
|
557 |
cat $ifile
|
|
|
6
by Loic Minier
* flash-kernel: fix generation of padded initramfs for imx51. |
558 |
# pad with zeroes; this uses $pad mem, not very elegant
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
559 |
dd if=/dev/zero bs=$pad count=1 2>/dev/null |
|
6
by Loic Minier
* flash-kernel: fix generation of padded initramfs for imx51. |
560 |
) | dd of="$ipadded" bs=4k 2>/dev/null || error "failed." |
561 |
echo "done." >&2 |
|
562 |
||
563 |
printf "Flashing initramfs... " >&2 |
|
|
7
by Loic Minier
* Used named signals for "trap". |
564 |
fis -d "$fis_dev" -o "$fis_offset_hex" -s "$fis_size_hex" create "$initrd" -f $ifisoffset -l $ifissize -e $ifisentry -r $ifisram -c "$ipadded" || error "FIS create failed." |
565 |
dd if="$ipadded" of="$fis_dev" bs=$ifisoffset seek=1 2>/dev/null || error "failed." |
|
|
5
by Loic Minier
* flash-kernel: Move Freescale MX51 Babbage Board around to be in its |
566 |
echo "done." >&2 |
567 |
;; |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
568 |
"GLAN Tank") |
569 |
rm -f /boot/initrd /boot/zImage |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
570 |
ln -s "$(basename "$ifile")" /boot/initrd |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
571 |
(
|
572 |
# Set machine id 1100 (0x044c)
|
|
573 |
devio 'wl 0xe3a01c04,4' 'wl 0xe381104c,4' |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
574 |
cat "$kfile"
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
575 |
) > /boot/zImage
|
576 |
;; |
|
577 |
"HP Media Vault mv2120") |
|
578 |
check_subarch "orion5x"
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
579 |
tmp="$(tempfile)" |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
580 |
printf "Generating kernel u-boot image... " >&2 |
581 |
# Set machine id 1693 (0x069d)
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
582 |
devio > "$tmp" 'wl 0xe3a01c06,4' 'wl 0xe381109d,4' |
583 |
cat "$kfile" >> "$tmp" |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
584 |
mkimage -A arm -O linux -T multi -C none -n "$desc" -a 0x01000000 \ |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
585 |
-e 0x01000000 -d "$tmp:$ifile" "$tmp.uboot" >&2 1>/dev/null |
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
586 |
echo "done." >&2 |
587 |
if [ -e /boot/uImage ]; then |
|
588 |
echo "Creating backup of /boot/uImage." >&2 |
|
589 |
mv /boot/uImage /boot/uImage.bak |
|
590 |
fi
|
|
591 |
echo "Creating new /boot/uImage." >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
592 |
mv "$tmp.uboot" /boot/uImage
|
593 |
rm -f "$tmp"
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
594 |
;; |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
595 |
"Linksys NSLU2") |
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
596 |
check_subarch "ixp4xx"
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
597 |
case "$(dpkg --print-architecture)" in |
|
2
by Martin Michlmayr, Joey Hess, Updated translations
[ Joey Hess ] |
598 |
arm|armel)
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
599 |
little_endian=1 |
600 |
;; |
|
601 |
armeb)
|
|
602 |
little_endian=0 |
|
603 |
;; |
|
604 |
esac
|
|
|
1.1.2
by Joey Hess, Otavio Salvador
[ Otavio Salvador ] |
605 |
check_mtd
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
606 |
fismtd=$(mtdblock "FIS directory") |
607 |
if [ -z "$fismtd" ]; then |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
608 |
error "Cannot find mtd FIS directory" |
609 |
fi
|
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
610 |
kmtd=$(mtdblock Kernel) |
611 |
if [ -z "$kmtd" ]; then |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
612 |
error "Cannot find mtd partition 'Kernel'" |
613 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
614 |
check_dev_mtdblock "$kmtd" |
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
615 |
kmtdsize=$(mtdsize "Kernel") |
616 |
check_size "kernel" $(($kfilesize + 16 + 16)) $kmtdsize |
|
617 |
imtd=$(mtdblock Ramdisk) |
|
618 |
if [ -z "$imtd" ]; then |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
619 |
error "Cannot find mtd partition 'Ramdisk'" |
620 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
621 |
check_dev_mtdblock "$imtd" |
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
622 |
imtdsize=$(mtdsize "Ramdisk") |
623 |
check_size "ramdisk" $(($ifilesize + 16)) $imtdsize |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
624 |
# The following devio magic parses the FIS directory to
|
625 |
# obtain the size, offset and name of each partition. This
|
|
626 |
# used used to obtain the offset of the Kernel partition.
|
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
627 |
offset=$(echo "$(devio "<<$fismtd" ' |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
628 |
<= $ 0x20000 -
|
629 |
L= 0x1000
|
|
630 |
$( 1
|
|
631 |
# 0xff byte in name[0] ends the partition table
|
|
632 |
$? @ 255 =
|
|
633 |
# output size base name
|
|
634 |
<= f15+
|
|
635 |
.= b 0xfffffff &
|
|
636 |
<= f4+
|
|
637 |
.= b
|
|
638 |
pf "%lu %lu " |
|
639 |
<= f28-
|
|
640 |
cp 16
|
|
641 |
pn
|
|
642 |
<= f240+
|
|
643 |
L= L256-
|
|
644 |
$) L255>')" |
|
|
645 |
while read a b c; do |
|
646 |
if [ "$c" = "Kernel" ]; then |
|
647 |
echo $b |
|
648 |
fi
|
|
649 |
done)
|
|
650 |
# The Kernel partition, starting at $offset, is divided into
|
|
651 |
# two areas at $boundary. We therefore need to split the
|
|
652 |
# kernel into two and write them to flash with two Sercomm
|
|
653 |
# headers.
|
|
654 |
boundary=1441792 # 0x00160000 |
|
655 |
ksize1=$(expr $boundary - $offset - 16) |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
656 |
tmp="$(tempfile)" |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
657 |
printf "Flashing kernel: " >&2 |
658 |
(
|
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
659 |
sercomm_header $(expr $kfilesize + 16) |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
660 |
dd if="$kfile" of="$tmp" bs=$ksize1 count=1 2>/dev/null |
661 |
nslu2_swap "$tmp"
|
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
662 |
sercomm_header 131072 |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
663 |
dd if="$kfile" of="$tmp" ibs=$ksize1 skip=1 2>/dev/null |
664 |
nslu2_swap "$tmp"
|
|
665 |
rm -f "$tmp"
|
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
666 |
) > "$kmtd" || error "failed." |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
667 |
echo "done." >&2 |
668 |
printf "Flashing initramfs: " >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
669 |
dd if="$ifile" of="$tmp" ibs=$(($imtdsize - 16)) conv=sync 2>/dev/null |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
670 |
(
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
671 |
sercomm_header $ifilesize
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
672 |
nslu2_swap "$tmp"
|
673 |
rm -f "$tmp"
|
|
674 |
) > "$imtd" || error "failed." |
|
675 |
echo "done." >&2 |
|
676 |
;; |
|
|
3.1.10
by Martin Michlmayr, John Holland, Updated translations
[ John Holland ] |
677 |
"Marvell OpenRD Base Board" | "Marvell OpenRD Client Board" | "Marvell SheevaPlug Reference Board" | "Marvell eSATA SheevaPlug Reference Board") |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
678 |
check_subarch "kirkwood"
|
679 |
tmp="$(tempfile)" |
|
680 |
printf "Generating kernel u-boot image... " >&2 |
|
681 |
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 \
|
|
|
3.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
682 |
-e 0x00008000 -n "$desc" -d "$kfile" "$tmp.uboot" >&2 1>/dev/null |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
683 |
echo "done." >&2 |
684 |
if [ -e /boot/uImage ]; then |
|
685 |
echo "Creating backup of /boot/uImage." >&2 |
|
686 |
mv /boot/uImage /boot/uImage.bak |
|
687 |
fi
|
|
688 |
echo "Creating new /boot/uImage." >&2 |
|
689 |
mv "$tmp.uboot" /boot/uImage
|
|
690 |
printf "Generating initrd u-boot image... " >&2 |
|
691 |
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 \
|
|
692 |
-e 0x0 -n "$idesc" -d "$ifile" "$tmp.uboot" >&2 1>/dev/null |
|
693 |
echo "done." >&2 |
|
694 |
if [ -e /boot/uInitrd ]; then |
|
695 |
echo "Creating backup of /boot/uInitrd." >&2 |
|
696 |
mv /boot/uInitrd /boot/uInitrd.bak |
|
697 |
fi
|
|
698 |
echo "Creating new /boot/uInitrd." >&2 |
|
699 |
mv "$tmp.uboot" /boot/uInitrd
|
|
|
3.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
700 |
rm -f "$tmp"
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
701 |
;; |
|
13
by Loïc Minier, Loïc Minier, Michael Casadevall
[ Loïc Minier ] |
702 |
"Marvell DB-MV88F6781-BP Development Board") |
703 |
check_subarch "dove"
|
|
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
704 |
dove_flash_kernel |
|
13
by Loïc Minier, Loïc Minier, Michael Casadevall
[ Loïc Minier ] |
705 |
;; |
|
28
by Oliver Grawert
merge Loïcs patch from bug 645659 to add IGEP2 support (not autoclosing |
706 |
"IGEP v2 board" | "OMAP3 Beagle Board" | "OMAP4430 4430SDP board" | "OMAP4430 Panda Board") |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
707 |
case "$machine" in |
|
28
by Oliver Grawert
merge Loïcs patch from bug 645659 to add IGEP2 support (not autoclosing |
708 |
"IGEP v2 board"|"OMAP3 Beagle Board") |
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
709 |
check_subarch "omap"
|
710 |
;; |
|
711 |
"OMAP4430 4430SDP board" | "OMAP4430 Panda Board") |
|
712 |
check_subarch "omap4"
|
|
713 |
;; |
|
714 |
esac
|
|
715 |
omap_flash_kernel
|
|
|
18
by Oliver Grawert
move uboot-envtools to a suggests, having it on the images will be handled |
716 |
;; |
|
3.1.9
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
717 |
"QNAP TS-109/TS-209" | "QNAP TS-119/TS-219" | "QNAP TS-409" | "QNAP TS-41x") |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
718 |
case "$machine" in |
719 |
"QNAP TS-109/TS-209" | "QNAP TS-409") |
|
720 |
check_subarch "orion5x"
|
|
721 |
;; |
|
|
3.1.9
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
722 |
"QNAP TS-119/TS-219" | "QNAP TS-41x") |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
723 |
check_subarch "kirkwood"
|
724 |
;; |
|
725 |
esac
|
|
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
726 |
check_mtd
|
727 |
imtd=$(mtdblock "RootFS1") |
|
728 |
if [ -z "$imtd" ]; then |
|
729 |
error "Cannot find mtd partition 'RootFS1'" |
|
730 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
731 |
check_dev_mtdblock "$imtd" |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
732 |
imtdsize=$(mtdsize "RootFS1") |
733 |
check_size "RootFS1" $ifilesize $imtdsize |
|
734 |
kmtd=$(mtdblock Kernel) |
|
735 |
if [ -z "$kmtd" ]; then |
|
736 |
error "Cannot find mtd partition 'Kernel'" |
|
737 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
738 |
check_dev_mtdblock "$kmtd" |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
739 |
kmtdsize=$(mtdsize "Kernel") |
740 |
check_size "Kernel" $(($kfilesize + 8 + 64)) $kmtdsize |
|
741 |
printf "Generating kernel u-boot image... " >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
742 |
tmp="$(tempfile)" |
|
1.1.8
by Martin Michlmayr
Add support for QNAP TS-409. |
743 |
case "$machine" in |
744 |
"QNAP TS-109/TS-209") |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
745 |
# Set machine id 1565 (0x061d)
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
746 |
devio > "$tmp" 'wl 0xe3a01c06,4' 'wl 0xe381101d,4' |
747 |
;; |
|
748 |
"QNAP TS-119/TS-219") |
|
749 |
# Set machine id 2139 (0x085b)
|
|
750 |
devio > "$tmp" 'wl 0xe3a01c08,4' 'wl 0xe381105b,4' |
|
|
1.1.8
by Martin Michlmayr
Add support for QNAP TS-409. |
751 |
;; |
752 |
"QNAP TS-409") |
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
753 |
# Set machine id 1601 (0x0641)
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
754 |
devio > "$tmp" 'wl 0xe3a01c06,4' 'wl 0xe3811041,4' |
|
1.1.8
by Martin Michlmayr
Add support for QNAP TS-409. |
755 |
;; |
|
3.1.9
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
756 |
"QNAP TS-41x") |
757 |
# Set machine id 2502 (0x09c6)
|
|
758 |
devio > "$tmp" 'wl 0xe3a01c09,4' 'wl 0xe38110c6,4' |
|
759 |
;; |
|
|
1.1.8
by Martin Michlmayr
Add support for QNAP TS-409. |
760 |
esac
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
761 |
cat "$kfile" >> "$tmp" |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
762 |
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 \
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
763 |
-e 0x00008000 -n "$desc" -d "$tmp" "$tmp.uboot" >&2 1>/dev/null |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
764 |
echo "done." >&2 |
765 |
printf "Flashing kernel... " >&2 |
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
766 |
cat "$tmp.uboot" > "$kmtd" || error "failed." |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
767 |
echo "done." >&2 |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
768 |
rm -f "$tmp.uboot" "$tmp" |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
769 |
printf "Flashing initramfs... " >&2 |
770 |
pad=$(expr $imtdsize - $ifilesize) |
|
771 |
(
|
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
772 |
cat "$ifile"
|
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
773 |
dd if=/dev/zero bs=$pad count=1 2>/dev/null |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
774 |
) > "$imtd" || error "failed." |
|
1.1.6
by Martin Michlmayr, Martin Michlmayr
[ Martin Michlmayr ] |
775 |
echo "done." >&2 |
776 |
;; |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
777 |
"Thecus N2100") |
|
1.1.1
by Martin Michlmayr, Martin Michlmayr, Rod Whitby, Gordon Farquharson, Updated translations
[ Martin Michlmayr ] |
778 |
check_subarch "iop32x"
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
779 |
check_mtd |
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
780 |
imtd=$(mtdblock ramdisk) |
781 |
if [ -z "$imtd" ]; then |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
782 |
error "Cannot find mtd partition 'ramdisk'" |
783 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
784 |
check_dev_mtdblock "$imtd" |
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
785 |
imtdsize=$(mtdsize "ramdisk") |
786 |
check_size "ramdisk" $ifilesize $imtdsize |
|
787 |
kmtd=$(mtdblock kernel) |
|
788 |
if [ -z "$kmtd" ]; then |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
789 |
error "Cannot find mtd partition 'kernel'" |
790 |
fi
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
791 |
check_dev_mtdblock "$kmtd" |
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
792 |
kmtdsize=$(mtdsize "kernel") |
793 |
check_size "kernel" $(($kfilesize + 8)) $kmtdsize |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
794 |
printf "Flashing kernel... " >&2 |
795 |
(
|
|
|
1.1.9
by Frans Pop, Updated translations
[ Updated translations ] |
796 |
# Set machine id 1101 (0x044d)
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
797 |
devio 'wl 0xe3a01c04,4' 'wl 0xe381104d,4' |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
798 |
cat "$kfile"
|
799 |
) > "$kmtd" || error "failed." |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
800 |
echo "done." >&2 |
801 |
printf "Flashing initramfs... " >&2 |
|
|
1.1.5
by Martin Michlmayr
* Check whether kernel and ramdisk fit into flash before writing |
802 |
pad=$(expr $imtdsize - $ifilesize) |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
803 |
(
|
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
804 |
cat "$ifile"
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
805 |
dd if=/dev/zero bs=$pad count=1 2>/dev/null |
|
3.1.1
by Martin Michlmayr
Add support for the SheevaPlug. |
806 |
) > "$imtd" || error "failed." |
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
807 |
echo "done." >&2 |
808 |
;; |
|
|
3.1.2
by Wouter Verhelst
Add support for Lanner EM7210 and compatibles (e.g., Intel SS4000-e) |
809 |
"Lanner EM7210") |
810 |
# Really: Intel SS4000-e and compatibles
|
|
811 |
check_subarch "iop32x"
|
|
812 |
check_mtd |
|
813 |
imtd=$(mtdblock "ramdisk.gz") |
|
814 |
if [ -z "$imtd" ]; then |
|
815 |
error "Cannot find mtd partition 'ramdisk.gz'" |
|
816 |
fi
|
|
817 |
check_dev_mtdblock "$imtd" |
|
818 |
imtdsize=$(mtdsize "ramdisk.gz") |
|
819 |
check_size "ramdisk" $ifilesize $imtdsize |
|
820 |
kmtd=$(mtdblock zImage) |
|
821 |
if [ -z "$kmtd" ]; then |
|
822 |
error "Cannot find mtd partition 'zImage'" |
|
823 |
fi
|
|
824 |
kmtdsize=$(mtdsize "zImage") |
|
825 |
check_size "zImage" $(($kfilesize + 8)) $kmtdsize |
|
826 |
printf "Flashing kernel..." >&2 |
|
827 |
(
|
|
828 |
# Set machine ID 1212 (0x04bc)
|
|
829 |
devio 'wl 0xe3a01c04,4' 'wl 0xe38110bc,4' |
|
830 |
cat "$kfile"
|
|
831 |
) > "$kmtd" || error "failed." |
|
832 |
echo "done." >&2 |
|
833 |
printf "Flashing initramfs... " >&2 |
|
834 |
pad=$(expr $imtdsize - $ifilesize) |
|
835 |
(
|
|
836 |
cat "$ifile"
|
|
837 |
dd if=/dev/zero bs=$pad count=1 2>/dev/null |
|
838 |
) > "$imtd" || error "failed." |
|
839 |
echo "done." >&2 |
|
840 |
;; |
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
841 |
*)
|
|
23
by Michael Casadevall
* Implement generic subarchitecture support (LP: #607723) |
842 |
case "$running_subarch" in |
843 |
"dove" | "omap" | "omap4") |
|
844 |
echo "warning: using generic subarchitecture fallback for $running_subarch" |
|
845 |
check_subarch $running_subarch
|
|
846 |
||
847 |
case "$subarch" in |
|
848 |
"dove") |
|
849 |
dove_flash_kernel |
|
850 |
;; |
|
851 |
"omap" | "omap4") |
|
852 |
omap_flash_kernel |
|
853 |
;; |
|
854 |
esac
|
|
855 |
;; |
|
856 |
*)
|
|
857 |
error "Unsupported platform."
|
|
858 |
;; |
|
859 |
esac
|
|
|
1
by Martin Michlmayr, Martin Michlmayr, Updated translations
[ Martin Michlmayr ] |
860 |
;; |
861 |
esac
|
|
862 |