3 # Copyright © 2010-2017
4 # Waldemar Brodkorb <wbx@openadk.org>
5 # Thorsten Glaser <tg@mirbsd.org>
7 # Provided that these terms and disclaimer and all copyright notices
8 # are retained or reproduced in an accompanying document, permission
9 # is granted to deal in this work without restriction, including un‐
10 # limited rights to use, publicly perform, distribute, sell, modify,
11 # merge, give away, or sublicence.
13 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
14 # the utmost extent permitted by applicable law, neither express nor
15 # implied; without malicious intent or gross negligence. In no event
16 # may a licensor, author or contributor be held liable for indirect,
17 # direct, other damage, loss, or other issues arising in any way out
18 # of dealing in the work, even if advised of the possibility of such
19 # damage or existence of a defect, except proven that it results out
20 # of said person’s immediate fault when using the work as intended.
22 # Alternatively, this work may be distributed under the terms of the
23 # General Public License, any version, as published by the Free Soft-
26 # Prepare a USB stick or CF/SD/MMC card or hard disc for installation
30 HOST
=$
(gcc
-dumpmachine)
34 (*:$ADK_TOPDIR/host_
$HOST/usr
/bin
:*) ;;
35 (*) export PATH
=$PATH:$ADK_TOPDIR/host_
$HOST/usr
/bin
;;
38 test -n "$KSH_VERSION" ||
exec mksh
"$me" "$@"
39 if test -z "$KSH_VERSION"; then
40 echo >&2 Fatal error
: could not run myself with mksh
!
44 ### run with mksh from here onwards ###
48 if (( USER_ID
)); then
49 print
-u2 Installation is only possible as root
!
53 ADK_TOPDIR
=$
(realpath .
)
71 Syntax: $me [-f filesystem] [-c cfgfssize] [-d datafssize] [-D datafscontent] [-k] [-n] [-g]
72 [-p panictime] [±q] [-s serialspeed] [±t] <target> <device> <archive>
73 Partition sizes are in MiB. Filesystem type is currently ignored (ext4).
74 To keep filesystem on data partition use -k.
75 Use -n to not format boot/root partition.
76 Defaults: -c 1 -p 10 -s 115200; -t = enable serial console
80 while getopts "c:d:D:ef:ghknp:qs:tx:" ch
; do
82 (c
) if (( (cfgfs
= OPTARG
) < 0 || cfgfs
> 16 )); then
83 print
-u2 "$me: -c $OPTARG out of bounds"
86 (d
) if (( (datafssz
= OPTARG
) < 0 )); then
87 print
-u2 "$me: -d $OPTARG out of bounds"
91 (f
) if [[ $OPTARG != @
(ext2|ext3|ext4|xfs
) ]]; then
92 print
-u2 "$me: filesystem $OPTARG invalid"
99 (p
) if (( (panicreboot
= OPTARG
) < 0 || panicreboot
> 300 )); then
100 print
-u2 "$me: -p $OPTARG out of bounds"
105 (s
) if [[ $OPTARG != @
(96|
192|
384|
576|
1152)00 ]]; then
106 print
-u2 "$me: serial speed $OPTARG invalid"
113 (D
) if [[ ! -d $OPTARG ]]; then
114 print
-u2 "$me: -D $OPTARG must be an existing directory"
117 datapartcontent
=$OPTARG;;
121 shift $
((OPTIND
- 1))
123 (( $# == 3 )) || usage
1
128 tools
="bc mkfs.ext4 mkfs.vfat tune2fs partprobe"
132 if [[ $paragon_ext == 0 ]]; then
133 export PATH
=/usr
/local
/opt
/e2fsprogs
/sbin
:/usr
/local
/opt
/e2fsprogs
/bin
:$PATH
134 tools
="$tools fuse-ext2 umount mkfs.ext4 tune2fs"
138 print
-u2 Sorry
, not ported to the OS
"'$ostype'" yet.
142 for tool
in $tools; do
143 print
-n Checking
if $tool is installed...
144 if whence
-p $tool >/dev
/null
; then
158 (banana-pro|orange-pi0|pcengines-apu|phytec-wega|raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi3p|raspberry-pi3p-64|solidrun-imx6|solidrun-clearfog|default
) ;;
160 print
-u2 "Unknown target '$target', exiting"
163 if [[ ! -b $tgt ]]; then
164 print
-u2 "'$tgt' is not a block device, exiting"
167 if [[ ! -f $src ]]; then
168 print
-u2 "'$src' is not a file, exiting"
171 (( quiet
)) || print
"Installing $src on $tgt."
175 R
=/Volumes
/ADKROOT
; diskutil unmount
$R || umount
$R
176 B
=/Volumes
/ADKBOOT
; diskutil unmount
$B || umount
$B
177 D
=/Volumes
/ADKDATA
; diskutil unmount
$D || umount
$D
179 rootpart
=${basedev}s1
180 datapart
=${basedev}s2
181 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi3p ||
$target = raspberry-pi3p-64 ||
$target = phytec-wega
]]; then
182 bootpart
=${basedev}s1
183 rootpart
=${basedev}s2
184 datapart
=${basedev}s3
186 match
=\'${basedev}\''?(s+([0-9]))'
188 if [[ $paragon_ext == 0 && $3 = ext4
]]; then
190 fuse-ext2
"$1" "$2" -o rw
+
194 (( quiet
)) || print
"Unmounting filesystem on ${1}..."
195 if [[ $paragon_ext == 0 ]]; then
196 umount
"$1" || diskutil unmount
"$1" || true
199 diskutil unmount
"$1"
203 (( quiet
)) ||
printf "Creating filesystem on ${1}"
204 if [[ $paragon_ext == 0 && $3 = ext4
]]; then
205 mkfs.ext4
-L "$2" "$1"
207 if [[ $3 = ext4
]]; then
210 if [[ $3 = vfat
]]; then
213 diskutil eraseVolume
$fstype "$2" "$1"
217 if [[ $paragon_ext == 0 && $3 = ext4
]]; then
218 tune2fs
-c 0 -i 0 "$1"
225 if [[ $basedev = /dev
/loop
* ]]; then
226 (( quiet
)) || print
"${tgt} is a loop device"
230 rootpart
=${basedev}${partitionsep}1
231 datapart
=${basedev}${partitionsep}2
232 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi3p ||
$target = raspberry-pi3p-64
]]; then
233 bootpart
=${basedev}${partitionsep}1
234 rootpart
=${basedev}${partitionsep}2
235 datapart
=${basedev}${partitionsep}3
238 match
=\'${basedev}${partitionsep}\''+([0-9])'
240 (( quiet
)) || print
"Mounting filesystem on ${1}..."
241 mount
-t "$3" "$1" "$2"
244 (( quiet
)) || print
"Unmounting filesystem on ${1}..."
248 (( quiet
)) || print
"Creating filesystem on ${1}..."
252 tune2fs
-c 0 -i 0 "$1"
258 while read -p dev rest
; do
259 eval [[ \
$dev = $match ]] ||
continue
260 print
-u2 "Block device $tgt is in use, please umount first."
264 if (( !quiet
)); then
265 print
"WARNING: This will overwrite $basedev - type Yes to continue!"
267 [[ $x = Yes
]] ||
exit 0
270 if ! T
=$
(mktemp
-d /tmp
/openadk.XXXXXXXXXX
); then
271 print
-u2 Error creating temporary directory.
274 if [[ $ostype != Darwin
]]; then
278 mkdir
-p "$R" "$B" "$D"
282 dksz
=$
(dkgetsz
"$tgt")
285 # n̲a̲m̲e̲ p̲a̲r̲t̲#̲0̲ p̲̲a̲r̲t̲#̲1̲ p̲̲a̲r̲t̲#̲2̲ p̲̲a̲r̲t̲#̲3̲
286 # default: 0x83(system) 0x83(?data) -(unused) 0x88(cfgfs)
287 # raspberry: 0x0B(boot) 0x83(system) 0x83(?data) 0x88(cfgfs)
292 # boot(raspberry) - fixed (100 MiB)
293 # cfgfs - fixed (parameter, max. 16 MiB)
294 # data - flexible (parameter)
295 # system - everything else
297 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi3p ||
$target = raspberry-pi3p-64 ||
$target = phytec-wega
]]; then
301 print
-u2 "Cannot combine GRUB with $target"
311 (( cyls
= dksz
/ heads
/ secs
))
312 if (( cyls
< (bootfssz
+ cfgfs
+ datafssz
+ 2) )); then
313 print
-u2 "Size of $tgt is $dksz, this looks fishy?"
318 if stat
-qs .
>/dev
/null
2>&1; then
319 statcmd
='stat -f %z' # BSD stat (or so we assume)
321 statcmd
='stat -c %s' # GNU stat
325 tar -xOf "$src" boot
/grub
/core.img
>"$T/core.img"
326 integer coreimgsz
=$
($statcmd "$T/core.img")
330 if (( coreimgsz
< 1024 )); then
331 print
-u2 core.img is probably too small
: $coreimgsz
335 if (( coreimgsz
> 65024 )); then
336 print
-u2 core.img is larger than
64K-512
: $coreimgsz
340 (( coreendsec
= (coreimgsz
+ 511) / 512 ))
341 if [[ $basedev = /dev
/svnd
+([0-9]) ]]; then
342 # BSD svnd0 mode: protect sector #1
345 corepatchofs
=$
((0x614))
348 corepatchofs
=$
((0x414))
350 # partition offset: at least coreendsec+1 but aligned on a multiple of secs
351 #(( partofs = ((coreendsec / secs) + 1) * secs ))
352 # we just use 2048 all the time, since some loaders are longer
354 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi3p ||
$target = raspberry-pi3p-64 ||
$target = phytec-wega
]]; then
355 (( spartofs
= partofs
+ (100 * 2048) ))
360 (( quiet
)) ||
if (( grub
)); then
361 print Preparing MBR and GRUB2...
363 print Preparing MBR...
365 dd if=/dev
/zero of
="$T/firsttrack" count
=$partofs 2>/dev
/null
366 # add another MiB to clear the first partition
367 dd if=/dev
/zero bs
=1048576 count
=1 >>"$T/firsttrack" 2>/dev
/null
368 echo $corestartsec $coreendsec | mksh
"$ADK_TOPDIR/scripts/bootgrub.mksh" \
369 -A -g $
((cyls
- bootfssz
- cfgfs
- datafssz
)):$heads:$secs -M 1:0x83 \
370 -O $spartofs |
dd of
="$T/firsttrack" conv
=notrunc
2>/dev
/null
371 (( grub
)) && dd if="$T/core.img" of
="$T/firsttrack" conv
=notrunc \
372 seek
=$corestartsec 2>/dev
/null
373 # set partition where it can find /boot/grub
374 (( grub
)) && print
-n '\0\0\0\0' | \
375 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$corepatchofs 2>/dev
/null
377 # create cfgfs partition (mostly taken from bootgrub.mksh)
379 typeset
-Uui8 thecode
381 set -A g_code
$cyls $heads $secs
382 (( psz
= g_code
[0] * g_code
[1] * g_code
[2] ))
383 (( pofs
= (cyls
- cfgfs
) * g_code
[1] * g_code
[2] ))
384 set -A o_code
# g_code equivalent for partition offset
385 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
386 (( o_code
[1] = pofs
/ g_code
[2] ))
387 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
388 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
389 # boot flag; C/H/S offset
390 thecode
[mbrpno
++]=0x00
391 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
392 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
393 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
394 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
395 # partition type; C/H/S end
396 (( thecode
[mbrpno
++] = 0x88 ))
397 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
398 (( cylno
= g_code
[0] > 1024 ?
1023 : g_code
[0] - 1 ))
399 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
400 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
401 # partition offset, size (LBA)
402 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
403 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
404 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
405 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
406 (( pssz
= psz
- pofs
))
407 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
408 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
409 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
410 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
411 # write partition table entry
414 while (( curptr
< 16 )); do
415 ostr
=$ostr\\0${thecode[curptr++]#8#}
418 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1EE)) 2>/dev
/null
420 if (( datafssz
)); then
421 # create data partition (copy of the above :)
423 typeset
-Uui8 thecode
425 set -A g_code
$cyls $heads $secs
426 (( psz
= (cyls
- cfgfs
) * g_code
[1] * g_code
[2] ))
427 (( pofs
= (cyls
- cfgfs
- datafssz
) * g_code
[1] * g_code
[2] ))
428 set -A o_code
# g_code equivalent for partition offset
429 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
430 (( o_code
[1] = pofs
/ g_code
[2] ))
431 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
432 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
433 # boot flag; C/H/S offset
434 thecode
[mbrpno
++]=0x00
435 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
436 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
437 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
438 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
439 # partition type; C/H/S end
440 (( thecode
[mbrpno
++] = 0x83 ))
441 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
442 (( cylno
= (g_code
[0] - cfgfs
) > 1024 ?
1023 : g_code
[0] - cfgfs
- 1 ))
443 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
444 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
445 # partition offset, size (LBA)
446 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
447 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
448 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
449 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
450 (( pssz
= psz
- pofs
))
451 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
452 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
453 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
454 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
455 # write partition table entry
458 while (( curptr
< 16 )); do
459 ostr
=$ostr\\0${thecode[curptr++]#8#}
462 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1CE)) 2>/dev
/null
465 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi3p ||
$target = raspberry-pi3p-64 ||
$target = phytec-wega
]]; then
466 # move system and data partition from #0/#1 to #1/#2
467 dd if="$T/firsttrack" bs
=1 skip
=$
((0x1BE)) count
=32 of
="$T/x" 2>/dev
/null
468 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1CE)) if="$T/x" 2>/dev
/null
469 # create boot partition (copy of the above :)
471 typeset
-Uui8 thecode
473 set -A g_code
$cyls $heads $secs
476 set -A o_code
# g_code equivalent for partition offset
477 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
478 (( o_code
[1] = pofs
/ g_code
[2] ))
479 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
480 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
481 # boot flag; C/H/S offset
482 thecode
[mbrpno
++]=0x00
483 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
484 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
485 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
486 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
487 # partition type; C/H/S end
488 (( thecode
[mbrpno
++] = 0x0B ))
489 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
490 (( cylno
= (spartofs
/ 2048) > 1024 ?
1023 : (spartofs
/ 2048) - 1 ))
491 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
492 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
493 # partition offset, size (LBA)
494 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
495 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
496 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
497 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
498 (( pssz
= psz
- pofs
))
499 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
500 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
501 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
502 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
503 # write partition table entry
506 while (( curptr
< 16 )); do
507 ostr
=$ostr\\0${thecode[curptr++]#8#}
510 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1BE)) 2>/dev
/null
515 [[ -c /dev
/arandom
]] && rnddev
=/dev
/arandom
516 dd if=$rnddev bs
=4 count
=1 2>/dev
/null | \
517 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1B8)) 2>/dev
/null
519 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1BC)) 2>/dev
/null
520 partuuid
=$
(dd if="$T/firsttrack" bs
=1 count
=4 skip
=$
((0x1B8)) 2>/dev
/null | \
521 hexdump -e '1/4 "%08x"')-0$
((syspartno
+1))
523 ((keep
)) ||
if (( datafssz
)); then
524 (( quiet
)) || print Cleaning out data partition...
525 dd if=/dev
/zero of
="$tgt" bs
=1048576 count
=1 seek
=$
((cyls
- cfgfs
- datafssz
)) > /dev
/null
2>&1
527 (( quiet
)) || print Cleaning out root partition...
528 dd if=/dev
/zero bs
=1048576 of
="$tgt" count
=1 seek
=$
((spartofs
/ 2048)) > /dev
/null
2>&1
530 (( quiet
)) ||
if (( grub
)); then
531 print Writing MBR and GRUB2 to target device... system PARTUUID
=$partuuid
533 print Writing MBR to target device... system PARTUUID
=$partuuid
535 dd if="$T/firsttrack" of
="$tgt" > /dev
/null
2>&1
537 if [[ $ostype = Linux
]]; then
545 fwdir
=$
(dirname "$src")
548 (banana-pro|orange-pi0
)
549 dd if="$fwdir/u-boot-sunxi-with-spl.bin" of
="$tgt" bs
=1024 seek
=8 > /dev
/null
2>&1
552 dd if="$fwdir/u-boot-spl.kwb" of
="$tgt" bs
=512 seek
=1 > /dev
/null
2>&1
555 dd if="$fwdir/SPL" of
="$tgt" bs
=1024 seek
=1 > /dev
/null
2>&1
556 dd if="$fwdir/u-boot.img" of
="$tgt" bs
=1024 seek
=69 > /dev
/null
2>&1
558 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi3p|raspberry-pi3p-64
)
559 (( noformat
)) || create_fs
"$bootpart" ADKBOOT vfat
562 (( noformat
)) || create_fs
"$bootpart" ADKBOOT ext4
566 (( noformat
)) || create_fs
"$rootpart" ADKROOT ext4
567 (( noformat
)) || tune_fs
"$rootpart"
569 (( quiet
)) || print Extracting installation archive...
570 mount_fs
"$rootpart" "$R" ext4
571 xz
-dc "$src" |
(cd "$R"; tar -xpf -)
573 if (( datafssz
)); then
574 mkdir
-m0755 "$R"/data
575 ((keep
)) || create_fs
"$datapart" ADKDATA ext4
576 ((keep
)) || tune_fs
"$datapart"
578 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi3p|raspberry-pi3p-64|phytec-wega
)
579 echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >> "$R"/etc
/fstab
581 (banana-pro|orange-pi0|solidrun-imx6|solidrun-clearfog
)
582 echo "/dev/mmcblk0p2 /data ext4 rw 0 0" >> "$R"/etc
/fstab
585 if [[ -d $datapartcontent ]]; then
586 mount_fs
"$datapart" "$D" ext4
587 # strip trailing slash
588 case $datapartcontent in
589 *[!/]*/) datapartcontent
=${datapartcontent%"${x##*[!/]}"};;
591 cp -R $datapartcontent/* "$D"
595 (( quiet
)) || print Finishing up with bootloader and kernel ...
597 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi3p|raspberry-pi3p-64
)
598 mount_fs
"$bootpart" "$B" vfat
599 for x
in "$R"/boot
/*; do
600 [[ -e "$x" ]] && mv -f "$R"/boot
/* "$B/"
603 for x
in "$fwdir"/*.dtb
; do
604 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$B/"
607 # use static dtoverlay, rename to *.dtb
609 for x
in "$fwdir"/overlays
/*.dtbo
; do
610 y
=$
(basename ${x} .dtbo
)
611 [[ -e "$x" ]] && cp "$fwdir"/overlays
/${y}.dtbo
"$B/"overlays
/${y}.dtb
616 mount_fs
"$bootpart" "$B" ext4
617 for x
in "$R"/boot
/*; do
618 [[ -e "$x" ]] && mv -f "$R"/boot
/* "$B/"
621 for x
in "$fwdir"/*.dtb
; do
622 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$B/"
628 for x
in "$fwdir"/*.dtb
; do
629 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
632 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
633 -n "SolidrunClearfog" \
634 -d $fwdir/boot.
script.clearfog
$R/boot
/boot.scr.uimg
637 for x
in "$fwdir"/*.dtb
; do
638 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
641 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
643 -d $fwdir/boot.
script.imx6
$R/boot
/boot.scr.uimg
646 for x
in "$fwdir"/*.dtb
; do
647 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
650 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
652 -d $fwdir/boot.
script.opi
$R/boot
/boot.scr.uimg
655 for x
in "$fwdir"/*.dtb
; do
656 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
659 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
661 -d $fwdir/boot.
script.bpi
$R/boot
/boot.scr.uimg
666 dd if=$rnddev bs
=16 count
=1 >>etc
/.rnd
2>/dev
/null
667 (( quiet
)) || print Fixing up permissions...
670 [[ -f usr
/bin
/sudo
]] && chmod 4755 usr
/bin
/sudo
673 (( quiet
)) || print Configuring GRUB2 bootloader...
678 if (( serial
)); then
679 print serial
--unit=0 --speed=$speed
680 print terminal_output serial
681 print terminal_input serial
682 consargs
="console=ttyS0,$speed console=tty0"
684 print terminal_output console
685 print terminal_input console
686 consargs
="console=tty0"
689 print
'menuentry "GNU/Linux (OpenADK)" {'
690 linuxargs
="root=PARTUUID=$partuuid $consargs rootwait"
691 (( panicreboot
)) && linuxargs
="$linuxargs panic=$panicreboot"
692 print
"\tlinux /boot/kernel $linuxargs"
694 ) >boot
/grub
/grub.cfg
697 (( quiet
)) || print Finishing up...
700 if (( datafssz
)); then