buildKernel.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh -xe
  2. #Build kenerl, wifi firmware
  3. # This file is part of PrawnOS (http://www.prawnos.com)
  4. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  5. # PrawnOS is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License version 2
  7. # as published by the Free Software Foundation.
  8. # PrawnOS is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  14. KVER=4.17.2
  15. TEST_PATCHES=false
  16. ROOT_DIR=`pwd`
  17. RESOURCES=$ROOT_DIR/resources/BuildResources
  18. [ ! -d build ] && mkdir build
  19. cd build
  20. # build Linux-libre, with ath9k_htc
  21. [ ! -f linux-libre-$KVER-gnu.tar.lz ] && wget https://www.linux-libre.fsfla.org/pub/linux-libre/releases/$KVER-gnu/linux-libre-$KVER-gnu.tar.lz
  22. [ ! -d linux-$KVER ] && tar --lzip -xvf linux-libre-$KVER-gnu.tar.lz && FRESH=true
  23. cd linux-$KVER
  24. make clean
  25. make mrproper
  26. #Apply the usb and mmc patches if unapplied
  27. [ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/DTS/*.patch; do patch -p1 < $i; done
  28. [ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/*.patch; do patch -p1 < $i; done
  29. #Apply all of the rockMyy patches that make sense
  30. [ "$TEST_PATCHES" = true ] && for i in $RESOURCES/patches-untested/kernel/*.patch; do patch -p1 < $i; done
  31. [ "$TEST_PATCHES" = true ] && for i in $RESOURCES/patches-untested/DTS/*.patch; do patch -p1 < $i; done
  32. cp $RESOURCES/config .config
  33. make -j `grep ^processor /proc/cpuinfo | wc -l` CROSS_COMPILE=arm-none-eabi- ARCH=arm zImage modules dtbs
  34. [ ! -h kernel.its ] && ln -s $RESOURCES/kernel.its .
  35. mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  36. dd if=/dev/zero of=bootloader.bin bs=512 count=1
  37. vbutil_kernel --pack vmlinux.kpart \
  38. --version 1 \
  39. --vmlinuz vmlinux.uimg \
  40. --arch arm \
  41. --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
  42. --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
  43. --config $RESOURCES/cmdline \
  44. --bootloader bootloader.bin
  45. cd ..
  46. # build AR9271 firmware
  47. [ ! -d open-ath9k-htc-firmware ] && git clone --depth 1 https://github.com/qca/open-ath9k-htc-firmware.git
  48. cd open-ath9k-htc-firmware
  49. make toolchain
  50. make -C target_firmware
  51. cd ..
  52. cd $ROOT_DIR