sdk.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/bin/bash
  2. ROOT_PATH=`pwd`
  3. TOOLS_PATH="tools/bin2ext4"
  4. # set default value
  5. MACHINE="light-fm"
  6. IMAGE_PATH=${ROOT_PATH}"/../tmp-glibc/deploy/images/"${MACHINE}
  7. TEE_PATH=${ROOT_PATH}"/../tmp-glibc/work/riscv64-oe-linux/op-tee/0.1-r0/git"
  8. DEB_PATH=${ROOT_PATH}"/../tmp-glibc/deploy/deb"
  9. #echo "ROOT_PATH="${ROOT_PATH}
  10. #echo "IMAGE_PATH="${IMAGE_PATH}
  11. print_help(){
  12. echo -e "\033[32m ===\t\t This is a script used to generate Linux SDK \t\t\t==\033[0m"
  13. echo -e "\033[32m ** it will get MACHINE and IMAGE information from file build-id.txt saved in buildhistory** ==\033[0m"
  14. }
  15. # copy boot image
  16. do_copy_boot(){
  17. echo -e "\033[32m === copy boot image ==\033[0m"
  18. set -x
  19. cp ${IMAGE_PATH}/boot.ext4 images/${MACHINE}/
  20. set +x
  21. }
  22. # copy uboot images
  23. do_copy_uboot(){
  24. echo -e "\033[32m === copy uboot images ==\033[0m"
  25. set -x
  26. mkdir -p images/${MACHINE}/light_fastboot_image_single_rank
  27. cp ${IMAGE_PATH}/u-boot-with-spl.bin images/${MACHINE}/light_fastboot_image_single_rank/u-boot-with-spl.bin
  28. set +x
  29. }
  30. # copy security related images
  31. do_copy_secimages(){
  32. echo -e "\033[32m === copy security related images ==\033[0m"
  33. set -x
  34. if echo "${MACHINE}" | grep -q "light-a-"; then
  35. cp -r images/prebuild/light-fm-a/light_fastboot_image_single_rank_sec images/${MACHINE}/
  36. elif echo "${MACHINE}" | grep -q "light-b-"; then
  37. cp -r images/prebuild/light-fm-b/light_fastboot_image_single_rank_sec images/${MACHINE}/
  38. else
  39. return 0
  40. fi
  41. cp ${IMAGE_PATH}/tf.ext4 images/${MACHINE}/light_fastboot_image_single_rank_sec/
  42. cp ${IMAGE_PATH}/tee.ext4 images/${MACHINE}/light_fastboot_image_single_rank_sec/
  43. if [ ! -d software/Tsec_dev_kit ]; then
  44. cp -r ${IMAGE_PATH}/Tsec_dev_kit software/
  45. fi
  46. set +x
  47. }
  48. # copy rootfs,if more than one rootfs have been compiled, all of them will be copied
  49. do_copy_rootfs(){
  50. echo -e "\033[32m === copy rootfs,if more than one rootfs have been compiled, all of them will be copied ==\033[0m"
  51. set -x
  52. cp ${IMAGE_PATH}/${IMAGE}-${MACHINE}.ext4 images/${MACHINE}/rootfs.${IMAGE}.ext4
  53. # if echo "${IMAGE}" | grep -q "linux-test"; then
  54. # cp ${IMAGE_PATH}/${IMAGE}-${MACHINE}.ext4 images/${MACHINE}/rootfs.test.ext4
  55. # else
  56. # cp ${IMAGE_PATH}/${IMAGE}-${MACHINE}.ext4 images/${MACHINE}/rootfs.ext4
  57. # fi
  58. set +x
  59. }
  60. do_copy_vmlinux(){
  61. echo -e "\033[32m === copy vmlinux to ${MACHINE} ==\033[0m"
  62. set -x
  63. MACHINE_UNDERLINE=${MACHINE//"-"/"_"}
  64. #echo MACHINE_UNDERLINE=${MACHINE_UNDERLINE}
  65. cp ${ROOT_PATH}/../tmp-glibc/work/${MACHINE_UNDERLINE}-oe-linux/linux-thead/*/linux-${MACHINE_UNDERLINE}-standard-build/vmlinux images/${MACHINE}/
  66. set +x
  67. }
  68. # copy deb
  69. do_copy_deb(){
  70. cmd_args=$*
  71. for item in $cmd_args; do
  72. if [ "$item" = "no-deb" ]; then
  73. echo "do_copy_deb() does not executed"
  74. return 0
  75. fi
  76. done
  77. echo -e "\033[32m === copy deb ==\033[0m"
  78. set -x
  79. cp -r ${DEB_PATH} ./
  80. set +x
  81. }
  82. do_tarball(){
  83. cmd_args=$*
  84. for item in $cmd_args; do
  85. if [ "$item" = "no-tarball" ]; then
  86. echo "do_tarball() does not executed"
  87. return 0
  88. fi
  89. done
  90. echo -e "\033[32m === build tarball for ${MACHINE} ==\033[0m"
  91. set -x
  92. mkdir -p tarball
  93. rm -rf /tmp/sdk_tarball/${MACHINE}/images/${MACHINE}
  94. mkdir -p /tmp/sdk_tarball/${MACHINE}/images/${MACHINE}
  95. cp -r images/${MACHINE} /tmp/sdk_tarball/${MACHINE}/images/
  96. cp -r tools /tmp/sdk_tarball/${MACHINE}/
  97. cd /tmp/sdk_tarball/ && tar -zcvf prebuild_${MACHINE}.tar.gz ${MACHINE} && cd -
  98. cp /tmp/sdk_tarball/prebuild_${MACHINE}.tar.gz ./tarball/
  99. set +x
  100. }
  101. do_work(){
  102. cmd_args=$*
  103. echo -e "\033[32m === copy images, go through every MACHINE and copy target images ==\033[0m"
  104. BUILD_INFO_FILE=`find ${ROOT_PATH}/../buildhistory/ -name build-id.txt`
  105. echo "BUILD_INFO_FILE="${BUILD_INFO_FILE}
  106. for file in ${BUILD_INFO_FILE}
  107. do
  108. info=`cat ${file} |head -n 1`
  109. echo ${info}
  110. MACHINE=`echo ${info} |cut -d \: -f 1`
  111. #echo "MACHINE="${MACHINE}
  112. IMAGE=`echo ${info} | cut -d \: -f 2 |cut -d ' ' -f 2`
  113. echo "----------IMAGE="${IMAGE}
  114. IMAGE_PATH=${ROOT_PATH}"/../tmp-glibc/deploy/images/"${MACHINE}
  115. #TARGET=`echo ${IMAGE##*-}`
  116. #echo "TARGET="${TARGET}
  117. echo "create images/"${MACHINE}
  118. mkdir -p images/${MACHINE}
  119. echo -e "\033[36m copy ${MACHINE} images\033[0m"
  120. do_copy_uboot
  121. do_copy_secimages
  122. do_copy_boot
  123. do_copy_rootfs
  124. do_copy_vmlinux
  125. do_tarball $cmd_args
  126. #break
  127. done
  128. do_copy_deb $cmd_args
  129. }
  130. finish(){
  131. echo -e -e "\033[32m Done \033[0m"
  132. }
  133. # start from here
  134. cmd_args=$*
  135. print_help
  136. do_work $cmd_args
  137. finish