GetPatchAndCompileKernel.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. export ARCH=arm
  2. if [ -z ${CROSS_COMPILE+x} ]; then
  3. export CROSS_COMPILE=arm-linux-gnueabihf-
  4. fi
  5. export KERNEL_GIT_URL='git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git'
  6. if [ -z ${MAKEOPTS+x} ]; then
  7. export MAKEOPTS=-j16
  8. fi
  9. export KERNEL_SERIES=v5.8
  10. export KERNEL_BRANCH=v5.8
  11. export LOCALVERSION=-RockMyy32-Frosty
  12. export MALI_VERSION=r19p0-01rel0
  13. export MALI_BASE_URL=https://developer.arm.com/-/media/Files/downloads/mali-drivers/kernel/mali-midgard-gpu
  14. export GITHUB_REPO=Miouyouyou/RockMyy
  15. export GIT_BRANCH=master
  16. export DTB_FILES="
  17. rk3288-evb-act8846.dtb
  18. rk3288-evb-rk808.dtb
  19. rk3288-firefly-beta.dtb
  20. rk3288-firefly-reload.dtb
  21. rk3288-firefly.dtb
  22. rk3288-tinker.dtb
  23. rk3288-miqi.dtb
  24. rk3288-popmetal.dtb
  25. rk3288-r89.dtb
  26. rk3288-rock2-square.dtb
  27. rk3288-veyron-brain.dtb
  28. rk3288-veyron-jaq.dtb
  29. rk3288-veyron-jerry.dtb
  30. rk3288-veyron-mickey.dtb
  31. rk3288-veyron-minnie.dtb
  32. rk3288-veyron-pinky.dtb
  33. rk3288-veyron-speedy.dtb
  34. "
  35. export PATCHES_DIR=patches
  36. export KERNEL_PATCHES_DIR=$PATCHES_DIR/kernel/$KERNEL_SERIES
  37. export KERNEL_PATCHES_DTS_DIR=$KERNEL_PATCHES_DIR/DTS
  38. export CONFIG_FILE_PATH=config/$KERNEL_SERIES/config-latest
  39. export BASE_FILES_URL=https://raw.githubusercontent.com/$GITHUB_REPO/$GIT_BRANCH
  40. export KERNEL_PATCHES_DIR_URL=$BASE_FILES_URL/$KERNEL_PATCHES_DIR
  41. export KERNEL_DTS_PATCHES_DIR_URL=$BASE_FILES_URL/$KERNEL_PATCHES_DTS_DIR
  42. export CONFIG_FILE_URL=$BASE_FILES_URL/config/$KERNEL_SERIES/config-latest
  43. export KERNEL_PATCHES="
  44. 0001-drivers-mmc-dw-mci-rockchip-Handle-ASUS-Tinkerboard-.patch
  45. 0002-block-partitions-efi-Ignore-GPT-flags-on-Veyron-Chro.patch
  46. 0003-block-partitions-efi-Ignore-bizarre-Chromebook-GPT-p.patch
  47. 0004-mimick-phy-rockchip-inno-hdmi-Support-more-pre-pll-c.patch
  48. 0006-drm-rockchip-vop-filter-modes-outside-0.5-pixel-cloc.patch
  49. 0007-drm-rockchip-dw_hdmi-Set-cur_ctr-to-0-always.patch
  50. 0008-drm-rockchip-dw_hdmi-adjust-cklvl-txlvl-for-RF-EMI.patch
  51. 0009-drm-rockchip-dw_hdmi-Use-auto-generated-tables.patch
  52. 0010-drm-rockchip-dw_hdmi-add-default-594Mhz-clk-for-4K-6.patch
  53. 0011-drm-rockchip-dw-hdmi-limit-tmds-to-340mhz.patch
  54. 0012-HACK-drm-rockchip-vop-limit-resolution-to-3840x2160.patch
  55. 0013-MINIARM-set-npll-be-used-for-hdmi-only.patch
  56. 0014-clk-rockchip-rk3288-use-npll-table-to-to-improve-HDM.patch
  57. 0015-clk-rockchip-rk3288-add-more-npll-clocks.patch
  58. 0016-Use-340000-as-fallback-max_tmds_clock.patch
  59. 0017-FIXME-Don-t-use-vop_crtc_mode_valid.patch
  60. 0018-dma-fence-Reducing-DMA_FENCE_TRACE-to-debug.patch
  61. "
  62. export KERNEL_DTS_PATCHES="
  63. 0001-dts-rk3288-miqi-Enabling-the-Mali-GPU-node.patch
  64. 0002-arm-dtsi-rk3288-tinker-Added-flags-for-reboot-suppor.patch
  65. 0003-arm-dtsi-rk3288-add-GPU-500-Mhz-OPP-again.patch
  66. "
  67. # -- Helper functions
  68. function die_on_error {
  69. if [ ! $? = 0 ]; then
  70. echo $1
  71. exit 1
  72. fi
  73. }
  74. function download_patches {
  75. base_url=$1
  76. patches=${@:2}
  77. for patch in $patches; do
  78. wget $base_url/$patch ||
  79. { echo "Could not download $patch"; exit 1; }
  80. done
  81. }
  82. function download_and_apply_patches {
  83. base_url=$1
  84. patches=${@:2}
  85. download_patches $base_url $patches
  86. git apply $patches
  87. die_on_error "Could not apply the downloaded patches"
  88. rm $patches
  89. }
  90. function copy_and_apply_patches {
  91. patch_base_dir=$1
  92. patches=${@:2}
  93. apply_dir=$PWD
  94. cd $patch_base_dir
  95. cp $patches $apply_dir ||
  96. { echo "Could not copy $patch"; exit 1; }
  97. cd $apply_dir
  98. git apply $patches
  99. die_on_error "Could not apply the copied patches"
  100. rm $patches
  101. }
  102. # Get the kernel
  103. # If we haven't already clone the Linux Kernel tree, clone it and move
  104. # into the linux folder created during the cloning.
  105. if [ ! -d "linux" ]; then
  106. git clone --depth 1 --branch $KERNEL_BRANCH $KERNEL_GIT_URL linux
  107. die_on_error "Could not git the kernel"
  108. fi
  109. cd linux
  110. export SRC_DIR=$PWD
  111. # Check if the tree is patched
  112. if [ ! -e "PATCHED" ]; then
  113. # If not, cleanup, apply the patches, commit and mark the tree as
  114. # patched
  115. # Remove all untracked files. These are residues from failed runs
  116. git clean -fdx &&
  117. # Rewind modified files to their initial state.
  118. git checkout -- .
  119. # Download and apply the various kernel and Mali kernel-space driver patches
  120. if [ ! -d "../patches" ]; then
  121. download_and_apply_patches $KERNEL_PATCHES_DIR_URL $KERNEL_PATCHES
  122. download_and_apply_patches $KERNEL_DTS_PATCHES_DIR_URL $KERNEL_DTS_PATCHES
  123. else
  124. copy_and_apply_patches ../$KERNEL_PATCHES_DIR $KERNEL_PATCHES
  125. copy_and_apply_patches ../$KERNEL_PATCHES_DTS_DIR $KERNEL_DTS_PATCHES
  126. fi
  127. # Cleanup, get the configuration file and mark the tree as patched
  128. echo "RockMyy" > PATCHED &&
  129. git add . &&
  130. git commit -m "Apply ALL THE PATCHES !"
  131. fi
  132. # Download a .config file if none present
  133. if [ ! -e ".config" ]; then
  134. make mrproper
  135. if [ ! -f "../$CONFIG_FILE_PATH" ]; then
  136. wget -O .config $CONFIG_FILE_URL
  137. else
  138. cp "../$CONFIG_FILE_PATH" .config
  139. fi
  140. die_on_error "Could not get the configuration file..."
  141. fi
  142. if [ -z ${MAKE_CONFIG+x} ]; then
  143. export MAKE_CONFIG=oldconfig
  144. fi
  145. if [ ! -z ${APPLYONLY+x} ]; then
  146. exit
  147. fi
  148. make $MAKE_CONFIG
  149. make $DTB_FILES zImage modules $MAKEOPTS
  150. die_on_error "Compilation failed"
  151. if [ -z ${DONT_INSTALL_IN_TMP+x} ]; then
  152. # Kernel compiled
  153. # This will just copy the kernel files and libraries in /tmp
  154. # This part is only useful if you're cross-compiling the kernel, of course
  155. export INSTALL_MOD_PATH=/tmp/RockMyy-Build
  156. export INSTALL_PATH=$INSTALL_MOD_PATH/boot
  157. export INSTALL_HDR_PATH=$INSTALL_MOD_PATH/usr
  158. mkdir -p $INSTALL_MOD_PATH $INSTALL_PATH $INSTALL_HDR_PATH
  159. make modules_install &&
  160. make install &&
  161. make INSTALL_HDR_PATH=$INSTALL_HDR_PATH headers_install && # This command IGNORES predefined variables
  162. cp arch/arm/boot/zImage $INSTALL_PATH &&
  163. cp arch/arm/boot/dts/*.dtb $INSTALL_PATH
  164. fi