Last active
May 10, 2019 21:17
-
-
Save ChronoMonochrome/8cc4d08cb2172765c6ce5cbc6767f38f to your computer and use it in GitHub Desktop.
Linux kernel build script for Midas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRC=/media/system/root/LOS15/kernel/samsung/midas | |
KERNEL_OUT=/ramdisk | |
ANDROID_OUT=/media/system/root/LOS15/out | |
GCC=/media/system/root/LOS15/prebuilts/gcc/linux-x86/arm/arm-eabi-7.4/bin/arm-linux-gnueabi- | |
TARGET=midas | |
$ANDROID_OUT/host/linux-x86/bin/mkbootfs -d $ANDROID_OUT/target/product/$TARGET/system \ | |
$ANDROID_OUT/target/product/$TARGET/root | $ANDROID_OUT/host/linux-x86/bin/minigzip > \ | |
$ANDROID_OUT/target/product/$TARGET/ramdisk.img | |
make -j8 CFLAGS_MODULE="-fno-pic" -C $SRC O=$KERNEL_OUT ARCH=arm CROSS_COMPILE="`which ccache` $GCC" lineageos_i9300_defconfig | |
make -j8 CFLAGS_MODULE="-fno-pic" -C $SRC O=$KERNEL_OUT ARCH=arm CROSS_COMPILE="`which ccache` $GCC" zImage-dtb | |
if grep -q '^CONFIG_OF=y' $KERNEL_OUT/.config; then \ | |
echo "Building DTBs"; \ | |
make CFLAGS_MODULE="-fno-pic" -C $SRC O=$KERNEL_OUT ARCH=arm CROSS_COMPILE="`which ccache` $GCC" dtbs; \ | |
fi | |
OUTPUT=$ANDROID_OUT/target/product/$TARGET/boot-$(git rev-parse --abbrev-ref HEAD | sed "s,/,_,g")-$(git rev-parse --short HEAD).img | |
cp $KERNEL_OUT/arch/arm/boot/zImage-dtb $ANDROID_OUT/target/product/$TARGET/kernel | |
$ANDROID_OUT/host/linux-x86/bin/mkbootimg \ | |
--kernel $ANDROID_OUT/target/product/$TARGET/kernel \ | |
--ramdisk $ANDROID_OUT/target/product/$TARGET/ramdisk.img \ | |
--base 0x40000000 \ | |
--pagesize 2048 \ | |
--cmdline "console=ttySAC2,115200 buildvariant=userdebug" \ | |
--os_version 7.1.2 \ | |
--os_patch_level 2018-09-05 \ | |
--output $OUTPUT | |
size=$(for i in $OUTPUT; do stat --format "%s" "$i" | tr -d '\n'; echo +; done; echo 0); | |
total=$(( $( echo "$size" ) )); | |
printname=$(echo -n "$OUTPUT" | tr " " +); | |
img_blocksize=4224; | |
twoblocks=$((img_blocksize * 2)); onepct=$(((((8650752 / 100) - 1) / img_blocksize + 1) * img_blocksize)); | |
reserve=$((twoblocks > onepct ? twoblocks : onepct)); | |
maxsize=$((8650752 - reserve)); | |
echo "$printname maxsize=$maxsize blocksize=$img_blocksize total=$total reserve=$reserve"; | |
if [ "$total" -gt "$maxsize" ]; then | |
echo "error: $printname too large ($total > [8650752 - $reserve])"; false; | |
elif [ "$total" -gt $((maxsize - 32768)) ]; then | |
echo "WARNING: $printname approaching size limit ($total now; limit $maxsize)"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment