Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. #! /bin/bash
  2. s_cpunum=4; BUILD=1; s_pkgext="txz";
  3.  
  4. root="/tmp/tmp" ; prefix="${root}/usr/local"
  5. rm -Rf "${root}" ; mkdir -p "${prefix}/bin" #"${prefix}/sbin"
  6.  
  7. s_binonly="";
  8. for s_target in binonly sun50i_h5_spl32 orangepi_pc2; do
  9. case "${s_target}" in
  10. binonly) s_binonly=1; ;;
  11. orangepi_pc) s_uboot_crossprefix="arm-linux-gnueabihf-"; ;;
  12. sun50i_h5_spl32) s_uboot_crossprefix="arm-linux-gnueabihf-"; ;;
  13. orangepi_pc2) s_uboot_crossprefix="aarch64-linux-gnueabihf-"; ;;
  14. *) echo "Error 9 - wrong target: ${s_target}"; exit -1; ;;
  15. esac
  16.  
  17. if [ "${s_target}" != "binonly" -a "${s_target}" != "s" ]; then
  18. if true; then
  19. # echo "Error 9 - not supported..."; exit -1;
  20. make -j "${s_cpunum}" CROSS_COMPILE=${s_uboot_crossprefix} V=1 distclean
  21. make -j "${s_cpunum}" CROSS_COMPILE=${s_uboot_crossprefix} V=1 ${s_target}_defconfig;
  22. make -j "${s_cpunum}" CROSS_COMPILE=${s_uboot_crossprefix} V=1 all;
  23. case "${s_target}" in
  24. orangepi_pc2)
  25. if [ \! -f "${root}/sunxi-spl.bin" ]; then echo "Error 9 - h5 sunxi-spl.bin missing..."; exit -1; fi;
  26. ${s_uboot_crossprefix}objcopy --gap-fill=0xff -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn -j .efi_runtime -j .efi_runtime_rel -I binary -O binary --pad-to=32768 --gap-fill=0xff \
  27. "${root}/sunxi-spl.bin" u-boot-sunxi-with-spl.bin && cat u-boot.img >> u-boot-sunxi-with-spl.bin || rm -f u-boot-sunxi-with-spl.bin
  28. ;;
  29. esac
  30. fi
  31.  
  32. ( cd tools; install -vpm755 jtagconsole gen_eth_addr img2srec mkimage easylogo/easylogo "${prefix}/bin";
  33. #cd env; install -vpm755 fw_printenv "${prefix}/sbin"; (cd "${prefix}/sbin"; ln -snf fw_printenv fw_setenv )
  34. )
  35. chown -R root.bin "${prefix}";
  36. case "${s_target}" in
  37. sun50i_h5_spl32) cp -dpR spl/sunxi-spl.bin "${root}/sunxi-spl.bin"; ;; # dd if="spl/sunxi-spl.bin" of="${root}/sunxi-spl.bin" bs=32768c conv=sync; ;;
  38. orangepi_pc2)
  39. if [ \! -f "${root}/sunxi-spl.bin" ]; then echo "Error 9 - h5 sunxi-spl.bin missing..."; exit -1; fi;
  40. #if [ "$(find "${root}/sunxi-spl.bin" -printf "%s")" -ne 32768 ]; then echo "Error 9 - h5 sunxi-spl.bin wrong size..."; exit -1; fi;
  41. if [ \! -f "u-boot.bin" ]; then echo "Error 9 - h5 u-boot.bin missing..."; exit -1; fi;
  42. if [ \! -f "u-boot-sunxi-with-spl.bin" ]; then echo "Error 9 - h5 u-boot-sunxi-with-spl.bin missing..."; exit -1; fi;
  43. (
  44. git clone https://github.com/apritzel/arm-trusted-firmware arm-trusted-firmware;#git checkout allwinner -f; git pull origin allwinner;
  45. cd arm-trusted-firmware;git checkout allwinner -f; git pull origin allwinner;
  46. make CROSS_COMPILE=${s_uboot_crossprefix} PLAT=sun50iw1p1 DEBUG=1 bl31 V=1
  47. )
  48. if [ \! -f "arm-trusted-firmware/build/sun50iw1p1/debug/bl31.bin" ]; then echo "Error 9 - bl31.bin missing..."; exit -1; fi;
  49. mkdir -p "${prefix}/share/uboot/";
  50. mv "${root}/sunxi-spl.bin" "${prefix}/share/uboot/${s_target}-sunxi-spl.bin";
  51. cp -dpR "u-boot-sunxi-with-spl.bin" "${prefix}/share/uboot/${s_target}-u-boot-sunxi-with-spl.bin";
  52. cp -dpR "arm-trusted-firmware/build/sun50iw1p1/debug/bl31.bin" "${prefix}/share/uboot/";
  53. chown root.wheel "${prefix}/share/uboot/";
  54. ;;
  55. *)
  56. mkdir -p "${prefix}/share/uboot";
  57. cp -dpR "u-boot.bin" "${prefix}/share/uboot/${s_target}-u-boot.bin";
  58. cp -dpR "u-boot-sunxi-with-spl.bin" "${prefix}/share/uboot/${s_target}-u-boot-sunxi-with-spl.bin";
  59. cp -dpR "u-boot-dtb.bin" "${prefix}/share/uboot/${s_target}-u-boot-dtb.bin";
  60. chown root.wheel "${prefix}/share/uboot/";
  61. ;;
  62. esac
  63. fi
  64. done
  65.  
  66. mkdir -p "${prefix}/share/man/man1";cp -dpR doc/*.1 "${prefix}/share/man/man1";chown -R man.man "${prefix}/share/man";
  67.  
  68. #make install DESTDIR="${root}"
  69.  
  70. rm -Rf "${prefix}/info"
  71.  
  72. if [ -d "${prefix}/man" ]; then mv "${prefix}/man" "${prefix}/share/man" ; rmdir "${prefix}/man" ; fi
  73. if [ -d "${prefix}/info" ]; then mv "${prefix}/info" "${prefix}/share/info" ; rmdir "${prefix}/info" ; fi
  74.  
  75. ${s_crossprefix}strip ${prefix}/bin/* ${prefix}/lib${LIBDIRSUFFIX}/*.so
  76. lzma -9 ${prefix}/share/man/man*/* ; chown -R man.man ${prefix}/share/man
  77. find ${prefix}/share/locale/* -maxdepth 0 -type d \! -name "fr" -a \! -name "en*" | xargs rm -Rf
  78.  
  79. rm -Rf "${prefix}/share/info" "${prefix}/share/doc"
  80.  
  81. if [ -f "${root}/sunxi-spl.bin" ]; then echo "Error 9 - h5 sunxi-spl.bin not processed..."; exit -1; fi;
  82. if [ -n "${s_binonly}" ]; then rm -Rf "${prefix}/bin" "${prefix}/share/man"; fi;
  83.  
  84. ( nam="../$(cd ${1:-.} ; basename $(pwd))-${ARCH}-${BUILD}${s_pkgext}" ; cd "${root}" ; makepkg -l y -c n "${nam}" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement