create_sunxi_boot_files.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #/bin/sh
  2. ######################
  3. # Sunxi compilation #
  4. ######################
  5. set -e
  6. set -x
  7. show_usage() {
  8. cat <<EOF
  9. # NAME
  10. $(basename $0) -- Script to build sunxi kernel and boot files
  11. # OPTIONS
  12. -o offline mode (mandatory)
  13. -b olinux board (a10lime, a20lime, a20lime2, a20micro) (default: a20lime)
  14. -t number of thread (default: 2)
  15. -l change linux boot logo
  16. EOF
  17. exit 1
  18. }
  19. THREADS=2
  20. MAINTAINER="Emile"
  21. MAINTAINERMAIL="emile@bleuchtang.fr"
  22. while getopts ":ob:t:l:" opt; do
  23. case $opt in
  24. o)
  25. OFFLINE=yes
  26. ;;
  27. b)
  28. BOARD=$OPTARG
  29. ;;
  30. t)
  31. THREADS=$OPTARG
  32. ;;
  33. l)
  34. LOGO=$OPTARG
  35. ;;
  36. \?)
  37. show_usage
  38. ;;
  39. esac
  40. done
  41. source /olinux/config_board.sh
  42. clone_or_pull (){
  43. project=$1
  44. repo=$2
  45. name=$(echo $project | sed 's/.git$//')
  46. if [ "$OFFLINE" ] ; then
  47. if [ -f /olinux/sunxi/$name/Makefile ] ; then
  48. cd /olinux/sunxi/$name/ && make clean && git checkout .
  49. return 0
  50. else
  51. return 0
  52. fi
  53. fi
  54. if [ -d /olinux/sunxi/$name/ ] ; then
  55. if [ -f /olinux/sunxi/$name/Makefile ] ; then
  56. cd /olinux/sunxi/$name/ && make clean && git checkout . && git pull
  57. else
  58. cd /olinux/sunxi/$name/ && git checkout . && git pull
  59. fi
  60. else
  61. git clone $repo/$project /olinux/sunxi/$name/
  62. fi
  63. }
  64. mkdir -p /olinux/sunxi/
  65. ## Sunxi u-boot
  66. clone_or_pull u-boot git://git.denx.de
  67. cd /olinux/sunxi/u-boot/
  68. make $U_BOOT_CONFIG ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  69. if [ "$LOGO" ] ; then
  70. cp /olinux/logo/${LOGO}.bmp /olinux/sunxi/u-boot/tools/logos/denx.bmp
  71. sed -i -e 's/#define CONFIG_VIDEO_LOGO/#define CONFIG_VIDEO_LOGO\n#define CONFIG_VIDEO_BMP_LOGO/' /olinux/sunxi/u-boot/include/configs/sunxi-common.h
  72. fi
  73. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  74. # Linux kernel
  75. clone_or_pull linux.git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds
  76. cd /olinux/sunxi/linux/
  77. # igorpecovnik patch for debian package
  78. patch -p1 < /olinux/patch/packaging-next.patch
  79. cp /olinux/config/linux-sunxi.config /olinux/sunxi/linux/.config
  80. if [ "$LOGO" ] ; then
  81. cp /olinux/logo/${LOGO}.ppm /olinux/sunxi/linux/drivers/video/logo/logo_linux_clut224.ppm
  82. fi
  83. #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
  84. #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  85. make -j${THREADS} ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all zImage
  86. # Install device tree blobs in separate package, link zImage to kernel image script
  87. rm -f /olinux/sunxi/*.deb
  88. make -j1 deb-pkg KBUILD_DEBARCH=armhf ARCH=arm DEBFULLNAME="$MAINTAINER" DEBEMAIL="$MAINTAINERMAIL" CROSS_COMPILE=arm-linux-gnueabihf-
  89. rm -rf /olinux/sunxi/config/boot.scr
  90. mkimage -C none -A arm -T script -d /olinux/config/boot.cmd /olinux/sunxi/boot.scr