rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | uboot_prep_kimage() { |
| 2 | |
| 3 | linux_comp=${KERNEL_COMPRESS} |
| 4 | |
| 5 | # uncompressed elf vmlinux |
| 6 | vmlinux_path="vmlinux" |
| 7 | |
| 8 | if test "${linux_comp}" = "lz4"; then |
| 9 | linux_suffix=".lz4" |
| 10 | elif test "${linux_comp}" = "gzip"; then |
| 11 | linux_suffix=".gz" |
| 12 | else |
| 13 | # Use 32-Bit kernel's compression method since |
| 14 | # it's is a kind of self-extracting executable. |
| 15 | if test -f "arch/arm/boot/compressed/vmlinux"; then |
| 16 | vmlinux_path="arch/arm/boot/compressed/vmlinux" |
| 17 | fi |
| 18 | linux_suffix="" |
| 19 | fi |
| 20 | |
| 21 | ${OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin |
| 22 | |
| 23 | if test "${linux_comp}" = "lz4"; then |
| 24 | lz4 -l -c1 linux.bin > linux.bin${linux_suffix} |
| 25 | # append uncompressed filesize info |
| 26 | dec_size=0 |
| 27 | fsize=$(stat -c "%s" "linux.bin") |
| 28 | dec_size=$(expr $dec_size + $fsize) |
| 29 | printf "%08x\n" $dec_size | |
| 30 | sed 's/\(..\)/\1 /g' | { |
| 31 | read ch0 ch1 ch2 ch3; |
| 32 | for ch in $ch3 $ch2 $ch1 $ch0; do |
| 33 | printf `printf '%s%03o' '\\' 0x$ch` >> linux.bin${linux_suffix}; |
| 34 | done; |
| 35 | } |
| 36 | elif test "${linux_comp}" = "gzip"; then |
| 37 | gzip -9 linux.bin |
| 38 | else |
| 39 | echo "For none case or another compressing" |
| 40 | fi |
| 41 | |
| 42 | if ! test "${linux_comp}" = "none"; then |
| 43 | mv -f "linux.bin${linux_suffix}" linux.bin |
| 44 | else |
| 45 | echo "No kerenl compression" |
| 46 | fi |
| 47 | |
| 48 | echo "${linux_comp}" |
| 49 | } |