Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.12 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #### my name is 1.2.3.Run.sh and I was originally Written By Stifler6996 (Tang73)
  4. ## To get straight to the executed script part, CTRL-F 'KoalaFarts'
  5. ## To modify the dd image size CTRL-F 'seek='
  6. #===== last mod by raxy on 16aug =====
  7. # build leaner image (was 5GB) w/o mate; make prompt more explicit; rm jokes
  8. # replace git clone khadas kernel 4.9 by umidelb kernel 4.13-rc2 repo; j8 by j4, fully handle umiddelb's dtb
  9. # ..handles torvald's source tree (inc. config & dtb), linux-4.9 --> linux-kernel; rename kern compil fn
  10. # ..handle numbqq 412rc6 sources tree, remove unused SBC PC kernel choice, handle mainline special wifi and BT drivers/scripts
  11. # ..950MB rootfs, rm unneeded some comments, handle xenial or zesty
  12. # ..begin can run on aarch64, split in 2 functions to clone uboot and kernel, begin clean inter steps echos
  13. # add git clone raxy
  14. # split make kernel in 3, done all sed/ed changes to give building booting login system
  15. # handle drivers/Kconfig, create patch_mainline_kernel(), handle kernel 4.12.7 stable, double check and split handling of defconfig in multiple cmds
  16. # ethernet works on 4.12.7! clean more of defconfig : rm tegra,arch-non-meson,intel, reshape ed cmds
  17. # to fix no login propt on hdmi display : unremove add CONFIG_FRAMEBUFFER_CONSOLE=y & CONFIG_FB=y, add CONFIG_DRM_MESON_DW_HDMI=y
  18. # ..CONFIG_DRM_MESON & CONFIG_DRM now kernel included (were modules), rm redundant CONFIG_CRYPTO_GHASH_ARM64_CE=y, CONFIG_CRYPTO_SHA1_ARM64_CE=y & CONFIG_CRYPTO_SHA2_ARM64_CE=y
  19. # --TODO next -- clean more of defconfig : debug, qcom, drm non meson, bluetooth, make work, make fbset and work, port to 4.13 when stable
  20. # --TODO next -- make work : usb, ssh server, hdmi boot mesg, sort and uniq defconfig after patching it
  21. # check if in Tang73's original script there was mention to khadas_init.sh which does not run here
  22.  
  23. ###### BASICS ######
  24. SCRIPT_ROOT="$(dirname "$(readlink -fm "$0")")"
  25. COMPONENT_ROOT="$(dirname "$(dirname "$(readlink -fm "$0")")")"
  26. APP_ROOT="$(dirname "$(dirname "$(dirname "$(readlink -fm "$0")")")")"
  27. MY_DTB="kvim.dtb"
  28. UBUN_TAR="undefined"
  29. #### Configure these
  30. OUTPUT_ROOT=${APP_ROOT}/SBC-Images #SBC= Single Board Computer!
  31. UBOOT_ROOT=${COMPONENT_ROOT}/u-boot
  32. KERNEL_ROOT=${COMPONENT_ROOT}/linux-kernel
  33.  
  34. runsOnArm64=0
  35. uname -a | grep aarch64
  36. if [ $? -eq 0 ]; then
  37. runsOnArm64=1
  38. fi
  39.  
  40. #clear
  41. cat <<EOF
  42. Runs on aarch64 : $runsOnArm64
  43. Using root directory : ${APP_ROOT}
  44. Using component folder: ${COMPONENT_ROOT}
  45. Using script folder : ${SCRIPT_ROOT}
  46. Using output folder : ${OUTPUT_ROOT}
  47.  
  48. EOF
  49.  
  50. install -d ${OUTPUT_ROOT}/{addtoimage,rootfs}
  51. install -d ${COMPONENT_ROOT}/{logo,ubuntu-base}
  52. ###### END BASICS ######
  53.  
  54. ###### FUNCTIONS ######
  55. system_setup_aptget () {
  56. echo
  57. echo -e "#####################"
  58. echo -e " system_setup_aptget : complement host system toolings"
  59. cd ${COMPONENT_ROOT}
  60. sudo apt-get update
  61. #sudo apt-get -y upgrade
  62. #OLD sudo apt-get -y install build-essential kernel-package fakeroot libncurses5-dev samba htop screen
  63. #OLD sudo apt-get -y install qemu qemu-user-static binfmt-support debootstrap lib32stdc++6 libstdc++6 sudo apt-get -y install build-essential kernel-package fakeroot libncurses5-dev htop
  64.  
  65. sudo apt-get -y install build-essential fakeroot libncurses5-dev libssl-dev ccache wget bzip2 git
  66. uname -a | grep x86
  67. if [ $? -eq 0 ]; then
  68. #IVN, x86 ! add these :
  69. sudo apt-get -y install gcc-arm-none-eabi gcc-aarch64-linux-gnu
  70. sudo apt-get -y install qemu qemu-user-static binfmt-support lib32stdc++6 libstdc++6
  71. # IVN this one specially for 16.10+ hosts!
  72. sudo apt-get install libnewlib-arm-none-eabi
  73. fi
  74.  
  75. echo
  76. echo -e "##########################"
  77. echo -e " END: host system_setup_aptget "
  78. echo
  79. }
  80.  
  81. system_setup_gitgetuboot () {
  82. cat <<EOF
  83.  
  84. ###############################
  85. system_setup_gitgetuboot : git clone uboot and kernel sources
  86.  
  87. EOF
  88. cd ${COMPONENT_ROOT}
  89. echo -e " (re)cloning u-boot, please wait.."
  90. git clone https://github.com/khadas/u-boot -b ubuntu u-boot
  91.  
  92. cat <<EOF
  93.  
  94. END: ssystem_setup_gitgetuboot
  95. ###############################
  96. EOF
  97. }
  98.  
  99. system_setup_gitgetkern () {
  100. cat <<EOF
  101.  
  102. ###############################
  103. system_setup_gitgetkern : git clone uboot and kernel sources
  104.  
  105. EOF
  106. cd ${COMPONENT_ROOT}
  107. GIT_OPT="--depth 1 --single-branch"
  108. SKIP1=0
  109.  
  110. while true; do
  111. read -n1 -p $'\nGit clone kernel source for (x)4.12.7 (r)axy/torvalds 4.12.0 (n)umbqq 4.12rc6 (k)hadas 4.9 (u)middelb mainline or (m)ainline latest torvalds [n/k/u/m/q]' yn
  112. echo
  113. case $yn in
  114. [m]* ) git clone $GIT_OPT -b master https://github.com/torvalds/linux.git linux-kernel; isMainline=1; touch linux-kernel/isTorvaldsLatest; break;;
  115. [k]* ) git clone $GIT_OPT -b ubuntu-4.9 https://github.com/khadas/linux linux-kernel; touch linux-kernel/isKhadas49; break;;
  116. [n]* ) git clone $GIT_OPT -b 4.12-rc6 https://github.com/numbqq/linux.git linux-kernel; touch linux-kernel/isNumbqq412rc6; break;;
  117. # [u]* ) git clone $GIT_OPT -b new-master https://github.com/ioft/linux.git linux-kernel; touch linux-kernel/isUmiddelb; break;;
  118. # [r]* ) git clone $GIT_OPT -b v4.12-rc6 https://github.com/dsir-minute/linux.git linux-kernel; break;;
  119. [r]* )
  120. git clone $GIT_OPT -b v4.12 https://github.com/torvalds/linux.git linux-kernel
  121. patch_mainline_kernel
  122. touch linux-kernel/is4.12.0-stable
  123. break;;
  124. [x]* )
  125. git clone $GIT_OPT -b linux-4.12.y https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-kernel
  126. touch linux-kernel/is4.12.y-stable
  127. patch_mainline_kernel
  128. break;;
  129. [q]* ) echo "Adios then !!!"; exit;;
  130. * ) echo -e "\n(x)4.12.7 (r)axy/torvalds 4.12.0 (n)umbqq 4.12rc6 (k)hadas 4.9 (u)middelb mainline or (m)ainline latest torvalds or (q)uit";;
  131. esac
  132. done
  133. cat <<EOF
  134.  
  135. END: ssystem_setup_gitgetkern
  136. ###############################
  137.  
  138. EOF
  139. }
  140.  
  141. patch_mainline_kernel() {
  142. SKIP1=1
  143. isMainline=1
  144. KERNPATH=~/project/khadas-build-script/Khadas-Components/linux-kernel
  145. echo '===>> handle device tree ...'
  146. cd ${KERNPATH}/arch/arm64/boot/dts/amlogic
  147. mv meson-gxl-s905x-khadas-vim.dts meson-gxl-s905x-khadas-vim.dts.org
  148. \cp /home/raxy/project/khadas-build-script/mainlineKernAdditions/khadas-vim-raxy.dts ./meson-gxl-s905x-khadas-vim.dts
  149. #echo 'add file partitions.dtsi inlined in special meson-gxl-s905x-khadas-vim.dts before ..'
  150. #\cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/partitions.dtsi .
  151. echo 'no need to copy it to scripts/dtc/include-prefixes/arm64/amlogic/ because theyr are linked!'
  152. #\cp -rf ./meson-gxl-s905x-khadas-vim.dts ${KERNPATH}/scripts/dtc/include-prefixes/arm64/amlogic/
  153. echo '===>> handle defconfig ...'
  154. cd ${KERNPATH}/arch/arm64/configs
  155. cp defconfig defconfig.org
  156. ### EXTRA CAUTION! when string not found, ie "?" printed; delete proceeded anyway !!!
  157. ed -s defconfig << EOF
  158. /CONFIG_SERIAL_MSM=
  159. d
  160. /CONFIG_SERIAL_MSM_CONSOLE=
  161. d
  162. /CONFIG_SERIAL_MVEBU_UART=
  163. d
  164. /CONFIG_I2C_MUX=
  165. d
  166. /CONFIG_I2C_BCM2835=
  167. d
  168. /CONFIG_I2C_IMX=
  169. d
  170. /CONFIG_I2C_MV64XXX=
  171. d
  172. /CONFIG_I2C_PXA=
  173. d
  174. /CONFIG_I2C_QUP=
  175. d
  176. /CONFIG_I2C_SH_MOBILE=
  177. d
  178. /CONFIG_I2C_TEGRA=
  179. d
  180. /CONFIG_I2C_UNIPHIER_F=
  181. d
  182. /CONFIG_I2C_RCAR=
  183. d
  184. /CONFIG_SPI_BCM2835=
  185. d
  186. /CONFIG_SPI_BCM2835AUX=
  187. d
  188. /CONFIG_SPI_ORION=y
  189. d
  190. /CONFIG_SPI_QUP=
  191. d
  192. /CONFIG_SPI_S3C64XX=
  193. d
  194. /CONFIG_PINCTRL_MSM8916=
  195. d
  196. /CONFIG_PINCTRL_MSM8994=
  197. d
  198. /CONFIG_PINCTRL_MSM8996=
  199. d
  200. /CONFIG_PINCTRL_QDF2XXX=
  201. d
  202. /CONFIG_PINCTRL_QCOM_SPMI_PMIC=
  203. d
  204. /CONFIG_GPIO_RCAR=y
  205. d
  206. /CONFIG_GPIO_XGENE_SB=
  207. d
  208. /CONFIG_POWER_RESET_MSM=
  209. d
  210. /CONFIG_ROCKCHIP_THERMAL=
  211. d
  212. /CONFIG_EXYNOS_THERMAL=
  213. d
  214. /CONFIG_S3C2410_WATCHDOG=
  215. d
  216. /CONFIG_RENESAS_WDT=
  217. d
  218. /CONFIG_BCM2835_WDT=
  219. d
  220. /CONFIG_MFD_EXYNOS_LPASS=
  221. d
  222. /CONFIG_MFD_HI655X_PMIC=
  223. d
  224. /CONFIG_MFD_SPMI_PMIC=
  225. d
  226. /CONFIG_REGULATOR_HI655X=
  227. d
  228. /CONFIG_REGULATOR_QCOM_SMD_RPM=
  229. d
  230. /CONFIG_VIDEO_SAMSUNG_S5P_JPEG=
  231. d
  232. /CONFIG_VIDEO_SAMSUNG_S5P_MFC=
  233. d
  234. /CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC=
  235. d
  236. /CONFIG_VIDEO_RENESAS_FCP=
  237. d
  238. /CONFIG_VIDEO_RENESAS_VSP1=
  239. d
  240. /CONFIG_DRM_NOUVEAU=
  241. d
  242. /CONFIG_DRM_EXYNOS=
  243. d
  244. /CONFIG_DRM_EXYNOS5433_DECON=
  245. d
  246. /CONFIG_DRM_EXYNOS7_DECON=
  247. d
  248. /CONFIG_DRM_EXYNOS_DSI=
  249. d
  250. /CONFIG_DRM_EXYNOS_HDMI=
  251. d
  252. /CONFIG_DRM_EXYNOS_MIC=
  253. d
  254. /CONFIG_DRM_RCAR_DU=
  255. d
  256. /CONFIG_DRM_RCAR_LVDS=
  257. d
  258. /CONFIG_DRM_RCAR_VSP=
  259. d
  260. /CONFIG_DRM_TEGRA=
  261. d
  262. /CONFIG_DRM_PANEL_SIMPLE=
  263. d
  264. /CONFIG_DRM_VC4=
  265. d
  266. /CONFIG_DRM_HISI_KIRIN=
  267. d
  268. /CONFIG_SND_BCM2835_SOC_I2S=
  269. d
  270. /CONFIG_SND_SOC_SAMSUNG=
  271. d
  272. /CONFIG_SND_SOC_RCAR=
  273. d
  274. /CONFIG_USB_XHCI_TEGRA=
  275. d
  276. /CONFIG_USB_EHCI_MSM=
  277. d
  278. /CONFIG_USB_EHCI_EXYNOS=
  279. d
  280. /CONFIG_USB_OHCI_EXYNOS=
  281. d
  282. /CONFIG_USB_RENESAS_USBHS=
  283. d
  284. /CONFIG_USB_MSM_OTG=
  285. d
  286. /CONFIG_USB_QCOM_8X16_PHY=
  287. d
  288. /CONFIG_USB_RENESAS_USBHS_UDC=
  289. d
  290. /CONFIG_MMC_SDHCI_OF_ESDHC=
  291. d
  292. /CONFIG_MMC_SDHCI_TEGRA=
  293. d
  294. /CONFIG_MMC_SDHCI_MSM=
  295. d
  296. /CONFIG_MMC_SDHI=
  297. d
  298. /CONFIG_MMC_DW_ROCKCHIP=
  299. d
  300. wq
  301. EOF
  302.  
  303. # end of delete block1
  304. ed -s defconfig << EOF
  305. /CONFIG_MMC_SUNXI=
  306. d
  307. /CONFIG_MMC_BCM2835=
  308. d
  309. /CONFIG_RTC_DRV_S3C=
  310. d
  311. /CONFIG_RTC_DRV_SUN6I=
  312. d
  313. /CONFIG_RTC_DRV_TEGRA=
  314. d
  315. /CONFIG_RTC_DRV_XGENE=
  316. d
  317. /CONFIG_DMA_BCM2835=
  318. d
  319. /CONFIG_TEGRA20_APB_DMA=
  320. d
  321. /CONFIG_QCOM_BAM_DMA=
  322. d
  323. /CONFIG_RCAR_DMAC=
  324. d
  325. /CONFIG_COMMON_CLK_QCOM=
  326. d
  327. /CONFIG_QCOM_CLK_SMD_RPM=
  328. d
  329. /CONFIG_MSM_GCC_8916=
  330. d
  331. /CONFIG_MSM_GCC_8994=
  332. d
  333. /CONFIG_MSM_MMCC_8996=
  334. d
  335. /CONFIG_HWSPINLOCK_QCOM=
  336. d
  337. /CONFIG_BCM2835_MBOX=
  338. d
  339. /CONFIG_HI6220_MBOX
  340. d
  341. /CONFIG_RPMSG_QCOM_SMD=
  342. d
  343. /CONFIG_RASPBERRYPI_POWER=
  344. d
  345. /CONFIG_QCOM_SMEM=
  346. d
  347. /CONFIG_QCOM_SMD_RPM=
  348. d
  349. /CONFIG_QCOM_SMP2P=
  350. d
  351. /CONFIG_QCOM_SMSM=
  352. d
  353. /CONFIG_ROCKCHIP_PM_DOMAINS=
  354. d
  355. /CONFIG_ARCH_TEGRA_132_SOC=
  356. d
  357. /CONFIG_ARCH_TEGRA_210_SOC=
  358. d
  359. /CONFIG_ARCH_TEGRA_186_SOC=
  360. d
  361. /CONFIG_EXYNOS_ADC=
  362. d
  363. /CONFIG_ROCKCHIP_SARADC=
  364. d
  365. /CONFIG_PWM_BCM2835=
  366. d
  367. /CONFIG_PWM_ROCKCHIP=
  368. d
  369. /CONFIG_PWM_SAMSUNG=
  370. d
  371. /CONFIG_PWM_TEGRA=
  372. d
  373. /CONFIG_PHY_RCAR_GEN3_USB2=
  374. d
  375. /CONFIG_PHY_HI6220_USB=
  376. d
  377. /CONFIG_PHY_SUN4I_USB=
  378. d
  379. /CONFIG_PHY_ROCKCHIP_INNO_USB2=
  380. d
  381. /CONFIG_PHY_ROCKCHIP_EMMC=
  382. d
  383. /CONFIG_PHY_ROCKCHIP_PCIE=
  384. d
  385. /CONFIG_PHY_TEGRA_XUSB=
  386. d
  387. /CONFIG_ARCH_R8A7796=
  388. d
  389. /CONFIG_ARCH_STRATIX10=
  390. d
  391. /CONFIG_ARCH_TEGRA=
  392. d
  393. /CONFIG_ARCH_SPRD=
  394. d
  395. /CONFIG_ARCH_THUNDER=
  396. d
  397. /CONFIG_ARCH_THUNDER2=
  398. d
  399. wq
  400. EOF
  401.  
  402. # end of delete block2
  403. ed -s defconfig << EOF
  404. /CONFIG_ARCH_UNIPHIER=
  405. d
  406. /CONFIG_ARCH_VEXPRESS=
  407. d
  408. /CONFIG_ARCH_VULCAN=
  409. d
  410. /CONFIG_ARCH_XGENE=
  411. d
  412. /CONFIG_ARCH_ZX=
  413. d
  414. /CONFIG_ARCH_ZYNQMP=
  415. d
  416. /CONFIG_IPV6=
  417. d
  418. /CONFIG_PCI_LAYERSCAPE=
  419. d
  420. /CONFIG_PCIE_QCOM=
  421. d
  422. /CONFIG_PCIE_ARMADA_8K=
  423. d
  424. /CONFIG_PCI_AARDVARK=
  425. d
  426. /CONFIG_PCIE_RCAR=
  427. d
  428. /CONFIG_PCIE_ROCKCHIP=
  429. d
  430. /CONFIG_RASPBERRYPI_FIRMWARE=
  431. d
  432. /CONFIG_AHCI_MVEBU=
  433. d
  434. /CONFIG_SATA_RCAR=
  435. d
  436. /CONFIG_NET_XGENE=
  437. d
  438. /CONFIG_MVNETA=
  439. d
  440. /CONFIG_MVPP2=
  441. d
  442. /CONFIG_RAVB=
  443. d
  444. /CONFIG_WL18XX=
  445. d
  446. /CONFIG_WLCORE_SDIO=
  447. d
  448. /CONFIG_INPUT_PM8941_PWRKEY=
  449. d
  450. /CONFIG_INPUT_HISI_POWERKEY=
  451. d
  452. /CONFIG_SERIAL_8250_BCM2835AUX=
  453. d
  454. /CONFIG_SERIAL_8250_MT6577=
  455. d
  456. /CONFIG_SERIAL_8250_UNIPHIER=
  457. d
  458. /CONFIG_SERIAL_SAMSUNG=
  459. d
  460. /CONFIG_SERIAL_SAMSUNG_CONSOLE=
  461. d
  462. /CONFIG_SERIAL_TEGRA=
  463. d
  464. /CONFIG_SERIAL_SH_SCI=
  465. d
  466. /CONFIG_SERIAL_SH_SCI_NR_UARTS=
  467. d
  468. /CONFIG_SERIAL_SH_SCI_CONSOLE=
  469. d
  470. wq
  471. EOF
  472. # end of delete block3
  473. ed -s defconfig << EOF
  474. /CONFIG_ARCH_SUNXI=
  475. d
  476. /CONFIG_ARCH_ALPINE=
  477. d
  478. /CONFIG_ARCH_BCM2835=
  479. d
  480. /CONFIG_ARCH_BCM_IPROC=
  481. d
  482. /CONFIG_ARCH_BERLIN=
  483. d
  484. /CONFIG_ARCH_EXYNOS=
  485. d
  486. /CONFIG_ARCH_LAYERSCAPE=
  487. d
  488. /CONFIG_ARCH_LG1K=
  489. d
  490. /CONFIG_ARCH_HISI=
  491. d
  492. /CONFIG_ARCH_MEDIATEK=
  493. d
  494. /CONFIG_ARCH_MVEBU=
  495. d
  496. /CONFIG_ARCH_QCOM=
  497. d
  498. /CONFIG_ARCH_ROCKCHIP=
  499. d
  500. /CONFIG_ARCH_SEATTLE=
  501. d
  502. /CONFIG_ARCH_RENESAS=
  503. d
  504. /CONFIG_ARCH_R8A7795=
  505. d
  506. /CONFIG_BACKLIGHT_GENERIC=
  507. d
  508. /CONFIG_BACKLIGHT_LP855X=
  509. d
  510. wq
  511. EOF
  512. # end of delete block4
  513. ed -s defconfig << EOF
  514. /CONFIG_BRCMFMAC=
  515. a
  516. CONFIG_BRCM_TRACING=y
  517. CONFIG_BRCMDBG=y
  518. CONFIG_ARCH_BRCMSTB=y
  519. CONFIG_AMLOGIC_DRIVER=y
  520. CONFIG_AMLOGIC_MODIFY=y
  521. CONFIG_AMLOGIC_IOMAP=y
  522. CONFIG_AMLOGIC_MMC=y
  523. CONFIG_AMLOGIC_BT_DEVICE=y
  524. CONFIG_REGULATOR=y
  525. CONFIG_SND_SIMPLE_CARD=y
  526. CONFIG_TMPFS=y
  527. CONFIG_PHY_BRCM_SATA=y
  528. CONFIG_PHY_SAMSUNG_USB2=y
  529. CONFIG_BRIDGE_NETFILTER=y
  530. CONFIG_VEXPRESS_CONFIG=y
  531. CONFIG_MVMDIO=y
  532. CONFIG_MDIO_BITBANG=y
  533. CONFIG_I2C_SLAVE=y
  534. CONFIG_SPI_BCM_QSPI=y
  535. CONFIG_POWER_RESET_VEXPRESS=y
  536. CONFIG_DRM_I2C_CH7006=m
  537. CONFIG_DRM_I2C_SIL164=m
  538. CONFIG_DRM_MESON_DW_HDMI=y
  539. CONFIG_COMMON_CLK_VERSATILE=y
  540. CONFIG_CLK_SP810=y
  541. CONFIG_CLK_VEXPRESS_OSC=y
  542. CONFIG_ARM_TIMER_SP804=y
  543. CONFIG_MAILBOX=y
  544. CONFIG_BCM_FLEXRM_MBOX=y
  545. CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
  546. CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
  547. CONFIG_BT_RFCOMM_TTY=y
  548. CONFIG_BT_RFCOMM=y
  549. CONFIG_BT_HCIUART_H4=y
  550. CONFIG_BT_BNEP_MC_FILTER=y
  551. CONFIG_BT_BNEP_PROTO_FILTER=y
  552. CONFIG_BT_BNEP=y
  553. CONFIG_ARM64_CRYPTO=y
  554. .
  555. 1
  556. /CONFIG_RFKILL=m
  557. d
  558. a
  559. CONFIG_RFKILL=y
  560. .
  561. 1
  562. /CONFIG_PWM_MESON=m
  563. d
  564. a
  565. CONFIG_PWM_MESON=y
  566. .
  567. 1
  568. /CONFIG_MESON_GXL_PHY=m
  569. d
  570. a
  571. CONFIG_MESON_GXL_PHY=y
  572. .
  573. 1
  574. /CONFIG_REALTEK_PHY=m
  575. d
  576. a
  577. CONFIG_REALTEK_PHY=y
  578. .
  579. 1
  580. /CONFIG_STMMAC_ETH=m
  581. d
  582. a
  583. CONFIG_STMMAC_ETH=y
  584. .
  585. 1
  586. /CONFIG_DRM_MESON=
  587. d
  588. a
  589. CONFIG_DRM_MESON=y
  590. .
  591. 1
  592. /CONFIG_DRM=
  593. d
  594. a
  595. CONFIG_DRM=y
  596. .
  597. wq
  598. EOF
  599. sort < defconfig | uniq > /tmp/qwerty
  600. mv /tmp/qwerty defconfig
  601. echo '===>> handle block/blk-mq-sched.c ...'
  602. if [ $SKIP1 -eq 1 ]; then
  603. echo '#not needed in 4.12.0'
  604. else
  605. cd $KERNPATH/block
  606. cp blk-mq-sched.c blk-mq-sched.c.org
  607. ed -s blk-mq-sched.c << EOF
  608. /if (set->flags & BLK_MQ_F_TAG_SHARED) {
  609. a
  610. if (!atomic_read(&queue->shared_hctx_restart))
  611. return;
  612. .
  613. wq
  614. EOF
  615. fi
  616.  
  617. echo '===>> handle block/blk-mq.c ...'
  618. if [ $SKIP1 -eq 1 ]; then
  619. echo '#not needed in 4.12.0'
  620. else
  621. cp blk-mq.c blk-mq.c.org
  622. ed -s blk-mq.c << EOF
  623. /if (shared)
  624. d
  625. d
  626. d
  627. d
  628. -1
  629. a
  630. REPLACE_ME
  631. .
  632. wq
  633. EOF
  634. ed -s blk-mq.c << EOF
  635. /REPLACE_ME
  636. d
  637. -1
  638. a
  639. if (shared) {
  640. if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
  641. atomic_inc(&q->shared_hctx_restart);
  642. hctx->flags |= BLK_MQ_F_TAG_SHARED;
  643. } else {
  644. if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
  645. atomic_dec(&q->shared_hctx_restart);
  646. hctx->flags &= ~BLK_MQ_F_TAG_SHARED;
  647. }
  648. .
  649. wq
  650. EOF
  651. fi
  652.  
  653. echo '===>> add drivers/amlogic/* ...'
  654. \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/amlogic $KERNPATH/drivers/
  655.  
  656. echo '===>> handle block.c and inclusion of emmc_partitions.h...'
  657. cd $KERNPATH/drivers/mmc/core
  658. cp block.c block.c.org
  659. ed -s block.c << EOF
  660. /#include "sd_ops.h"
  661. a
  662.  
  663. #ifdef CONFIG_AMLOGIC_MMC
  664. #include <linux/mmc/emmc_partitions.h>
  665. #endif
  666. .
  667. /if (mmc_add_disk(md))
  668. +1a
  669.  
  670. #ifdef CONFIG_AMLOGIC_MMC
  671. /* amlogic add emmc partitions ops */
  672. aml_emmc_partition_ops(card, md->disk);
  673. #endif
  674.  
  675. .
  676. wq
  677. EOF
  678. # echo '===>> invoke emmc_partitions.h from block.c..'
  679. # none of these work
  680. # sed -i "/if \(mmc_add_disk\(md\)\)/a aml_emmc_partition_ops" block.c
  681. # sed -i "/if \(mmc_add_disk\(md\)\)\n\t*goto out;/a aml_emmc_partition_ops;" block.c
  682. # sed -E -i 's/if \(mmc_add_disk\(md\)\)\n.*goto out;/\naml_emmc_partition_ops;/g' block.c
  683. # printf 's/if \(mmc_add_disk\(md\)\)\n.*goto out;/&\naml_emmc_partition_ops;/g' | ed block.c
  684.  
  685. echo '===>> handle drivers/Makefile ...'
  686. cd ${KERNPATH}/drivers
  687. ed -s Makefile << EOF
  688. /CONFIG_TEE
  689. a
  690. obj-\$(CONFIG_AMLOGIC_DRIVER) += amlogic/
  691. .
  692. wq
  693. EOF
  694. echo '===>> upgrade drivers/Kconfig ...'
  695. #cd ${KERNPATH}/drivers
  696. cp Kconfig Kconfig.org
  697. ed -s Kconfig << EOF
  698. /"Device Drivers"
  699. a
  700.  
  701. source "drivers/amlogic/Kconfig"
  702. .
  703. wq
  704. EOF
  705. echo '===>> handle include/linux/mmc/card.h ...'
  706. cd ${KERNPATH}/include/linux/mmc/
  707. ed -s card.h << EOF
  708. /#define MMC_TYPE_SD_COMBO
  709. a
  710. #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
  711. #define MMC_STATE_READONLY (1<<1) /* card is read-only */
  712. #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */
  713. #define MMC_CARD_SDXC (1<<3) /* card is SDXC */
  714. #define MMC_CARD_REMOVED (1<<4) /* card has been removed */
  715. #define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */
  716. #define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */
  717. .
  718. /#define mmc_card_sdio(c)
  719. a
  720.  
  721. #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
  722. #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
  723. #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
  724. #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
  725. #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED))
  726. #define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS)
  727. #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED)
  728. #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
  729. #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
  730. #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
  731. #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
  732. #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
  733. #define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS)
  734. #define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS)
  735. #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
  736. #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
  737. .
  738. wq
  739. EOF
  740. echo '===>> handle include/linux/mmc/host.h ...'
  741. sed -i "/unsigned int *\t*f_init;/a #ifdef CONFIG_AMLOGIC_MMC\n\tu8 first_init_flag;\n#endif" host.h
  742. #sed -i "/#define MMC_CAP2_FULL_PWR_CYCLE/a #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */" host.h
  743. ed -s host.h << EOF
  744. /#define MMC_CAP2_FULL_PWR_CYCLE
  745. a
  746. #ifdef CONFIG_AMLOGIC_MMC
  747. #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */
  748. #endif
  749. .
  750. wq
  751. EOF
  752. echo '===>> add file include/linux/mmc/emmc_partitions.h ..'
  753. \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/mmc/emmc_partitions.h ${KERNPATH}/include/linux/mmc
  754.  
  755. echo '===>> add include/linux/amlogic/*.h ...'
  756. \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/include/linux/amlogic $KERNPATH/include/linux
  757.  
  758. echo '===>> handle include/linux/blkdev.h ...'
  759. if [ $SKIP1 -eq 1 ]; then
  760. echo '#not needed in 4.12.0'
  761. else
  762. cd ${KERNPATH}/include/linux
  763. cp blkdev.h blkdev.h.org
  764. sed -i "/int *\t*nr_rqs_elvpriv;/a atomic_t\tshared_hctx_restart;" blkdev.h
  765. fi
  766.  
  767. echo '===>> handle mm/mmap.c ...'
  768. if [ $SKIP1 -eq 1 ]; then
  769. echo '#not needed in 4.12.0'
  770. else
  771. cd ${KERNPATH}/mm
  772. cp mmap.c mmap.c.org
  773. ed -s mmap.c << EOF
  774. /gap_end >= low_limit && gap_end - gap_start >= length
  775. d
  776. -1a
  777. if (gap_end >= low_limit && gap_end > gap_start && gap_end - gap_start >= length)
  778. .
  779. /gap_start <= high_limit && gap_end - gap_start >= length
  780. d
  781. -1a
  782. if (gap_start <= high_limit && gap_end > gap_start && gap_end - gap_start >= length)
  783. .
  784. /Guard against wrapping around to address 0
  785. d
  786. d
  787. d
  788. d
  789. d
  790. -1a
  791. /* Guard against exceeding limits of the address space. */
  792. address &= PAGE_MASK;
  793. if (address >= TASK_SIZE)
  794. return -ENOMEM;
  795. address += PAGE_SIZE;
  796. .
  797. /if (gap_addr < address)
  798. d
  799. d
  800. -1a
  801.  
  802. /* Guard against overflow */
  803. if (gap_addr < address || gap_addr > TASK_SIZE)
  804. gap_addr = TASK_SIZE;
  805.  
  806. .
  807. wq
  808. EOF
  809. fi
  810.  
  811. echo '===>> handle drivers/clk/meson/Kconfig ...'
  812. if [ $SKIP1 -eq 1 ]; then
  813. echo '#not needed in 4.12.0'
  814. else
  815. cd ${KERNPATH}/drivers/clk/meson
  816. cp Kconfig Kconfig.org
  817. ed -s Kconfig << EOF
  818. /depends on COMMON_CLK_AMLOGIC
  819. /depends on COMMON_CLK_AMLOGIC
  820. n
  821. a
  822. select RESET_CONTROLLER
  823. .
  824. wq
  825. EOF
  826. fi
  827. echo '===>> mainline source tree now fully patched!'
  828. }
  829.  
  830. system_setup_ubuntu-base () {
  831. echo
  832. echo -e "##########################"
  833. echo -e " system_setup_ubuntu-base : get prebuilt ubuntu tar file"
  834. echo
  835. cd ${COMPONENT_ROOT}/ubuntu-base
  836.  
  837. while true; do
  838. read -n1 -p $'\nwget (x)enial 16.04.3 or (z)esty 17.04 ? [x/z]' res
  839. case $res in
  840. [x]* ) UBUN_TAR=ubuntu-base-16.04.3-base-arm64.tar.gz;
  841. wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.3/release/$UBUN_TAR; break;;
  842. [z]* ) UBUN_TAR=ubuntu-base-17.04-base-arm64.tar.gz;
  843. wget http://cdimage.ubuntu.com/ubuntu-base/releases/zesty/release/$UBUN_TAR; break;;
  844. * ) echo -e "\n(x)enial 16.04.3 or (z)esty 17.04 ? ";;
  845. esac
  846. done
  847.  
  848. echo
  849. echo -e " END: system_setup_ubuntu-base "
  850. echo -e "###############################"
  851. echo
  852. }
  853.  
  854. system_setup_logo-bmp () {
  855. echo
  856. echo -e "#######################"
  857. echo -e " system_setup_logo-bmp : get logo image"
  858. echo
  859. cd ${COMPONENT_ROOT}/logo
  860. echo -e " You don't need to do this! I already included some images, they were only small in size!"
  861. echo -e " If you want to change them, they must be a 16/24bit bmp file and should be 1080p or less apparently."
  862. echo -e " This option use to download some images - look at the script if you want to change it."
  863. #wget https://s-media-cache-ak0.pinimg.com/originals/40/51/01/405101b2b3ccd9aef92d79322eaceb59.jpg skull.jpg
  864. #wget https://meyer.io/dl/khadasvim/debian-bootup.bmp
  865. echo
  866. echo -e " END: system_setup_logo-bmp "
  867. echo -e "############################"
  868. echo
  869. }
  870.  
  871. general_question_hdmi () {
  872. echo
  873. echo -e "*** NOTICE! ***"
  874. echo -e "***************\n"
  875. cd ${COMPONENT_ROOT}/u-boot
  876. echo -e "HAVE YOU CHECKED: /u-boot/board/khadas/configs/kvim.h ?"
  877. echo -e "If not, you will probably want to fix it and put 'hdmimode' BACK IN..!"
  878. echo
  879. echo -e "I dont know why I have to do it - but if I do not do this I get a blank screen"
  880. echo -e "during the boot and forever. Everything works, just no HDMI screen."
  881. echo -e "Add this back in and everything is good again?!?! WHY?! WHY!!"
  882. echo
  883. echo -e "Basically add 'hdmimode=1080p60hz' to the bootargs line, like this (it will be all one line in kvim.h):"
  884. echo
  885. cat <<EOF
  886. #### copy/paste the whole line below just under (for non mainline kernels): "bootargs==\" \\
  887. "root=LABEL=ROOTFS rootflags=data=writeback rw logo=osd1,loaded,0x3d800000,1080p60hz,full hdmimode=1080p60hz m_bpp=32 dmfc=3 vout=hdmi cvbsmode=576cvbs console=ttyS0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.repair=yes net.ifnames=0\0" \\
  888.  
  889. EOF
  890. }
  891.  
  892. general_question_macaddr () {
  893. echo
  894. echo -e "*** ANOTHER NOTICE! ***"
  895. echo -e "***********************\n"
  896. cd ${COMPONENT_ROOT}/u-boot
  897. echo -e "HAVE YOU SET YOUR specific ethernet MAC addr ?: (Also in /u-boot/board/khadas/configs/kvim.h)"
  898. echo -e "#define CONFIG_ETHADDR F0:CA:CC:1A:F0:0D"
  899. echo
  900. }
  901.  
  902. compile_firmware_u-boot () {
  903. echo
  904. echo -e "#########################"
  905. echo -e " compile_firmware_u-boot "
  906. echo
  907. cd ${COMPONENT_ROOT}/u-boot
  908. echo -e " Cleaning up - please wait.. "
  909. make clean
  910. make mrproper
  911. make distclean
  912. touch .scmversion
  913. make kvim_defconfig
  914. if [ $runsOnArm64 -eq 1 ]; then
  915. make -j4
  916. else
  917. make -j4 CROSS_COMPILE=aarch64-linux-gnu-
  918. fi
  919. echo
  920. echo -e "##############################"
  921. echo -e " END: compile_firmware_u-boot "
  922. echo
  923. }
  924.  
  925. compile_software_kernel () {
  926. echo
  927. echo -e "#############################"
  928. echo -e " compile_software_kernel "
  929.  
  930. echo
  931. cd ${COMPONENT_ROOT}/linux-kernel
  932. echo -e " Cleaning up - please wait.. "
  933. # 10aug :removed sudos
  934. #make clean
  935. #make mrproper
  936. #make distclean
  937. touch .scmversion
  938. isMainline=0
  939. while true; do
  940. read -n1 -p $'\nCompile (k)hadas (u)middelb mainline (m)torvalds/raxy mainline (n)umbqq 412rc6? [k/u/m/n]' yn
  941. echo
  942. case $yn in
  943. [k]* ) make ARCH=arm64 kvim_defconfig; break;;
  944. [n]* ) make ARCH=arm64 kvim_defconfig; isMainline=1; break;;
  945. [u]* ) make ARCH=arm64 gx_defconfig; isMainline=1; break;;
  946. [m]* ) make ARCH=arm64 defconfig; isMainline=1; break;;
  947. [q]* ) echo -e "Adios then !!!"; exit;;
  948. * ) echo -e "\n(k)hadas (u)middelb mainline (m)torvalds/raxy mainline (n)umbqq 412rc6 or (q)uit";;
  949. esac
  950. done
  951. if [ $isMainline -eq 1 ]; then
  952. SPECIAL_DTB="amlogic/meson-gxl-s905x-khadas-vim.dtb"
  953. echo SPECIAL_DTB:$SPECIAL_DTB
  954. make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- $SPECIAL_DTB
  955. make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules
  956. make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image
  957. #make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- $SPECIAL_DTB
  958. cp ${KERNEL_ROOT}/arch/arm64/boot/dts/$SPECIAL_DTB ${KERNEL_ROOT}/arch/arm64/boot/dts/amlogic/$MY_DTB
  959. else
  960. make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image $MY_DTB modules
  961. fi
  962.  
  963. echo
  964. echo -e " END: compile_software_kernel "
  965. echo -e "##################################"
  966. echo
  967. }
  968.  
  969. build_chroot_filesystem () {
  970. echo
  971. echo -e "#########################"
  972. echo -e " build_chroot_filesystem "
  973. echo
  974.  
  975. cd ${APP_ROOT}
  976.  
  977. #### NOTE: Bare in mind this size need to be a workable size = in your Chroot Jail workable size...
  978. #### So 5GB for desktop is a usable operating space for apt-get to be able to do all its shit within the jail.
  979. #### Once it is done, apt-get clean will get you back some of the space.
  980. #### I worked on adding 1GB to size. So if you know everything you want to install here will ultimately take 4GB, go for 5GB (seek=5120).
  981. #### Also, a good size for a non-GUI image for TESTING is 768MB (you will need to edit a lot of install shit out to fit, but it will be fast!)
  982. #### This isn't a scripted question because I assume you would ALWAYS normally want to make a GUI!
  983. dd if=/dev/zero of=${OUTPUT_ROOT}/rootfs.img bs=1M count=0 seek=950
  984.  
  985. #### Delete and recreate our mount folder (just making sure its empty)
  986. rm -rf ${OUTPUT_ROOT}/rootfs && install -d ${OUTPUT_ROOT}/rootfs
  987. #### Create linux filesystem on the newly created image
  988. sudo mkfs.ext4 -F -L ROOTFS ${OUTPUT_ROOT}/rootfs.img
  989. #### Mount image
  990. echo -e " Slipping a quick mount in.. "
  991. sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
  992. #### Remove the unnecessary files
  993. sudo rm -rf ${OUTPUT_ROOT}/rootfs/lost+found
  994.  
  995. #### Do One or the other (second is more internet intensive. Both result in the same though since later we will apt-get upgrade anyway!)
  996. #### Extract the ubuntu-base tarball into the mounted folder
  997.  
  998. if [ $UBUN_TAR = "undefined" ] ;then
  999. while true; do
  1000. read -n1 -p $'\nexpand (x)enial 16.04.3 or (z)esty 17.04 ? [x/z]' res
  1001. case $res in
  1002. [x]* ) UBUN_TAR=ubuntu-base-16.04.3-base-arm64.tar.gz; break;;
  1003. [z]* ) UBUN_TAR=ubuntu-base-17.04-base-arm64.tar.gz; break;;
  1004. * ) echo -e "\n(x)enial 16.04 or (z)esty 17.04 ? ";;
  1005. esac
  1006. done
  1007. fi
  1008.  
  1009. echo -e "Ubuntu base going in.. "
  1010. sudo tar -xzf ${COMPONENT_ROOT}/ubuntu-base/$UBUN_TAR -C ${OUTPUT_ROOT}/rootfs/
  1011.  
  1012. #### Install Kernel Modules
  1013. echo -e " Kernel modules going in.. "
  1014. #### NOTE: "INSTALL_MOD_STRIP=1" and watch the module size drop by 10X!
  1015. sudo make -C ${COMPONENT_ROOT}/linux-kernel -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=${OUTPUT_ROOT}/rootfs/
  1016.  
  1017. #### Mirrors for de ubuntu-ports
  1018. sudo cp -a ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list.orig
  1019. #### http://ftp.tu-chemnitz.de/pub/linux/ubuntu-ports/
  1020. sudo sed -i "s/http:\/\/ports.ubuntu.com\/ubuntu-ports\//http:\/\/ftp.tu-chemnitz.de\/pub\/linux\/ubuntu-ports\//g" ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list
  1021.  
  1022. #### http://mirror.veracruz.co/ubuntu/
  1023. #### http://mirror.vorboss.net/ubuntu-archive/
  1024. #### http://ubuntu-archive.adsolux.com/ubuntu/
  1025. #### http://mirrors.pol.hostinja.com/ubuntu/
  1026.  
  1027. #### Enable the rest of the source locations (so you can install htop, nano etc)
  1028. sudo sed -i "s/\#\ deb/deb/g" ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list
  1029.  
  1030. #### Grab and file linux version (although we know - this might be useful later when we add
  1031. #### kernel-x.y as a new option to this building script
  1032. grep "Linux/arm64" ${COMPONENT_ROOT}/linux-kernel/.config | awk '{print $3}' > ${OUTPUT_ROOT}/linux-version
  1033. sudo cp -r ${OUTPUT_ROOT}/linux-version ${OUTPUT_ROOT}/rootfs/
  1034. echo
  1035.  
  1036. #### copy over initramfs scripts
  1037. echo -e " initramfs scripts going in.. "
  1038. sudo mkdir -p ${OUTPUT_ROOT}/rootfs/etc/initramfs-tools/scripts/local-top/
  1039. sudo cp -r ${SCRIPT_ROOT}/etc/initramfs-tools/scripts/local-top/khadas_init.sh ${OUTPUT_ROOT}/rootfs/etc/initramfs-tools/scripts/local-top/khadas_init.sh
  1040.  
  1041. sudo chmod +x ${OUTPUT_ROOT}/rootfs/etc/initramfs-tools/scripts/local-top/khadas_init.sh
  1042.  
  1043. #### copy over rc.local scripts
  1044. echo -e " rc.local scripts going in.. "
  1045. sudo cp -r ${SCRIPT_ROOT}/etc/rc.local ${OUTPUT_ROOT}/rootfs/etc/
  1046.  
  1047. #### firstboot initialization: for 'ROOTFS' partition resize
  1048. sudo touch ${OUTPUT_ROOT}/rootfs/etc/default/FIRSTBOOT
  1049.  
  1050. isMainline=0
  1051. while true; do
  1052. read -n1 -p $'\nwhich is your kernel, (k)hadas (u)middelb mainline (m)torvalds mainline (n)umbqq 412rc6? [k/u/m/m]' yn
  1053. case $yn in
  1054. [k]* ) break;;
  1055. [n]* ) isMainline=1; break;;
  1056. [u]* ) isMainline=1; break;;
  1057. [m]* ) isMainline=1; break;;
  1058. [q]* ) echo "go Fukkkkkk!!!"; exit;;
  1059. * ) echo -e "\n(k)hadas (u)middelb mainline (m)torvalds mainline (n)umbqq 412rc6 or (q)uit";;
  1060. esac
  1061. done
  1062.  
  1063. #### Move in FIRMWARE files for WiFi
  1064. sudo mkdir ${OUTPUT_ROOT}/rootfs/lib/firmware
  1065. sudo cp -r ${COMPONENT_ROOT}/hwpacks/wlan-firmware/brcm/ ${OUTPUT_ROOT}/rootfs/lib/firmware/
  1066. ### adjust country code ininsall.txt for wifi
  1067. sudo sed -i -e 's/ccode=AU/ccode=FR/g' ${OUTPUT_ROOT}/rootfs/lib/firmware/brcm/config.txt
  1068.  
  1069. #### Move in patch files for bluetooth
  1070. sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/brcm_patchram_plus ${OUTPUT_ROOT}/rootfs/usr/local/bin/
  1071. sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas.service ${OUTPUT_ROOT}/rootfs/lib/systemd/system/
  1072.  
  1073. if [ $isMainline -eq 1 ]; then
  1074. sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas-mainline.sh ${OUTPUT_ROOT}/rootfs/usr/local/bin/bluetooth-khadas.sh
  1075. cd ${OUTPUT_ROOT}/rootfs/lib/firmware/brcm
  1076. echo "== mainline kernel needs renamed wifi drivers! =="
  1077. sudo cp fw_bcm43438a1.bin brcmfmac43430-sdio.bin
  1078. sudo cp nvram_ap6212a.txt brcmfmac43430-sdio.txt
  1079. sudo cp fw_bcm43455c0_ag.bin brcmfmac43455-sdio.bin
  1080. sudo cp nvram_ap6255.txt brcmfmac43455-sdio.txt
  1081. cd -
  1082. else
  1083. sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas.sh ${OUTPUT_ROOT}/rootfs/usr/local/bin/
  1084. fi
  1085.  
  1086. #### script for executing in chroot
  1087. sudo cp -r ${SCRIPT_ROOT}/99.ChrootScript.sh ${OUTPUT_ROOT}/rootfs/
  1088.  
  1089. #### Setup the Chroot environment
  1090. sudo cp -a /usr/bin/qemu-aarch64-static ${OUTPUT_ROOT}/rootfs/usr/bin/
  1091.  
  1092. #### unmounting
  1093. echo -e " Syncing rootfs."
  1094. sudo sync
  1095. echo -e " unmounting rootfs."
  1096. sudo umount ${OUTPUT_ROOT}/rootfs
  1097.  
  1098. echo
  1099. echo -e " END: build_chroot_filesystem "
  1100. echo -e "##############################"
  1101. echo
  1102. }
  1103.  
  1104. chroot_jail_run () {
  1105. echo
  1106. echo -e "#################"
  1107. echo -e " chroot_jail_run "
  1108. echo
  1109. cd ${APP_ROOT}
  1110. echo -e " Getting my full mount on.. "
  1111. sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
  1112. sudo mount -o bind /proc ${OUTPUT_ROOT}/rootfs/proc
  1113. sudo mount -o bind /sys ${OUTPUT_ROOT}/rootfs/sys
  1114. sudo mount -o bind /dev ${OUTPUT_ROOT}/rootfs/dev
  1115. sudo mount -o bind /dev/pts ${OUTPUT_ROOT}/rootfs/dev/pts
  1116. while true; do
  1117. read -n1 -p $'\nchroot (A)utorun script, (M)anual mode or (B)ack out? [a/m/b]' yn
  1118. case $yn in
  1119. [Aa]* ) echo -e "\n ch'rooting in full auto! "; sudo chroot ${OUTPUT_ROOT}/rootfs/ bash -c "./99.ChrootScript.sh"; break;;
  1120. [Mm]* ) echo -e "\n manual ch'root. Type 'exit' to quit "; sudo chroot ${OUTPUT_ROOT}/rootfs/; break;;
  1121. [Bb]* ) echo -e "\n\n** Shiittt!! *unmounting everything* - you'll probably want to quit on next question! **\n"; break;;
  1122. * ) echo -e "\n(Aa)utorun, (Mm)anual or (Bb)ack out";;
  1123. esac
  1124. done
  1125. echo -e " Syncing rootfs."
  1126. sudo sync
  1127. echo -e " unmount; Climbing off, and flushing the evidence.."
  1128. sudo umount ${OUTPUT_ROOT}/rootfs/dev/pts
  1129. sudo umount ${OUTPUT_ROOT}/rootfs/dev
  1130. sudo umount ${OUTPUT_ROOT}/rootfs/proc
  1131. sudo umount ${OUTPUT_ROOT}/rootfs/sys
  1132. sudo umount ${OUTPUT_ROOT}/rootfs
  1133. echo
  1134. echo -e " END: chroot_jail_run "
  1135. echo -e "######################"
  1136. echo
  1137. }
  1138.  
  1139. chroot_jail_mkinitrfs () {
  1140. echo
  1141. echo -e "#######################"
  1142. echo -e " chroot_jail_mkinitrfs "
  1143. echo
  1144. cd ${APP_ROOT}
  1145. echo -e " Getting my full mount on.. "
  1146. echo
  1147. sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
  1148. sudo mount -o bind /proc ${OUTPUT_ROOT}/rootfs/proc
  1149. sudo mount -o bind /sys ${OUTPUT_ROOT}/rootfs/sys
  1150. sudo mount -o bind /dev ${OUTPUT_ROOT}/rootfs/dev
  1151. sudo mount -o bind /dev/pts ${OUTPUT_ROOT}/rootfs/dev/pts
  1152.  
  1153. sudo cp -a /usr/bin/qemu-aarch64-static ${OUTPUT_ROOT}/rootfs/usr/bin/
  1154. sudo chroot ${OUTPUT_ROOT}/rootfs/ mkinitramfs -o /boot/initrd.img $(cat ${OUTPUT_ROOT}/linux-version)
  1155. cp ${OUTPUT_ROOT}/rootfs/boot/initrd.img ${OUTPUT_ROOT}/initrd.img
  1156. sudo rm -f ${OUTPUT_ROOT}/rootfs/boot/initrd.img
  1157. sudo rm -f ${OUTPUT_ROOT}/rootfs/usr/bin/qemu-aarch64-static
  1158.  
  1159. echo -e " Syncing rootfs."
  1160. sudo sync
  1161. echo -e " unmount; Climbing off, and flushing the evidence.."
  1162. sudo umount ${OUTPUT_ROOT}/rootfs/dev/pts
  1163. sudo umount ${OUTPUT_ROOT}/rootfs/dev
  1164. sudo umount ${OUTPUT_ROOT}/rootfs/proc
  1165. sudo umount ${OUTPUT_ROOT}/rootfs/sys
  1166. sudo umount ${OUTPUT_ROOT}/rootfs
  1167. echo
  1168. echo -e " END: chroot_jail_mkinitrfs "
  1169. echo -e "############################"
  1170. echo
  1171. }
  1172.  
  1173. build_firmware_image () {
  1174. echo
  1175. echo -e "######################"
  1176. echo -e " build_firmware_image "
  1177. echo
  1178. cd ${APP_ROOT}
  1179. echo -e " Copying over DTB, kernel Image, U-Boot bins and config files"
  1180. echo
  1181. cp ${COMPONENT_ROOT}/linux-kernel/arch/arm64/boot/dts/amlogic/$MY_DTB ${OUTPUT_ROOT}
  1182. cp ${COMPONENT_ROOT}/linux-kernel/arch/arm64/boot/Image ${OUTPUT_ROOT}/Image
  1183. cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin ${OUTPUT_ROOT}/u-boot.bin
  1184. cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.sd.bin ${OUTPUT_ROOT}/u-boot.bin.sd.bin
  1185. cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.usb.bl2 ${OUTPUT_ROOT}/u-boot.bin.usb.bl2
  1186. cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.usb.tpl ${OUTPUT_ROOT}/u-boot.bin.usb.tpl
  1187. cp ${SCRIPT_ROOT}/img-pack-cfg/aml_sdc_burn.ini ${OUTPUT_ROOT}/aml_sdc_burn.ini
  1188. cp ${SCRIPT_ROOT}/img-pack-cfg/platform.conf ${OUTPUT_ROOT}/platform.conf
  1189.  
  1190. #### Make the images image!
  1191. echo -e " Making the images/logo package"
  1192. echo
  1193. #### first copy all the images we want to the correct label they need.
  1194. cp ${COMPONENT_ROOT}/logo/skull720.bmp ${OUTPUT_ROOT}/addtoimage/bootup.bmp
  1195. cp ${COMPONENT_ROOT}/logo/upgrade_error.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_error.bmp
  1196. cp ${COMPONENT_ROOT}/logo/upgrade_logo.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_logo.bmp
  1197. cp ${COMPONENT_ROOT}/logo/upgrade_unfocus.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_unfocus.bmp
  1198. cp ${COMPONENT_ROOT}/logo/upgrade_bar.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_bar.bmp
  1199. cp ${COMPONENT_ROOT}/logo/upgrade_fail.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_fail.bmp
  1200. cp ${COMPONENT_ROOT}/logo/upgrade_success.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_success.bmp
  1201. cp ${COMPONENT_ROOT}/logo/upgrade_upgrading.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_upgrading.bmp
  1202. #### Now image all those files to the logo.img packaged file.
  1203. ${COMPONENT_ROOT}/utils/logo_img_packer -r ${OUTPUT_ROOT}/addtoimage ${OUTPUT_ROOT}/logo.img
  1204.  
  1205. echo
  1206. echo -e " Making the ramdisk image "
  1207. FINAL_IMG_FOLDER="/media/raxy/ext3part/SBC-Images"
  1208.  
  1209. ${COMPONENT_ROOT}/utils/mkbootimg --kernel ${OUTPUT_ROOT}/Image --ramdisk ${OUTPUT_ROOT}/initrd.img -o ${OUTPUT_ROOT}/ramdisk.img
  1210. echo
  1211.  
  1212. ${COMPONENT_ROOT}/utils/aml_image_v2_packer -r ${SCRIPT_ROOT}/img-pack-cfg/package.conf ${OUTPUT_ROOT}/ ${FINAL_IMG_FOLDER}/update.img
  1213. mv ${FINAL_IMG_FOLDER}/update.img ${FINAL_IMG_FOLDER}/kVimEmmc-`cat ${OUTPUT_ROOT}/linux-version`-`date +"%Y%m%d%H%M"`.img
  1214.  
  1215. echo
  1216. echo -e " END: build_firmware_image "
  1217. echo -e "###########################"
  1218. echo
  1219. }
  1220.  
  1221. ###### SUPPORT FUNCTIONS! ######
  1222. anykey (){
  1223. $1
  1224. echo -e "I'll just wait here while you go and check shall I?"
  1225. read -n1 -rsp $'Press any key to continue ...\n'
  1226. }
  1227.  
  1228. question () {
  1229. while true; do
  1230. read -n1 -p $'\nDo you need to run '$1'? [y/n/q]' yn
  1231. case $yn in
  1232. [Yy]* ) $1; return;;
  1233. [Nn]* ) return;;
  1234. [Qq]* ) echo -e "\n(X) Good Bye."; exit;;
  1235. * ) echo -e "\n(Yy)es, (Nn)o or (Qq)uit";;
  1236. esac
  1237. done
  1238. }
  1239. ###### END SUPPORT FUNCTIONS! ######
  1240.  
  1241. ###### HERE WE GO - KoalaFarts! ######
  1242. question system_setup_aptget
  1243. question system_setup_gitgetuboot
  1244. question system_setup_gitgetkern
  1245. question system_setup_ubuntu-base
  1246. question system_setup_logo-bmp
  1247. anykey general_question_hdmi
  1248. anykey general_question_macaddr
  1249. question compile_firmware_u-boot
  1250. question compile_software_kernel
  1251. question build_chroot_filesystem
  1252. question chroot_jail_run
  1253. question chroot_jail_mkinitrfs
  1254. question build_firmware_image
  1255. echo -e "\nthis is the END!\n"
  1256. cd ${SCRIPT_ROOT}
  1257. ###### the end! ######
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement