setup.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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-riscv
  48. bitbake-layers add-layer ../meta-starfive
  49. bitbake-layers add-layer ../meta-clang
  50. # fix the configuration
  51. echo "Creating auto.conf"
  52. if [ -e $CONFFILE ]; then
  53. rm -rf $CONFFILE
  54. fi
  55. cat <<EOF > $CONFFILE
  56. MACHINE ?= "${MACHINE}"
  57. #IMAGE_FEATURES += "tools-debug"
  58. #IMAGE_FEATURES += "tools-tweaks"
  59. #IMAGE_FEATURES += "dbg-pkgs"
  60. # rootfs for debugging
  61. #IMAGE_GEN_DEBUGFS = "1"
  62. #IMAGE_FSTYPES_DEBUGFS = "tar.gz"
  63. #EXTRA_IMAGE_FEATURES:append = " ssh-server-dropbear"
  64. EXTRA_IMAGE_FEATURES:append = " package-management"
  65. PACKAGECONFIG:append:pn-qemu-native = " sdl"
  66. PACKAGECONFIG:append:pn-nativesdk-qemu = " sdl"
  67. USER_CLASSES ?= "buildstats buildhistory buildstats-summary"
  68. INHERIT += "uninative"
  69. DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam systemd "
  70. #DISTRO_FEATURES:append = " largefile opengl ptest multiarch wayland pam "
  71. DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
  72. VIRTUAL-RUNTIME_init_manager = "systemd"
  73. ##VIRTUAL-RUNTIME_initscripts = ""
  74. ##VIRTUAL-RUNTIME_syslog = ""
  75. HOSTTOOLS_NONFATAL:append = " ssh"
  76. DISTRO_NAME = "StarFive Linux SDK"
  77. #DISTRO_VERSION = ""
  78. #DISTRO_CODENAME = ""
  79. EOF
  80. echo "---------------------------------------------------"
  81. echo "Example: MACHINE=${MACHINE} bitbake ${BITBAKEIMAGE}"
  82. echo "---------------------------------------------------"
  83. echo ""
  84. echo "Buildable machine info"
  85. echo "---------------------------------------------------"
  86. echo "* qemuriscv64 : The 64-bit RISC-V machine"
  87. echo "* starfive-dubhe : The StarFive Dubhe machine"
  88. echo "---------------------------------------------------"
  89. # start build
  90. #echo "Starting build"
  91. #bitbake $BITBAKEIMAGE
  92. # Launch build script
  93. # Terminal Style
  94. PURPLE='\E[1;35m'
  95. YELLOW='\E[1;33m'
  96. GREEN='\E[0;32m'
  97. RED='\E[0;31m'
  98. NC='\E[0m'
  99. MARK="\033[0;32m\xE2\x9C\x94\033[0m"
  100. #Function
  101. runprog(){
  102. read -p "Do you want to runqemu?[Y/n]:" RES
  103. case $RES in
  104. [Yy])
  105. MACHINE=starfive-dubhe runqemu nographic $1;;
  106. [Nn])
  107. return;;
  108. *)
  109. echo "Invalid option $RES , [Y/n] only.";;
  110. esac
  111. }
  112. updatecfg(){
  113. cfg=("ENABLE_INIT" "ENABLE_EXT4" "ENABLE_UBI" "ENABLE_NFS")
  114. for cfgname in ${cfg[@]}; do
  115. if [[ $1 == ${cfgname} ]]; then
  116. if ! grep -q $1 ./conf/local.conf; then
  117. echo $1="\"1"\" >> ./conf/local.conf;
  118. else sed -i "s/$1=\"0\"/$1=\"1\"/g" ./conf/local.conf;
  119. fi;
  120. else
  121. if ! grep -q ${cfgname} ./conf/local.conf; then
  122. echo ${cfgname}="\"0"\" >> ./conf/local.conf;
  123. else sed -i "s/${cfgname}=\"1\"/${cfgname}=\"0\"/g" ./conf/local.conf;
  124. fi;
  125. fi;
  126. done
  127. }
  128. dubhe(){
  129. # Menu script
  130. echo ""
  131. echo -e "${PURPLE}*******************************************************************"
  132. echo "* *"
  133. echo "* StarFive Dubhe Build Menu *"
  134. echo "* *"
  135. echo -e "*******************************************************************${NC}"
  136. echo "";
  137. echo -e "${YELLOW}Description : ";
  138. echo "";
  139. echo "This build script can build three types of image.";
  140. echo "";
  141. echo "1) QSPI-Image";
  142. echo " - Initramfs has been bundled into qspi-image.";
  143. echo " - Generated output : ";
  144. echo " QSPI-Image.bin";
  145. echo "2) Dubhe-Image-Minimal";
  146. echo " - Minimal image with ext4 support.";
  147. echo " - Generated output : ";
  148. echo " QSPI-EXT4-Image.bin";
  149. echo " SD-Image.img";
  150. echo "3) QSPI-Ubifs-Image";
  151. echo " - Minimal image with ubifs support.";
  152. echo " - Generated output : ";
  153. echo -e " QSPI-Ubifs-Image.bin";
  154. echo "4) QSPI-NFS-Image";
  155. echo " - NFS config has been enabled.";
  156. echo " - Generated output : ";
  157. echo -e " QSPI-NFS-Image.bin${NC}";
  158. echo "";
  159. PS3="Select your action : "
  160. options=("Build qspi-image" "Build dubhe-image-minimal" "Build qspi-ubifs-image" "Build qspi-nfs-image" "Quit")
  161. select opt in "${options[@]}"
  162. do
  163. case $opt in
  164. "Build qspi-image")
  165. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  166. updatecfg ENABLE_INIT;
  167. cur_ter=$(tty);
  168. output=$(MACHINE=starfive-dubhe bitbake qspi-image | tee $cur_ter);
  169. if [[ $output != *"ERROR"* ]]; then
  170. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  171. runprog dubhe-image-initramfs;
  172. else echo -e "\U000274C ${RED}Build Failed${NC}"
  173. fi;;
  174. "Build dubhe-image-minimal")
  175. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  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 qspi-ubifs-image")
  185. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  186. updatecfg ENABLE_UBI
  187. cur_ter=$(tty);
  188. output=$(MACHINE=starfive-dubhe bitbake qspi-ubifs-image | tee $cur_ter);
  189. if [[ $output != *"ERROR"* ]]; then
  190. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  191. else echo -e "\U000274C ${RED}Build Failed${NC}"
  192. fi;;
  193. "Build qspi-nfs-image")
  194. # cd ../build || { echo "Run setup.sh before building images."; cd meta-starfive; break; };
  195. sed -n 47p ../meta-starfive/recipes-kernel/linux/linux-starfive-dev_6.1.20.bb;
  196. read -p "Kindly confirm boot argument such as nfs path and ip address before build (/meta-starfive/recipes-kernel/linux/files/nfs.patch). Proceed to build?[Y/n]:" RES;
  197. case $RES in
  198. [Yy])
  199. updatecfg ENABLE_NFS
  200. cur_ter=$(tty);
  201. output_min=$(MACHINE=starfive-dubhe bitbake qspi-nfs-image | tee $cur_ter);
  202. if [[ $output_min != *"ERROR"* ]]; then
  203. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  204. else echo -e "\U000274C ${RED}Build Failed${NC}"
  205. fi;;
  206. [Nn])
  207. return;;
  208. *)
  209. echo "Invalid option $RES , [Y/n] only.";
  210. esac;;
  211. "Quit")
  212. break;;
  213. *)
  214. echo "Invalid option $REPLY. Kindly select choice between menu range."
  215. esac
  216. REPLY=
  217. done
  218. }
  219. vf2(){
  220. # Menu script
  221. echo ""
  222. echo -e "${PURPLE}*******************************************************************"
  223. echo "* *"
  224. echo "* StarFive Visionfive2 Build Menu *"
  225. echo "* *"
  226. echo -e "*******************************************************************${NC}"
  227. echo "";
  228. echo -e "${YELLOW}Description : ";
  229. echo "";
  230. echo "This build script can build two types of image.";
  231. echo "";
  232. echo "1) core-image-minimal";
  233. echo " - Minimal image with ext4 support.";
  234. echo " - Generated output : ";
  235. echo " starfive-visionfive2-core-image-minimal.img";
  236. echo "2) core-image-minimal-xfce";
  237. echo " - Minimal image with XFCE desktop environment.";
  238. echo " - Generated output : ";
  239. echo " starfive-visionfive2-core-image-minimal-xfce.img";
  240. echo -e "3) Quit${NC}";
  241. echo "";
  242. PS3="Select your action : "
  243. options=("Build core-image-minimal" "Build core-image-minimal-xfce" "Quit")
  244. select opt in "${options[@]}"
  245. do
  246. case $opt in
  247. "Build core-image-minimal")
  248. cur_ter=$(tty);
  249. output_min=$(MACHINE=starfive-visionfive2 bitbake core-image-minimal | tee $cur_ter);
  250. if [[ $output_min != *"ERROR"* ]]; then
  251. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  252. else echo -e "\U000274C ${RED}Build Failed${NC}"
  253. fi;;
  254. "Build core-image-minimal-xfce")
  255. cur_ter=$(tty);
  256. output_min=$(MACHINE=starfive-visionfive2 bitbake core-image-minimal-xfce | tee $cur_ter);
  257. if [[ $output_min != *"ERROR"* ]]; then
  258. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  259. else echo -e "\U000274C ${RED}Build Failed${NC}"
  260. fi;;
  261. "Quit")
  262. break;;
  263. *)
  264. echo "Invalid option $REPLY. Kindly select choice between menu range."
  265. esac
  266. REPLY=
  267. done
  268. }
  269. jh8100(){
  270. # Menu script
  271. echo ""
  272. echo -e "${PURPLE}*******************************************************************"
  273. echo "* *"
  274. echo "* StarFive JH8100 Build Menu *"
  275. echo "* *"
  276. echo -e "*******************************************************************${NC}"
  277. echo "";
  278. echo -e "${YELLOW}Description : ";
  279. echo "";
  280. echo "This build script can build two types of image.";
  281. echo "";
  282. echo "1) core-image-minimal";
  283. echo " - Minimal image with ext4 support.";
  284. echo " - Generated output : ";
  285. echo " starfive-jh8100-core-image-minimal.img";
  286. echo -e "2) Quit${NC}";
  287. echo "";
  288. PS3="Select your action : "
  289. options=("Build core-image-minimal" "Quit")
  290. select opt in "${options[@]}"
  291. do
  292. case $opt in
  293. "Build core-image-minimal")
  294. cur_ter=$(tty);
  295. output_min=$(MACHINE=starfive-jh8100 bitbake core-image-minimal | tee $cur_ter);
  296. if [[ $output_min != *"ERROR"* ]]; then
  297. echo -e "\U0002705 ${GREEN}Build Complete${NC}"
  298. else echo -e "\U000274C ${RED}Build Failed${NC}"
  299. fi;;
  300. "Quit")
  301. break;;
  302. *)
  303. echo "Invalid option $REPLY. Kindly select choice between menu range."
  304. esac
  305. REPLY=
  306. done
  307. }
  308. # Menu script
  309. echo ""
  310. echo -e "${PURPLE}*******************************************************************"
  311. echo "* *"
  312. echo "* Welcome to StarFive Yocto *"
  313. echo "* *"
  314. echo -e "*******************************************************************${NC}"
  315. echo "";
  316. echo -e "${YELLOW}List below shows machine supported : ";
  317. echo "1) StarFive Dubhe";
  318. echo "2) StarFive JH8100";
  319. echo -e "3) Quit${NC}";
  320. echo "";
  321. PS3="Select machine : "
  322. options=("StarFive Dubhe" "StarFive JH8100" "Quit")
  323. select opt in "${options[@]}"
  324. do
  325. case $opt in
  326. "StarFive Dubhe")
  327. dubhe;;
  328. "StarFive JH8100")
  329. jh8100;;
  330. "Quit")
  331. break;;
  332. *)
  333. echo "Invalid option $REPLY. Kindly select choice between menu range."
  334. esac
  335. REPLY=
  336. done