summaryrefslogtreecommitdiff
path: root/kbuild.sh
diff options
context:
space:
mode:
Diffstat (limited to 'kbuild.sh')
-rwxr-xr-xkbuild.sh167
1 files changed, 7 insertions, 160 deletions
diff --git a/kbuild.sh b/kbuild.sh
index 50f8d21..d91e67b 100755
--- a/kbuild.sh
+++ b/kbuild.sh
@@ -173,165 +173,12 @@ version=$(cat $output_dir/include/generated/utsrelease.h | cut -d '"' -f 2)
# Create the image
#
-make_fit_image() {
- local kernel_its=$output_dir/arch/$arch/boot/kernel_fdt.its
-
- cat <<EOF > $kernel_its
-/dts-v1/;
-/ {
- description = "Kernel + FDT image for $board board";
- #address-cells = <1>;
-
- images {
- kernel {
- description = "Linux kernel";
- data = /incbin/("$output_dir/arch/$arch/boot/$image_kernel");
- type = "kernel";
- arch = "$arch";
- os = "linux";
- compression = "none";
- load = <$LOADADDR>;
- entry = <$LOADADDR>;
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- };
-EOF
-
- local dtb
-
- for dtb in $DTBS ; do
- local src=${dtb/:*/}
- local dst=${dtb/*:/}
- dst=${dst/*\//}
-
- cat <<EOF >> $kernel_its
- fdt-$dst {
- description = "Flattened Device Tree blob $dst";
- data = /incbin/("$output_dir/arch/$arch/boot/dts/$src");
- type = "flat_dt";
- arch = "$arch";
- compression = "none";
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- };
-EOF
- done
-
- local config=$(echo $DTBS | sed 's/.*[:/]//')
- cat <<EOF >> $kernel_its
- };
-
- configurations {
- default = "conf-$config";
-EOF
- for dtb in $DTBS ; do
- local dst=${dtb/*:/}
- dst=${dst/*\//}
-
- cat <<EOF >> $kernel_its
- conf-$dst {
- description = "Boot Linux kernel with $dst blob";
- kernel = "kernel";
- fdt = "fdt-$dst";
- };
-EOF
- done
-
- cat <<EOF >> $kernel_its
- };
-};
-EOF
-
- PATH="$output_dir/scripts/dtc:$PATH" mkimage -f $kernel_its ${kernel_its/its/itb}
-}
-
-make_srec_image() {
- local image=$output_dir/arch/$arch/boot/$image_kernel
-
- cat $image | lzma -z -e > $image.xz
- objcopy -I binary -O srec --srec-forceS3 --srec-len 516 \
- $image.xz $image.xz.srec
-
- for dtb in $DTBS ; do
- local src=${dtb/:*/}
-
- objcopy -I binary -O srec --srec-forceS3 --srec-len 516 \
- $src $src.srec
- done
-}
-
-make_uboot_image() {
- mkimage -A $arch -O linux -T kernel -C none -a $LOADADDR -e $LOADADDR \
- -n "Linux-${version}" -d $output_dir/arch/$arch/boot/$kernel_image \
- $output_dir/arch/$arch/boot/uImage
-}
-
-make_cros_image() {
- local boot_dir=$output_dir/arch/$arch/boot
- local vmlinuz=$boot_dir/$1
- local bootloader
- local config
-
- if [[ -f $opt_bootloader ]] ; then
- bootloader=$opt_bootloader
- else
- dd if=/dev/zero of=$boot_dir/bootloader bs=512 count=1
- bootloader=$boot_dir/bootloader
- fi
-
- if [[ -f $opt_cmdline_file ]] ; then
- config=$opt_cmdline_file
- else
- echo "$CMDLINE" > $boot_dir/cmdline
- config=$boot_dir/cmdline
- fi
-
- vbutil_kernel \
- --pack $boot_dir/vmlinuz.image \
- --version 1 \
- --vmlinuz $vmlinuz \
- --arch $arch \
- --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
- --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
- --config $config \
- --bootloader $bootloader
-}
-
-case $IMAGE in
-FIT)
- make_fit_image
- image_file=$output_dir/arch/$arch/boot/kernel_fdt.itb
- ;;
-cros-arm)
- make_fit_image
- make_cros_image kernel_fdt.itb
- image_file=$output_dir/arch/$arch/boot/vmlinuz.image
- ;;
-cros-x86)
- make_fit_image
- make_cros_image bzImage
- image_file=$output_dir/arch/$arch/boot/vmlinuz.image
- ;;
-srec)
- make_srec_image
- image_file=$output_dir/arch/$arch/boot/$kernel_image.xz.srec
- ;;
-uImage)
- make_uboot_image
- image_file=$output_dir/arch/$arch/boot/uImage
- ;;
-*)
- image_file=$output_dir/arch/$arch/boot/$IMAGE
- ;;
-esac
+if [[ -r "$kbuild_root/images/$image.sh" ]] ; then
+ source "${kbuild_root}/images/$image.sh" || exit 1
+ eval make_${image}_image
+else
+ image_file=$output_dir/arch/$arch/boot/$image
+fi
#
# Copy the files to their destination directories
@@ -353,7 +200,7 @@ copy_dtbs() {
mkdir -p $BOOT_DIR
cp $image_file $BOOT_DIR/
-if [[ $IMAGE != FIT && $IMAGE != cros-arm && $IMAGE != cros-x86 ]] ; then
+if [[ $image != FIT && $image != CrOS ]] ; then
copy_dtbs $BOOT_DIR/
fi