| .. | .. |
|---|
| 1 | 1 | #!/bin/sh |
|---|
| 2 | +# SPDX-License-Identifier: GPL-2.0-only |
|---|
| 2 | 3 | |
|---|
| 3 | 4 | # Copyright (C) 2006 Paul Mackerras, IBM Corporation <paulus@samba.org> |
|---|
| 4 | | -# This program may be used under the terms of version 2 of the GNU |
|---|
| 5 | | -# General Public License. |
|---|
| 6 | 5 | |
|---|
| 7 | 6 | # This script takes a kernel binary and optionally an initrd image |
|---|
| 8 | 7 | # and/or a device-tree blob, and creates a bootable zImage for a |
|---|
| .. | .. |
|---|
| 14 | 13 | # -i initrd specify initrd file |
|---|
| 15 | 14 | # -d devtree specify device-tree blob |
|---|
| 16 | 15 | # -s tree.dts specify device-tree source file (needs dtc installed) |
|---|
| 16 | +# -e esm_blob specify ESM blob for secure images |
|---|
| 17 | 17 | # -c cache $kernel.strip.gz (use if present & newer, else make) |
|---|
| 18 | 18 | # -C prefix specify command prefix for cross-building tools |
|---|
| 19 | 19 | # (strip, objcopy, ld) |
|---|
| .. | .. |
|---|
| 29 | 29 | # Allow for verbose output |
|---|
| 30 | 30 | if [ "$V" = 1 ]; then |
|---|
| 31 | 31 | set -x |
|---|
| 32 | + map="-Map wrapper.map" |
|---|
| 32 | 33 | fi |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | # defaults |
|---|
| .. | .. |
|---|
| 38 | 39 | initrd= |
|---|
| 39 | 40 | dtb= |
|---|
| 40 | 41 | dts= |
|---|
| 42 | +esm_blob= |
|---|
| 41 | 43 | cacheit= |
|---|
| 42 | 44 | binary= |
|---|
| 43 | 45 | compression=.gz |
|---|
| 46 | +uboot_comp=gzip |
|---|
| 44 | 47 | pie= |
|---|
| 45 | 48 | format= |
|---|
| 46 | 49 | |
|---|
| .. | .. |
|---|
| 60 | 63 | |
|---|
| 61 | 64 | usage() { |
|---|
| 62 | 65 | echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 |
|---|
| 63 | | - echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 |
|---|
| 64 | | - echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2 |
|---|
| 65 | | - echo ' [--no-compression] [vmlinux]' >&2 |
|---|
| 66 | + echo ' [-d devtree] [-s tree.dts] [-e esm_blob]' >&2 |
|---|
| 67 | + echo ' [-c] [-C cross-prefix] [-D datadir] [-W workingdir]' >&2 |
|---|
| 68 | + echo ' [-Z (gz|xz|none)] [--no-compression] [vmlinux]' >&2 |
|---|
| 66 | 69 | exit 1 |
|---|
| 67 | 70 | } |
|---|
| 68 | 71 | |
|---|
| .. | .. |
|---|
| 105 | 108 | [ "$#" -gt 0 ] || usage |
|---|
| 106 | 109 | dtb="$1" |
|---|
| 107 | 110 | ;; |
|---|
| 111 | + -e) |
|---|
| 112 | + shift |
|---|
| 113 | + [ "$#" -gt 0 ] || usage |
|---|
| 114 | + esm_blob="$1" |
|---|
| 115 | + ;; |
|---|
| 108 | 116 | -s) |
|---|
| 109 | 117 | shift |
|---|
| 110 | 118 | [ "$#" -gt 0 ] || usage |
|---|
| .. | .. |
|---|
| 131 | 139 | ;; |
|---|
| 132 | 140 | -z) |
|---|
| 133 | 141 | compression=.gz |
|---|
| 142 | + uboot_comp=gzip |
|---|
| 134 | 143 | ;; |
|---|
| 135 | 144 | -Z) |
|---|
| 136 | 145 | shift |
|---|
| 137 | 146 | [ "$#" -gt 0 ] || usage |
|---|
| 138 | | - [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage |
|---|
| 147 | + [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "lzma" -o "$1" != "lzo" -o "$1" != "none" ] || usage |
|---|
| 139 | 148 | |
|---|
| 140 | 149 | compression=".$1" |
|---|
| 150 | + uboot_comp=$1 |
|---|
| 141 | 151 | |
|---|
| 142 | 152 | if [ $compression = ".none" ]; then |
|---|
| 143 | 153 | compression= |
|---|
| 154 | + uboot_comp=none |
|---|
| 144 | 155 | fi |
|---|
| 156 | + if [ $uboot_comp = "gz" ]; then |
|---|
| 157 | + uboot_comp=gzip |
|---|
| 158 | + fi |
|---|
| 145 | 159 | ;; |
|---|
| 146 | 160 | --no-gzip) |
|---|
| 147 | 161 | # a "feature" of the the wrapper script is that it can be used outside |
|---|
| 148 | 162 | # the kernel tree. So keeping this around for backwards compatibility. |
|---|
| 149 | 163 | compression= |
|---|
| 164 | + uboot_comp=none |
|---|
| 150 | 165 | ;; |
|---|
| 151 | 166 | -?) |
|---|
| 152 | 167 | usage |
|---|
| .. | .. |
|---|
| 211 | 226 | tmp=$tmpdir/zImage.$$.o |
|---|
| 212 | 227 | ksection=.kernel:vmlinux.strip |
|---|
| 213 | 228 | isection=.kernel:initrd |
|---|
| 229 | +esection=.kernel:esm_blob |
|---|
| 214 | 230 | link_address='0x400000' |
|---|
| 215 | 231 | make_space=y |
|---|
| 232 | + |
|---|
| 233 | + |
|---|
| 234 | +if [ -n "$esm_blob" -a "$platform" != "pseries" ]; then |
|---|
| 235 | + echo "ESM blob not support on non-pseries platforms" >&2 |
|---|
| 236 | + exit 1 |
|---|
| 237 | +fi |
|---|
| 216 | 238 | |
|---|
| 217 | 239 | case "$platform" in |
|---|
| 218 | 240 | of) |
|---|
| .. | .. |
|---|
| 302 | 324 | platformo="$object/fixed-head.o $object/redboot-8xx.o" |
|---|
| 303 | 325 | binary=y |
|---|
| 304 | 326 | ;; |
|---|
| 305 | | -simpleboot-virtex405-*) |
|---|
| 306 | | - platformo="$object/virtex405-head.o $object/simpleboot.o $object/virtex.o" |
|---|
| 307 | | - binary=y |
|---|
| 308 | | - ;; |
|---|
| 309 | | -simpleboot-virtex440-*) |
|---|
| 310 | | - platformo="$object/fixed-head.o $object/simpleboot.o $object/virtex.o" |
|---|
| 311 | | - binary=y |
|---|
| 312 | | - ;; |
|---|
| 313 | 327 | simpleboot-*) |
|---|
| 314 | 328 | platformo="$object/fixed-head.o $object/simpleboot.o" |
|---|
| 315 | 329 | binary=y |
|---|
| .. | .. |
|---|
| 366 | 380 | .gz) |
|---|
| 367 | 381 | gzip -n -f -9 "$vmz.$$" |
|---|
| 368 | 382 | ;; |
|---|
| 383 | + .lzma) |
|---|
| 384 | + xz --format=lzma -f -6 "$vmz.$$" |
|---|
| 385 | + ;; |
|---|
| 386 | + .lzo) |
|---|
| 387 | + lzop -f -9 "$vmz.$$" |
|---|
| 388 | + ;; |
|---|
| 369 | 389 | *) |
|---|
| 370 | 390 | # drop the compression suffix so the stripped vmlinux is used |
|---|
| 371 | 391 | compression= |
|---|
| 392 | + uboot_comp=none |
|---|
| 372 | 393 | ;; |
|---|
| 373 | 394 | esac |
|---|
| 374 | 395 | |
|---|
| .. | .. |
|---|
| 412 | 433 | case "$platform" in |
|---|
| 413 | 434 | uboot) |
|---|
| 414 | 435 | rm -f "$ofile" |
|---|
| 415 | | - ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \ |
|---|
| 436 | + ${MKIMAGE} -A ppc -O linux -T kernel -C $uboot_comp -a $membase -e $membase \ |
|---|
| 416 | 437 | $uboot_version -d "$vmz" "$ofile" |
|---|
| 417 | 438 | if [ -z "$cacheit" ]; then |
|---|
| 418 | 439 | rm -f "$vmz" |
|---|
| .. | .. |
|---|
| 463 | 484 | fi |
|---|
| 464 | 485 | fi |
|---|
| 465 | 486 | |
|---|
| 487 | +if [ -n "$esm_blob" ]; then |
|---|
| 488 | + addsec $tmp "$esm_blob" $esection |
|---|
| 489 | +fi |
|---|
| 490 | + |
|---|
| 466 | 491 | if [ "$platform" != "miboot" ]; then |
|---|
| 467 | 492 | if [ -n "$link_address" ] ; then |
|---|
| 468 | 493 | text_start="-Ttext $link_address" |
|---|
| 469 | 494 | fi |
|---|
| 470 | 495 | #link everything |
|---|
| 471 | | - ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" \ |
|---|
| 496 | + ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" $map \ |
|---|
| 472 | 497 | $platformo $tmp $object/wrapper.a |
|---|
| 473 | 498 | rm $tmp |
|---|
| 474 | 499 | fi |
|---|
| .. | .. |
|---|
| 538 | 563 | count=$overlay_size bs=1 |
|---|
| 539 | 564 | |
|---|
| 540 | 565 | odir="$(dirname "$ofile.bin")" |
|---|
| 541 | | - rm -f "$odir/otheros.bld" |
|---|
| 542 | | - gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld" |
|---|
| 566 | + |
|---|
| 567 | + # The ps3's flash loader has a size limit of 16 MiB for the uncompressed |
|---|
| 568 | + # image. If a compressed image that exceeded this limit is written to |
|---|
| 569 | + # flash the loader will decompress that image until the 16 MiB limit is |
|---|
| 570 | + # reached, then enter the system reset vector of the partially decompressed |
|---|
| 571 | + # image. No warning is issued. |
|---|
| 572 | + rm -f "$odir"/{otheros,otheros-too-big}.bld |
|---|
| 573 | + size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1) |
|---|
| 574 | + bld="otheros.bld" |
|---|
| 575 | + if [ $size -gt $((0x1000000)) ]; then |
|---|
| 576 | + bld="otheros-too-big.bld" |
|---|
| 577 | + fi |
|---|
| 578 | + gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld" |
|---|
| 543 | 579 | ;; |
|---|
| 544 | 580 | esac |
|---|