create_sunxi_boot_files.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #/bin/sh
  2. ######################
  3. # Sunxi compilation #
  4. ######################
  5. show_usage() {
  6. cat <<EOF
  7. # NAME
  8. $(basename $0) -- Script to build sunxi kernel and boot files
  9. # OPTIONS
  10. -o offline mode (mandatory)
  11. -t olinux type (lime, lime2, micro) (default: lime)
  12. EOF
  13. exit 1
  14. }
  15. while getopts ":ot:" opt; do
  16. case $opt in
  17. o)
  18. offline=$OPTARG
  19. ;;
  20. t)
  21. olinux=$OPTARG
  22. ;;
  23. \?)
  24. show_usage
  25. ;;
  26. esac
  27. done
  28. clone_or_pull (){
  29. project=$1
  30. repo=$2
  31. name=$(echo $project | sed 's/.git$//')
  32. if [ "$offline" ] ; then
  33. cd /olinux/sunxi/$name/ && make clean
  34. return 0
  35. fi
  36. if [ -d /olinux/sunxi/$name/ ] ; then
  37. cd /olinux/sunxi/$name/ && make clean && git pull --depth 1
  38. else
  39. git clone --depth 1 $repo/$project /olinux/sunxi/$name/
  40. fi
  41. }
  42. if [ "$olinux" = "lime2" ] ; then
  43. u_boot_config=A20-OLinuXino-Lime2_defconfig
  44. sunxi_board_config="a20/a20-olinuxino_lime2.fex"
  45. elif [ "$olinux" = "micro" ] ; then
  46. u_boot_config=A20-OLinuXino_MICRO_defconfig
  47. sunxi_board_config="a20/a20-olinuxino_micro.fex"
  48. else
  49. u_boot_config=A20-OLinuXino-Lime_defconfig
  50. sunxi_board_config="a20/a20-olinuxino_lime.fex"
  51. fi
  52. mkdir -p /olinux/sunxi/
  53. # Sunxi u-boot
  54. #clone_or_pull u-boot-sunxi
  55. clone_or_pull u-boot.git git://git.denx.de
  56. cd /olinux/sunxi/u-boot && make CROSS_COMPILE=arm-linux-gnueabihf $u_boot_config && make CROSS_COMPILE=arm-linux-gnueabihf-
  57. # Sunxi kernel
  58. clone_or_pull linux-sunxi.git https://github.com/linux-sunxi
  59. cp /olinux/a20_defconfig /olinux/sunxi/linux-sunxi/arch/arm/configs/.
  60. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm a20_defconfig
  61. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 uImage
  62. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=out modules
  63. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=out modules_install
  64. # Sunxi board configs
  65. clone_or_pull sunxi-boards.git https://github.com/linux-sunxi
  66. # Sunxi tools
  67. clone_or_pull sunxi-tools.git https://github.com/linux-sunxi
  68. cd /olinux/sunxi/sunxi-tools/ && make
  69. cd /olinux/sunxi/ && rm -f script.bin && ./sunxi-tools/fex2bin sunxi-boards/sys_config/$sunxi_board_config script.bin
  70. cd /olinux/sunxi/ && chmod +x script.bin