setup.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #!/bin/bash
  2. # Bootstrapper for buildbot slave
  3. DIR="build"
  4. MACHINE="starfive-dubhe"
  5. CONFFILE="conf/auto.conf"
  6. BITBAKEIMAGE="virtual/kernel"
  7. # clean up the output dir
  8. #echo "Cleaning build dir"
  9. #rm -rf $DIR
  10. # make sure sstate is there
  11. #echo "Creating sstate directory"
  12. #mkdir -p ~/sstate/$MACHINE
  13. # fix permissions set by buildbot
  14. #echo "Fixing permissions for buildbot"
  15. #umask -S u=rwx,g=rx,o=rx
  16. #chmod -R 755 .
  17. # Reconfigure dash on debian-like systems
  18. which aptitude > /dev/null 2>&1
  19. ret=$?
  20. if [ "$(readlink /bin/sh)" = "dash" -a "$ret" = "0" ]; then
  21. sudo aptitude install expect -y
  22. expect -c 'spawn sudo dpkg-reconfigure -freadline dash; send "n\n"; interact;'
  23. elif [ "${0##*/}" = "dash" ]; then
  24. echo "dash as default shell is not supported"
  25. return
  26. fi
  27. # bootstrap OE
  28. if [[ ":$PATH:" != *":$PWD/meta-starfive:"* ]]; then
  29. export PATH=$PATH:$PWD/meta-starfive
  30. fi
  31. echo "Init OE"
  32. export BASH_SOURCE="poky/oe-init-build-env"
  33. source poky/oe-init-build-env
  34. # Symlink the cache
  35. #echo "Setup symlink for sstate"
  36. #ln -s ~/sstate/${MACHINE} sstate-cache
  37. # add the missing layers
  38. echo "Adding layers"
  39. bitbake-layers add-layer ../meta-openembedded/meta-oe
  40. bitbake-layers add-layer ../meta-openembedded/meta-python
  41. bitbake-layers add-layer ../meta-openembedded/meta-multimedia
  42. bitbake-layers add-layer ../meta-openembedded/meta-filesystems
  43. bitbake-layers add-layer ../meta-openembedded/meta-networking
  44. bitbake-layers add-layer ../meta-openembedded/meta-gnome
  45. bitbake-layers add-layer ../meta-openembedded/meta-xfce
  46. bitbake-layers add-layer ../meta-openembedded/meta-webserver
  47. bitbake-layers add-layer ../meta-starfive
  48. bitbake-layers add-layer ../meta-clang
  49. # fix the configuration
  50. echo "Creating auto.conf"
  51. if [ -e $CONFFILE ]; then
  52. rm -rf $CONFFILE
  53. fi
  54. cat <<EOF > $CONFFILE
  55. MACHINE ?= "${MACHINE}"
  56. #IMAGE_FEATURES += "tools-debug"
  57. #IMAGE_FEATURES += "tools-tweaks"
  58. #IMAGE_FEATURES += "dbg-pkgs"
  59. # rootfs for debugging
  60. #IMAGE_GEN_DEBUGFS = "1"
  61. #IMAGE_FSTYPES_DEBUGFS = "tar.gz"
  62. #EXTRA_IMAGE_FEATURES:append = " ssh-server-dropbear"
  63. EXTRA_IMAGE_FEATURES:append = " package-management"
  64. PACKAGECONFIG:append:pn-qemu-native = " sdl"
  65. PACKAGECONFIG:append:pn-nativesdk-qemu = " sdl"
  66. USER_CLASSES ?= "buildstats buildhistory buildstats-summary"
  67. INHERIT += "uninative"
  68. DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam systemd "
  69. #DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam "
  70. DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
  71. VIRTUAL-RUNTIME_init_manager = "systemd"
  72. ##VIRTUAL-RUNTIME_initscripts = ""
  73. ##VIRTUAL-RUNTIME_syslog = ""
  74. HOSTTOOLS_NONFATAL:append = " ssh"
  75. DISTRO_NAME = "StarFive Linux SDK"
  76. #DISTRO_VERSION = ""
  77. #DISTRO_CODENAME = ""
  78. EOF
  79. echo "---------------------------------------------------"
  80. echo "Example: MACHINE=${MACHINE} bitbake ${BITBAKEIMAGE}"
  81. echo "---------------------------------------------------"
  82. echo ""
  83. echo "Buildable machine info"
  84. echo "---------------------------------------------------"
  85. echo "* qemuriscv64 : The 64-bit RISC-V machine"
  86. echo "* starfive-dubhe : The StarFive Dubhe machine"
  87. echo "---------------------------------------------------"
  88. # start build
  89. #echo "Starting build"
  90. #bitbake $BITBAKEIMAGE
  91. # Launch build script
  92. # Terminal Style
  93. PURPLE='\E[1;35m'
  94. YELLOW='\E[1;33m'
  95. GREEN='\E[0;32m'
  96. RED='\E[0;31m'
  97. NC='\E[0m'
  98. MARK="\033[0;32m\xE2\x9C\x94\033[0m"
  99. #Function
  100. runprog(){
  101. read -p "Do you want to runqemu?[Y/n]:" RES
  102. case $RES in
  103. [Yy])
  104. MACHINE=starfive-dubhe runqemu nographic $1;;
  105. [Nn])
  106. return;;
  107. *)
  108. echo "Invalid option $RES , [Y/n] only.";;
  109. esac
  110. }
  111. updatecfg(){
  112. cfg=("ENABLE_INIT" "ENABLE_EXT4" "ENABLE_UBI" "ENABLE_NFS")
  113. for cfgname in ${cfg[@]}; do
  114. if [[ $1 == ${cfgname} ]]; then
  115. if ! grep -q $1 ./conf/local.conf; then
  116. echo $1="\"1"\" >> ./conf/local.conf;
  117. else sed -i "s/$1=\"0\"/$1=\"1\"/g" ./conf/local.conf;
  118. fi;
  119. else
  120. if ! grep -q ${cfgname} ./conf/local.conf; then
  121. echo ${cfgname}="\"0"\" >> ./conf/local.conf;
  122. else sed -i "s/${cfgname}=\"1\"/${cfgname}=\"0\"/g" ./conf/local.conf;
  123. fi;
  124. fi;
  125. done
  126. }
  127. dubhe(){
  128. # Menu script
  129. echo ""
  130. echo -e "${PURPLE}*******************************************************************"
  131. echo "* *"
  132. echo "* StarFive Dubhe Build Menu *"
  133. echo "* *"
  134. echo -e "*******************************************************************${NC}"
  135. echo "";
  136. echo -e "${YELLOW}Description : ";
  137. echo "";
  138. echo "This build script can build three types of image.";
  139. echo "";
  140. echo "1) QSPI-Image";
  141. echo " - QSPI image that boots image via TFTP";
  142. echo " - Generated output : ";
  143. echo " starfive-dubhe-qspi-tftpboot.bin";
  144. echo " Image-initramfs-starfive-dubhe.bin";
  145. echo " dubhe80_fpga.dtb"
  146. echo -e " dubhe90_fpga.dtb${NC}";
  147. #echo "2) Dubhe-Image-Minimal";
  148. #echo " - Minimal image with ext4 support.";
  149. #echo " - Generated output : ";
  150. #echo " QSPI-EXT4-Image.bin";
  151. #echo " SD-Image.img";
  152. #echo "3) QSPI-Ubifs-Image";
  153. #echo " - Minimal image with ubifs support.";
  154. #echo " - Generated output : ";
  155. #echo -e " QSPI-Ubifs-Image.bin";
  156. #echo "4) QSPI-NFS-Image";
  157. #echo " - NFS config has been enabled.";
  158. #echo " - Generated output : ";
  159. #echo -e " QSPI-NFS-Image.bin${NC}";
  160. echo "";
  161. PS3="Select your action : "
  162. options=("Build qspi-image" "Quit")
  163. select opt in "${options[@]}"
  164. do
  165. case $opt in
  166. "Build qspi-image")
  167. updatecfg ENABLE_INIT;
  168. cur_ter=$(tty);
  169. output=$(MACHINE=starfive-dubhe bitbake qspi-image | tee $cur_ter);
  170. if [[ $output != *"ERROR"* ]]; then
  171. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  172. runprog dubhe-image-initramfs;
  173. else echo -e "\U000274C ${RED}Build Failed${NC}"
  174. fi;;
  175. # "Build dubhe-image-minimal")
  176. # updatecfg ENABLE_EXT4
  177. # cur_ter=$(tty);
  178. # output_min=$(MACHINE=starfive-dubhe bitbake dubhe-image-minimal | tee $cur_ter);
  179. # if [[ $output_min != *"ERROR"* ]]; then
  180. # echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  181. # runprog console-image-minimal;
  182. # else echo -e "\U000274C ${RED}Build Failed${NC}"
  183. # fi;;
  184. # "Build qs#pi-ubifs-image")
  185. # updatecfg ENABLE_UBI
  186. # cur_ter=$(tty);
  187. # output=$(MACHINE=starfive-dubhe bitbake qspi-ubifs-image | tee $cur_ter);
  188. # if [[ $output != *"ERROR"* ]]; then
  189. # echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  190. # else echo -e "\U000274C ${RED}Build Failed${NC}"
  191. # fi;;
  192. # "Build qspi-nfs-image")
  193. # sed -n 47p ../meta-starfive/recipes-kernel/linux/linux-starfive-dev_6.1.20.bb;
  194. # read -p "Kindly confirm boot argument such as nfs path and ip address before build (/meta-starfive/recipes-kernel/linux/linux-starfive-dev_6.1.20). Proceed to build?[Y/n]:" RES;
  195. # case $RES in
  196. # [Yy])
  197. # updatecfg ENABLE_NFS
  198. # cur_ter=$(tty);
  199. # output_min=$(MACHINE=starfive-dubhe bitbake qspi-nfs-image | tee $cur_ter);
  200. # if [[ $output_min != *"ERROR"* ]]; then
  201. # echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  202. # else echo -e "\U000274C ${RED}Build Failed${NC}"
  203. # fi;;
  204. # [Nn])
  205. # return;;
  206. # *)
  207. # echo "Invalid option $RES , [Y/n] only.";
  208. # esac;;
  209. "Quit")
  210. break;;
  211. *)
  212. echo "Invalid option $REPLY. Kindly select choice between menu range."
  213. esac
  214. REPLY=
  215. done
  216. }
  217. vf2(){
  218. # Menu script
  219. echo ""
  220. echo -e "${PURPLE}*******************************************************************"
  221. echo "* *"
  222. echo "* StarFive Visionfive2 Build Menu *"
  223. echo "* *"
  224. echo -e "*******************************************************************${NC}"
  225. echo "";
  226. echo -e "${YELLOW}Description : ";
  227. echo "";
  228. echo "This build script can build two types of image.";
  229. echo "";
  230. echo "1) core-image-minimal";
  231. echo " - Minimal image with ext4 support.";
  232. echo " - Generated output : ";
  233. echo " starfive-visionfive2-core-image-minimal.img";
  234. echo "2) core-image-minimal-xfce";
  235. echo " - Minimal image with XFCE desktop environment.";
  236. echo " - Generated output : ";
  237. echo " starfive-visionfive2-core-image-minimal-xfce.img";
  238. echo -e "3) Quit${NC}";
  239. echo "";
  240. PS3="Select your action : "
  241. options=("Build core-image-minimal" "Build core-image-minimal-xfce" "Quit")
  242. select opt in "${options[@]}"
  243. do
  244. case $opt in
  245. "Build core-image-minimal")
  246. cur_ter=$(tty);
  247. output_min=$(MACHINE=starfive-visionfive2 bitbake core-image-minimal | tee $cur_ter);
  248. if [[ $output_min != *"ERROR"* ]]; then
  249. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  250. else echo -e "\U000274C ${RED}Build Failed${NC}"
  251. fi;;
  252. "Build core-image-minimal-xfce")
  253. cur_ter=$(tty);
  254. output_min=$(MACHINE=starfive-visionfive2 bitbake core-image-minimal-xfce | tee $cur_ter);
  255. if [[ $output_min != *"ERROR"* ]]; then
  256. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  257. else echo -e "\U000274C ${RED}Build Failed${NC}"
  258. fi;;
  259. "Quit")
  260. break;;
  261. *)
  262. echo "Invalid option $REPLY. Kindly select choice between menu range."
  263. esac
  264. REPLY=
  265. done
  266. }
  267. jh8100(){
  268. # Menu script
  269. echo ""
  270. echo -e "${PURPLE}*******************************************************************"
  271. echo "* *"
  272. echo "* StarFive JH8100 Build Menu *"
  273. echo "* *"
  274. echo -e "*******************************************************************${NC}"
  275. echo "";
  276. echo -e "${YELLOW}Description : ";
  277. echo "";
  278. echo "This build script can build two types of image.";
  279. echo "";
  280. echo "1) core-image-minimal";
  281. echo " - Minimal image with ext4 support.";
  282. echo " - Generated output : ";
  283. echo " starfive-jh8100-core-image-minimal.img";
  284. echo -e "2) Quit${NC}";
  285. echo "";
  286. PS3="Select your action : "
  287. options=("Build core-image-minimal" "Quit")
  288. select opt in "${options[@]}"
  289. do
  290. case $opt in
  291. "Build core-image-minimal")
  292. cur_ter=$(tty);
  293. output_min=$(MACHINE=starfive-jh8100 bitbake core-image-minimal | tee $cur_ter);
  294. if [[ $output_min != *"ERROR"* ]]; then
  295. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  296. else echo -e "\U000274C ${RED}Build Failed${NC}"
  297. fi;;
  298. "Quit")
  299. break;;
  300. *)
  301. echo "Invalid option $REPLY. Kindly select choice between menu range."
  302. esac
  303. REPLY=
  304. done
  305. }
  306. # Menu script
  307. echo ""
  308. echo -e "${PURPLE}*******************************************************************"
  309. echo "* *"
  310. echo "* Welcome to StarFive Yocto *"
  311. echo "* *"
  312. echo -e "*******************************************************************${NC}"
  313. echo "";
  314. echo -e "${YELLOW}List below shows machine supported : ";
  315. echo "1) StarFive Dubhe";
  316. echo "2) StarFive JH8100";
  317. echo -e "3) Quit${NC}";
  318. echo "";
  319. PS3="Select machine : "
  320. options=("StarFive Dubhe" "StarFive JH8100" "Quit")
  321. select opt in "${options[@]}"
  322. do
  323. case $opt in
  324. "StarFive Dubhe")
  325. dubhe;;
  326. "StarFive JH8100")
  327. jh8100;;
  328. "Quit")
  329. break;;
  330. *)
  331. echo "Invalid option $REPLY. Kindly select choice between menu range."
  332. esac
  333. REPLY=
  334. done