3 # Copyright © 2010-2023
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 (atmel-ngw100|banana-pro|banana-pro-zero|orange-pi0|pcengines-apu|phytec-imx6|phytec-wega|raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5|rockpi4-plus|solidrun-imx6|solidrun-clearfog|imgtec-ci20|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-pi4 ||
$target = raspberry-pi4-64 ||
$target = raspberry-pi5 ||
$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 [[ "$tgt" == *"nvme0n1"* ]] ||
[[ "$tgt" == *"mmcblk"* ]]; then
231 if [[ $basedev = /dev
/loop
* ]]; then
232 (( quiet
)) || print
"${tgt} is a loop device"
236 rootpart
=${basedev}${partitionsep}1
237 datapart
=${basedev}${partitionsep}2
238 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi4 ||
$target = raspberry-pi4-64 ||
$target = raspberry-pi5
]]; then
239 bootpart
=${basedev}${partitionsep}1
240 rootpart
=${basedev}${partitionsep}2
241 datapart
=${basedev}${partitionsep}3
244 match
=\'${basedev}${partitionsep}\''+([0-9])'
246 (( quiet
)) || print
"Mounting filesystem on ${1}..."
247 mount
-t "$3" "$1" "$2"
250 (( quiet
)) || print
"Unmounting filesystem on ${1}..."
254 (( quiet
)) || print
"Creating filesystem on ${1}..."
258 tune2fs
-c 0 -i 0 "$1"
264 while read -p dev rest
; do
265 eval [[ \
$dev = $match ]] ||
continue
266 print
-u2 "Block device $tgt is in use, please umount first."
270 if (( !quiet
)); then
271 print
"WARNING: This will overwrite $basedev - type Yes to continue!"
273 [[ $x = Yes
]] ||
exit 0
276 if ! T
=$
(mktemp
-d /tmp
/openadk.XXXXXXXXXX
); then
277 print
-u2 Error creating temporary directory.
280 if [[ $ostype != Darwin
]]; then
284 mkdir
-p "$R" "$B" "$D"
288 dksz
=$
(dkgetsz
"$tgt")
291 # n̲a̲m̲e̲ p̲a̲r̲t̲#̲0̲ p̲̲a̲r̲t̲#̲1̲ p̲̲a̲r̲t̲#̲2̲ p̲̲a̲r̲t̲#̲3̲
292 # default: 0x83(system) 0x83(?data) -(unused) 0x88(cfgfs)
293 # raspberry: 0x0B(boot) 0x83(system) 0x83(?data) 0x88(cfgfs)
298 # boot(raspberry) - fixed (100 MiB)
299 # cfgfs - fixed (parameter, max. 16 MiB)
300 # data - flexible (parameter)
301 # system - everything else
303 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi4 ||
$target = raspberry-pi4-64 ||
$target = raspberry-pi5 ||
$target = phytec-wega
]]; then
307 print
-u2 "Cannot combine GRUB with $target"
317 (( cyls
= dksz
/ heads
/ secs
))
318 if (( cyls
< (bootfssz
+ cfgfs
+ datafssz
+ 2) )); then
319 print
-u2 "Size of $tgt is $dksz, this looks fishy?"
324 if stat
-qs .
>/dev
/null
2>&1; then
325 statcmd
='stat -f %z' # BSD stat (or so we assume)
327 statcmd
='stat -c %s' # GNU stat
331 tar -xOf "$src" boot
/grub
/core.img
>"$T/core.img"
332 integer coreimgsz
=$
($statcmd "$T/core.img")
336 if (( coreimgsz
< 1024 )); then
337 print
-u2 core.img is probably too small
: $coreimgsz
341 if (( coreimgsz
> 65024 )); then
342 print
-u2 core.img is larger than
64K-512
: $coreimgsz
346 (( coreendsec
= (coreimgsz
+ 511) / 512 ))
347 if [[ $basedev = /dev
/svnd
+([0-9]) ]]; then
348 # BSD svnd0 mode: protect sector #1
351 corepatchofs
=$
((0x614))
354 corepatchofs
=$
((0x414))
356 # partition offset: at least coreendsec+1 but aligned on a multiple of secs
357 #(( partofs = ((coreendsec / secs) + 1) * secs ))
358 # we just use 2048 all the time, since some loaders are longer
360 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi4 ||
$target = raspberry-pi4-64 ||
$target = raspberry-pi5 ||
$target = phytec-wega ||
$target = rockpi4-plus
]]; then
361 (( spartofs
= partofs
+ (100 * 2048) ))
366 (( quiet
)) ||
if (( grub
)); then
367 print Preparing MBR and GRUB2...
369 print Preparing MBR...
371 dd if=/dev
/zero of
="$T/firsttrack" count
=$partofs 2>/dev
/null
372 # add another MiB to clear the first partition
373 dd if=/dev
/zero bs
=1048576 count
=1 >>"$T/firsttrack" 2>/dev
/null
374 echo $corestartsec $coreendsec | mksh
"$ADK_TOPDIR/scripts/bootgrub.mksh" \
375 -A -g $
((cyls
- bootfssz
- cfgfs
- datafssz
)):$heads:$secs -M 1:0x83 \
376 -O $spartofs |
dd of
="$T/firsttrack" conv
=notrunc
2>/dev
/null
377 (( grub
)) && dd if="$T/core.img" of
="$T/firsttrack" conv
=notrunc \
378 seek
=$corestartsec 2>/dev
/null
379 # set partition where it can find /boot/grub
380 (( grub
)) && print
-n '\0\0\0\0' | \
381 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$corepatchofs 2>/dev
/null
383 # create cfgfs partition (mostly taken from bootgrub.mksh)
385 typeset
-Uui8 thecode
387 set -A g_code
$cyls $heads $secs
388 (( psz
= g_code
[0] * g_code
[1] * g_code
[2] ))
389 (( pofs
= (cyls
- cfgfs
) * g_code
[1] * g_code
[2] ))
390 set -A o_code
# g_code equivalent for partition offset
391 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
392 (( o_code
[1] = pofs
/ g_code
[2] ))
393 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
394 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
395 # boot flag; C/H/S offset
396 thecode
[mbrpno
++]=0x00
397 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
398 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
399 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
400 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
401 # partition type; C/H/S end
402 (( thecode
[mbrpno
++] = 0x88 ))
403 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
404 (( cylno
= g_code
[0] > 1024 ?
1023 : g_code
[0] - 1 ))
405 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
406 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
407 # partition offset, size (LBA)
408 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
409 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
410 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
411 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
412 (( pssz
= psz
- pofs
))
413 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
414 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
415 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
416 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
417 # write partition table entry
420 while (( curptr
< 16 )); do
421 ostr
=$ostr\\0${thecode[curptr++]#8#}
424 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1EE)) 2>/dev
/null
426 if (( datafssz
)); then
427 # create data partition (copy of the above :)
429 typeset
-Uui8 thecode
431 set -A g_code
$cyls $heads $secs
432 (( psz
= (cyls
- cfgfs
) * g_code
[1] * g_code
[2] ))
433 (( pofs
= (cyls
- cfgfs
- datafssz
) * g_code
[1] * g_code
[2] ))
434 set -A o_code
# g_code equivalent for partition offset
435 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
436 (( o_code
[1] = pofs
/ g_code
[2] ))
437 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
438 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
439 # boot flag; C/H/S offset
440 thecode
[mbrpno
++]=0x00
441 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
442 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
443 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
444 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
445 # partition type; C/H/S end
446 (( thecode
[mbrpno
++] = 0x83 ))
447 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
448 (( cylno
= (g_code
[0] - cfgfs
) > 1024 ?
1023 : g_code
[0] - cfgfs
- 1 ))
449 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
450 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
451 # partition offset, size (LBA)
452 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
453 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
454 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
455 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
456 (( pssz
= psz
- pofs
))
457 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
458 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
459 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
460 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
461 # write partition table entry
464 while (( curptr
< 16 )); do
465 ostr
=$ostr\\0${thecode[curptr++]#8#}
468 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1CE)) 2>/dev
/null
471 if [[ $target = raspberry-pi ||
$target = raspberry-pi0 ||
$target = raspberry-pi2 ||
$target = raspberry-pi3 ||
$target = raspberry-pi3-64 ||
$target = raspberry-pi4 ||
$target = raspberry-pi4-64 ||
$target = raspberry-pi5 ||
$target = phytec-wega
]]; then
472 # move system and data partition from #0/#1 to #1/#2
473 dd if="$T/firsttrack" bs
=1 skip
=$
((0x1BE)) count
=32 of
="$T/x" 2>/dev
/null
474 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1CE)) if="$T/x" 2>/dev
/null
475 # create boot partition (copy of the above :)
477 typeset
-Uui8 thecode
479 set -A g_code
$cyls $heads $secs
482 set -A o_code
# g_code equivalent for partition offset
483 (( o_code
[2] = pofs
% g_code
[2] + 1 ))
484 (( o_code
[1] = pofs
/ g_code
[2] ))
485 (( o_code
[0] = o_code
[1] / g_code
[1] + 1 ))
486 (( o_code
[1] = o_code
[1] % g_code
[1] + 1 ))
487 # boot flag; C/H/S offset
488 thecode
[mbrpno
++]=0x00
489 (( thecode
[mbrpno
++] = o_code
[1] - 1 ))
490 (( cylno
= o_code
[0] > 1024 ?
1023 : o_code
[0] - 1 ))
491 (( thecode
[mbrpno
++] = o_code
[2] |
((cylno
& 0x0300) >> 2) ))
492 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
493 # partition type; C/H/S end
494 (( thecode
[mbrpno
++] = 0x0B ))
495 (( thecode
[mbrpno
++] = g_code
[1] - 1 ))
496 (( cylno
= (spartofs
/ 2048) > 1024 ?
1023 : (spartofs
/ 2048) - 1 ))
497 (( thecode
[mbrpno
++] = g_code
[2] |
((cylno
& 0x0300) >> 2) ))
498 (( thecode
[mbrpno
++] = cylno
& 0x00FF ))
499 # partition offset, size (LBA)
500 (( thecode
[mbrpno
++] = pofs
& 0xFF ))
501 (( thecode
[mbrpno
++] = (pofs
>> 8) & 0xFF ))
502 (( thecode
[mbrpno
++] = (pofs
>> 16) & 0xFF ))
503 (( thecode
[mbrpno
++] = (pofs
>> 24) & 0xFF ))
504 (( pssz
= psz
- pofs
))
505 (( thecode
[mbrpno
++] = pssz
& 0xFF ))
506 (( thecode
[mbrpno
++] = (pssz
>> 8) & 0xFF ))
507 (( thecode
[mbrpno
++] = (pssz
>> 16) & 0xFF ))
508 (( thecode
[mbrpno
++] = (pssz
>> 24) & 0xFF ))
509 # write partition table entry
512 while (( curptr
< 16 )); do
513 ostr
=$ostr\\0${thecode[curptr++]#8#}
516 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1BE)) 2>/dev
/null
521 [[ -c /dev
/arandom
]] && rnddev
=/dev
/arandom
522 dd if=$rnddev bs
=4 count
=1 2>/dev
/null | \
523 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1B8)) 2>/dev
/null
525 dd of
="$T/firsttrack" conv
=notrunc bs
=1 seek
=$
((0x1BC)) 2>/dev
/null
526 partuuid
=$
(dd if="$T/firsttrack" bs
=1 count
=4 skip
=$
((0x1B8)) 2>/dev
/null | \
527 hexdump -e '1/4 "%08x"')-0$
((syspartno
+1))
529 ((keep
)) ||
if (( datafssz
)); then
530 (( quiet
)) || print Cleaning out data partition...
531 dd if=/dev
/zero of
="$tgt" bs
=1048576 count
=1 seek
=$
((cyls
- cfgfs
- datafssz
)) > /dev
/null
2>&1
533 (( quiet
)) || print Cleaning out root partition...
534 dd if=/dev
/zero bs
=1048576 of
="$tgt" count
=1 seek
=$
((spartofs
/ 2048)) > /dev
/null
2>&1
536 (( quiet
)) ||
if (( grub
)); then
537 print Writing MBR and GRUB2 to target device... system PARTUUID
=$partuuid
539 print Writing MBR to target device... system PARTUUID
=$partuuid
541 dd if="$T/firsttrack" of
="$tgt" > /dev
/null
2>&1
543 if [[ $ostype = Linux
]]; then
551 fwdir
=$
(dirname "$src")
555 dd if="$fwdir/idbloader.img" of
="$tgt" bs
=512 seek
=64 > /dev
/null
2>&1
556 dd if="$fwdir/u-boot.itb" of
="$tgt" bs
=512 seek
=16384 > /dev
/null
2>&1
559 dd if="$fwdir/u-boot-spl.bin" of
="$tgt" obs
=512 seek
=1 > /dev
/null
2>&1
560 dd if="$fwdir/u-boot-dtb.img" of
="$tgt" obs
=1k seek
=14 > /dev
/null
2>&1
562 (banana-pro|banana-pro-zero|orange-pi0
)
563 dd if="$fwdir/u-boot-sunxi-with-spl.bin" of
="$tgt" bs
=1024 seek
=8 > /dev
/null
2>&1
566 dd if="$fwdir/u-boot-with-spl.kwb" of
="$tgt" bs
=512 seek
=1 > /dev
/null
2>&1
568 (solidrun-imx6|phytec-imx6
)
569 dd if="$fwdir/SPL" of
="$tgt" bs
=1024 seek
=1 > /dev
/null
2>&1
570 dd if="$fwdir/u-boot.img" of
="$tgt" bs
=1024 seek
=69 > /dev
/null
2>&1
572 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5
)
573 (( noformat
)) || create_fs
"$bootpart" ADKBOOT vfat
576 (( noformat
)) || create_fs
"$bootpart" ADKBOOT ext4
582 (( noformat
)) || create_fs
"$rootpart" ADKROOT ext2
583 (( noformat
)) || tune_fs
"$rootpart"
586 (( noformat
)) || create_fs
"$rootpart" ADKROOT ext4
587 (( noformat
)) || tune_fs
"$rootpart"
590 (( quiet
)) || print Extracting installation archive...
591 mount_fs
"$rootpart" "$R" ext4
592 gzip -dc "$src" |
(cd "$R"; tar -xpf -)
594 if (( datafssz
)); then
595 mkdir
-m0755 "$R"/data
596 ((keep
)) || create_fs
"$datapart" ADKDATA ext4
597 ((keep
)) || tune_fs
"$datapart"
599 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5|phytec-wega
)
600 echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >> "$R"/etc
/fstab
602 (banana-pro|orange-pi0|solidrun-clearfog|rockpi4-plus
)
603 echo "/dev/mmcblk0p2 /data ext4 rw 0 0" >> "$R"/etc
/fstab
605 (solidrun-imx6|phytec-imx6
)
606 echo "/dev/mmcblk1p2 /data ext4 rw 0 0" >> "$R"/etc
/fstab
609 if [[ -d $datapartcontent ]]; then
610 mount_fs
"$datapart" "$D" ext4
611 # strip trailing slash
612 case $datapartcontent in
613 *[!/]*/) datapartcontent
=${datapartcontent%"${x##*[!/]}"};;
615 cp -R $datapartcontent/* "$D"
619 (( quiet
)) || print Finishing up with bootloader and kernel ...
621 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|raspberry-pi4|raspberry-pi4-64|raspberry-pi5
)
622 mount_fs
"$bootpart" "$B" vfat
623 for x
in "$R"/boot
/*; do
624 [[ -e "$x" ]] && mv -f "$R"/boot
/* "$B/"
627 for x
in "$fwdir"/*.dtb
; do
628 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$B/"
631 # use static dtoverlay, rename to *.dtb
633 for x
in "$fwdir"/overlays
/*.dtbo
; do
634 y
=$
(basename ${x} .dtbo
)
635 [[ -e "$x" ]] && cp "$fwdir"/overlays
/${y}.dtbo
"$B/"overlays
/${y}.dtbo
637 for x
in "$fwdir"/overlays
/*.dtb
; do
638 y
=$
(basename ${x} .dtb
)
639 [[ -e "$x" ]] && cp "$fwdir"/overlays
/${y}.dtb
"$B/"overlays
/${y}.dtb
644 mount_fs
"$bootpart" "$B" ext4
645 for x
in "$R"/boot
/*; do
646 [[ -e "$x" ]] && mv -f "$R"/boot
/* "$B/"
649 for x
in "$fwdir"/*.dtb
; do
650 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$B/"
656 for x
in "$fwdir"/*.dtb
; do
657 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
660 mkimage
-A arm64
-O linux
-T script -C none
-a 0 -e 0 \
662 -d $fwdir/boot.
script.rockpi4
$R/boot
/boot.scr.uimg
665 for x
in "$fwdir"/*.dtb
; do
666 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
669 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
670 -n "SolidrunClearfog" \
671 -d $fwdir/boot.
script.clearfog
$R/boot
/boot.scr.uimg
674 for x
in "$fwdir"/*.dtb
; do
675 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
678 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
680 -d $fwdir/boot.
script.imx6
$R/boot
/boot.scr.uimg
683 for x
in "$fwdir"/*.dtb
; do
684 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
687 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
689 -d $fwdir/boot.
script.phytec
$R/boot
/boot.scr.uimg
692 for x
in "$fwdir"/*.dtb
; do
693 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
696 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
698 -d $fwdir/boot.
script.opi
$R/boot
/boot.scr.uimg
701 for x
in "$fwdir"/*.dtb
; do
702 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
705 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
707 -d $fwdir/boot.
script.bpi
$R/boot
/boot.scr.uimg
710 for x
in "$fwdir"/*.dtb
; do
711 [[ -e "$x" ]] && cp "$fwdir"/*.dtb
"$R/boot/"
714 mkimage
-A arm
-O linux
-T script -C none
-a 0 -e 0 \
716 -d $fwdir/boot.
script.bpizero
$R/boot
/boot.scr.uimg
721 dd if=$rnddev bs
=16 count
=1 >>etc
/.rnd
2>/dev
/null
722 (( quiet
)) || print Fixing up permissions...
725 [[ -f usr
/bin
/sudo
]] && chmod 4755 usr
/bin
/sudo
728 (( quiet
)) || print Configuring GRUB2 bootloader...
733 if (( serial
)); then
734 print serial
--unit=0 --speed=$speed
735 print terminal_output serial
736 print terminal_input serial
737 consargs
="console=ttyS0,$speed console=tty0"
739 print terminal_output console
740 print terminal_input console
741 consargs
="console=tty0"
744 print
'menuentry "GNU/Linux (OpenADK)" {'
745 linuxargs
="root=PARTUUID=$partuuid $consargs rootwait"
746 (( panicreboot
)) && linuxargs
="$linuxargs panic=$panicreboot"
747 print
"\tlinux /boot/kernel $linuxargs"
749 ) >boot
/grub
/grub.cfg
752 (( quiet
)) || print Finishing up...
755 if (( datafssz
)); then