Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #### originally Written By Stifler6996 (Tang73)
- ## To get straight to the executed script part, CTRL-F 'KoalaFarts'
- ## To modify the dd image size CTRL-F 'seek='
- #===== last mod by raxy on 15aug =====
- # build leaner image (was 5GB) w/o mate; make prompt more explicit; rm jokes
- # replace git clone khadas kernel 4.9 by umidelb kernel 4.13-rc2 repo; j8 by j4, fully handle umiddelb's dtb
- # ..handles torvald's source tree (inc. config & dtb), linux-4.9 --> linux-kernel; rename kern compil fn
- # ..handle numbqq 412rc6 sources tree, remove unused SBC PC kernel choice, handle mainline special wifi and BT drivers/scripts
- # ..950MB rootfs, rm unneeded some comments, handle xenial or zesty
- # ..begin can run on aarch64, split in 2 functions to clone uboot and kernel, begin clean inter steps echos
- # add git clone raxy
- # split make kernel in 3, done all sed/ed changes to give building booting login system
- # handle drivers/Kconfig, create patch_mainline_kernel(), handle kernel 4.12.7 stable, double check and split handling of defconfig in multiple cmds
- # ethernet works on 4.12.7! clean more of defconfig : rm tegra,arch-non-meson,intel, reshape ed cmds
- # --TODO next -- clean more of defconfig : debug, qcom, drm non meson, bluetooth, make work, make fbset and work, port to 4.13 when stable
- # --TODO next -- make work : usb, ssh server, hdmi boot mesg: unremove add CONFIG_FRAMEBUFFER_CONSOLE=y & CONFIG_FB=y, add CONFIG_DRM_MESON_DW_HDMI=y
- # check if in Tang73's original script there was mention to khadas_init.sh which does not run here
- ###### BASICS ######
- SCRIPT_ROOT="$(dirname "$(readlink -fm "$0")")"
- COMPONENT_ROOT="$(dirname "$(dirname "$(readlink -fm "$0")")")"
- APP_ROOT="$(dirname "$(dirname "$(dirname "$(readlink -fm "$0")")")")"
- MY_DTB="kvim.dtb"
- UBUN_TAR="undefined"
- #### Configure these
- OUTPUT_ROOT=${APP_ROOT}/SBC-Images #SBC= Single Board Computer!
- UBOOT_ROOT=${COMPONENT_ROOT}/u-boot
- KERNEL_ROOT=${COMPONENT_ROOT}/linux-kernel
- runsOnArm64=0
- uname -a | grep aarch64
- if [ $? -eq 0 ]; then
- runsOnArm64=1
- fi
- #clear
- cat <<EOF
- Runs on aarch64 : $runsOnArm64
- Using root directory : ${APP_ROOT}
- Using component folder: ${COMPONENT_ROOT}
- Using script folder : ${SCRIPT_ROOT}
- Using output folder : ${OUTPUT_ROOT}
- EOF
- install -d ${OUTPUT_ROOT}/{addtoimage,rootfs}
- install -d ${COMPONENT_ROOT}/{logo,ubuntu-base}
- ###### END BASICS ######
- ###### FUNCTIONS ######
- system_setup_aptget () {
- echo
- echo -e "#####################"
- echo -e " system_setup_aptget : complement host system toolings"
- cd ${COMPONENT_ROOT}
- sudo apt-get update
- #sudo apt-get -y upgrade
- #OLD sudo apt-get -y install build-essential kernel-package fakeroot libncurses5-dev samba htop screen
- #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
- sudo apt-get -y install build-essential fakeroot libncurses5-dev libssl-dev ccache wget bzip2 git
- uname -a | grep x86
- if [ $? -eq 0 ]; then
- #IVN, x86 ! add these :
- sudo apt-get -y install gcc-arm-none-eabi gcc-aarch64-linux-gnu
- sudo apt-get -y install qemu qemu-user-static binfmt-support lib32stdc++6 libstdc++6
- # IVN this one specially for 16.10+ hosts!
- sudo apt-get install libnewlib-arm-none-eabi
- fi
- echo
- echo -e "##########################"
- echo -e " END: host system_setup_aptget "
- echo
- }
- system_setup_gitgetuboot () {
- cat <<EOF
- ###############################
- system_setup_gitgetuboot : git clone uboot and kernel sources
- EOF
- cd ${COMPONENT_ROOT}
- echo -e " (re)cloning u-boot, please wait.."
- git clone https://github.com/khadas/u-boot -b ubuntu u-boot
- cat <<EOF
- END: ssystem_setup_gitgetuboot
- ###############################
- EOF
- }
- system_setup_gitgetkern () {
- cat <<EOF
- ###############################
- system_setup_gitgetkern : git clone uboot and kernel sources
- EOF
- cd ${COMPONENT_ROOT}
- GIT_OPT="--depth 1 --single-branch"
- SKIP1=0
- while true; do
- 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
- echo
- case $yn in
- [m]* ) git clone $GIT_OPT -b master https://github.com/torvalds/linux.git linux-kernel; isMainline=1; touch linux-kernel/isTorvaldsLatest; break;;
- [k]* ) git clone $GIT_OPT -b ubuntu-4.9 https://github.com/khadas/linux linux-kernel; touch linux-kernel/isKhadas49; break;;
- [n]* ) git clone $GIT_OPT -b 4.12-rc6 https://github.com/numbqq/linux.git linux-kernel; touch linux-kernel/isNumbqq412rc6; break;;
- # [u]* ) git clone $GIT_OPT -b new-master https://github.com/ioft/linux.git linux-kernel; touch linux-kernel/isUmiddelb; break;;
- # [r]* ) git clone $GIT_OPT -b v4.12-rc6 https://github.com/dsir-minute/linux.git linux-kernel; break;;
- [r]* )
- git clone $GIT_OPT -b v4.12 https://github.com/torvalds/linux.git linux-kernel
- patch_mainline_kernel
- touch linux-kernel/is4.12.0-stable
- break;;
- [x]* )
- git clone $GIT_OPT -b linux-4.12.y https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-kernel
- touch linux-kernel/is4.12.y-stable
- patch_mainline_kernel
- break;;
- [q]* ) echo "Adios then !!!"; exit;;
- * ) 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";;
- esac
- done
- cat <<EOF
- END: ssystem_setup_gitgetkern
- ###############################
- EOF
- }
- patch_mainline_kernel() {
- SKIP1=1
- isMainline=1
- KERNPATH=~/project/khadas-build-script/Khadas-Components/linux-kernel
- echo '===>> handle device tree ...'
- cd ${KERNPATH}/arch/arm64/boot/dts/amlogic
- mv meson-gxl-s905x-khadas-vim.dts meson-gxl-s905x-khadas-vim.dts.org
- \cp /home/raxy/project/khadas-build-script/mainlineKernAdditions/khadas-vim-raxy.dts ./meson-gxl-s905x-khadas-vim.dts
- #echo 'add file partitions.dtsi inlined in special meson-gxl-s905x-khadas-vim.dts before ..'
- #\cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/partitions.dtsi .
- echo 'no need to copy it to scripts/dtc/include-prefixes/arm64/amlogic/ because theyr are linked!'
- #\cp -rf ./meson-gxl-s905x-khadas-vim.dts ${KERNPATH}/scripts/dtc/include-prefixes/arm64/amlogic/
- echo '===>> handle defconfig ...'
- cd ${KERNPATH}/arch/arm64/configs
- cp defconfig defconfig.org
- ### EXTRA CAUTION! when string not found, ie "?" printed; delete proceeded anyway !!!
- ed -s defconfig << EOF
- /CONFIG_SERIAL_MSM=
- d
- /CONFIG_SERIAL_MSM_CONSOLE=
- d
- /CONFIG_SERIAL_MVEBU_UART=
- d
- /CONFIG_I2C_MUX=
- d
- /CONFIG_I2C_BCM2835=
- d
- /CONFIG_I2C_IMX=
- d
- /CONFIG_I2C_MV64XXX=
- d
- /CONFIG_I2C_PXA=
- d
- /CONFIG_I2C_QUP=
- d
- /CONFIG_I2C_SH_MOBILE=
- d
- /CONFIG_I2C_TEGRA=
- d
- /CONFIG_I2C_UNIPHIER_F=
- d
- /CONFIG_I2C_RCAR=
- d
- /CONFIG_SPI_BCM2835=
- d
- /CONFIG_SPI_BCM2835AUX=
- d
- /CONFIG_SPI_ORION=y
- d
- /CONFIG_SPI_QUP=
- d
- /CONFIG_SPI_S3C64XX=
- d
- /CONFIG_PINCTRL_MSM8916=
- d
- /CONFIG_PINCTRL_MSM8994=
- d
- /CONFIG_PINCTRL_MSM8996=
- d
- /CONFIG_PINCTRL_QDF2XXX=
- d
- /CONFIG_PINCTRL_QCOM_SPMI_PMIC=
- d
- /CONFIG_GPIO_RCAR=y
- d
- /CONFIG_GPIO_XGENE_SB=
- d
- /CONFIG_POWER_RESET_MSM=
- d
- /CONFIG_ROCKCHIP_THERMAL=
- d
- /CONFIG_EXYNOS_THERMAL=
- d
- /CONFIG_S3C2410_WATCHDOG=
- d
- /CONFIG_RENESAS_WDT=
- d
- /CONFIG_BCM2835_WDT=
- d
- /CONFIG_MFD_EXYNOS_LPASS=
- d
- /CONFIG_MFD_HI655X_PMIC=
- d
- /CONFIG_MFD_SPMI_PMIC=
- d
- /CONFIG_REGULATOR_HI655X=
- d
- /CONFIG_REGULATOR_QCOM_SMD_RPM=
- d
- /CONFIG_VIDEO_SAMSUNG_S5P_JPEG=
- d
- /CONFIG_VIDEO_SAMSUNG_S5P_MFC=
- d
- /CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC=
- d
- /CONFIG_VIDEO_RENESAS_FCP=
- d
- /CONFIG_VIDEO_RENESAS_VSP1=
- d
- /CONFIG_DRM_NOUVEAU=
- d
- /CONFIG_DRM_EXYNOS=
- d
- /CONFIG_DRM_EXYNOS5433_DECON=
- d
- /CONFIG_DRM_EXYNOS7_DECON=
- d
- /CONFIG_DRM_EXYNOS_DSI=
- d
- /CONFIG_DRM_EXYNOS_HDMI=
- d
- /CONFIG_DRM_EXYNOS_MIC=
- d
- /CONFIG_DRM_RCAR_DU=
- d
- /CONFIG_DRM_RCAR_LVDS=
- d
- /CONFIG_DRM_RCAR_VSP=
- d
- /CONFIG_DRM_TEGRA=
- d
- /CONFIG_DRM_PANEL_SIMPLE=
- d
- /CONFIG_DRM_VC4=
- d
- /CONFIG_DRM_HISI_KIRIN=
- d
- /CONFIG_SND_BCM2835_SOC_I2S=
- d
- /CONFIG_SND_SOC_SAMSUNG=
- d
- /CONFIG_SND_SOC_RCAR=
- d
- /CONFIG_USB_XHCI_TEGRA=
- d
- /CONFIG_USB_EHCI_MSM=
- d
- /CONFIG_USB_EHCI_EXYNOS=
- d
- /CONFIG_USB_OHCI_EXYNOS=
- d
- /CONFIG_USB_RENESAS_USBHS=
- d
- /CONFIG_USB_MSM_OTG=
- d
- /CONFIG_USB_QCOM_8X16_PHY=
- d
- /CONFIG_USB_RENESAS_USBHS_UDC=
- d
- /CONFIG_MMC_SDHCI_OF_ESDHC=
- d
- /CONFIG_MMC_SDHCI_TEGRA=
- d
- /CONFIG_MMC_SDHCI_MSM=
- d
- /CONFIG_MMC_SDHI=
- d
- /CONFIG_MMC_DW_ROCKCHIP=
- d
- wq
- EOF
- # end of delete block1
- ed -s defconfig << EOF
- /CONFIG_MMC_SUNXI=
- d
- /CONFIG_MMC_BCM2835=
- d
- /CONFIG_RTC_DRV_S3C=
- d
- /CONFIG_RTC_DRV_SUN6I=
- d
- /CONFIG_RTC_DRV_TEGRA=
- d
- /CONFIG_RTC_DRV_XGENE=
- d
- /CONFIG_DMA_BCM2835=
- d
- /CONFIG_TEGRA20_APB_DMA=
- d
- /CONFIG_QCOM_BAM_DMA=
- d
- /CONFIG_RCAR_DMAC=
- d
- /CONFIG_COMMON_CLK_QCOM=
- d
- /CONFIG_QCOM_CLK_SMD_RPM=
- d
- /CONFIG_MSM_GCC_8916=
- d
- /CONFIG_MSM_GCC_8994=
- d
- /CONFIG_MSM_MMCC_8996=
- d
- /CONFIG_HWSPINLOCK_QCOM=
- d
- /CONFIG_BCM2835_MBOX=
- d
- /CONFIG_HI6220_MBOX
- d
- /CONFIG_RPMSG_QCOM_SMD=
- d
- /CONFIG_RASPBERRYPI_POWER=
- d
- /CONFIG_QCOM_SMEM=
- d
- /CONFIG_QCOM_SMD_RPM=
- d
- /CONFIG_QCOM_SMP2P=
- d
- /CONFIG_QCOM_SMSM=
- d
- /CONFIG_ROCKCHIP_PM_DOMAINS=
- d
- /CONFIG_ARCH_TEGRA_132_SOC=
- d
- /CONFIG_ARCH_TEGRA_210_SOC=
- d
- /CONFIG_ARCH_TEGRA_186_SOC=
- d
- /CONFIG_EXYNOS_ADC=
- d
- /CONFIG_ROCKCHIP_SARADC=
- d
- /CONFIG_PWM_BCM2835=
- d
- /CONFIG_PWM_ROCKCHIP=
- d
- /CONFIG_PWM_SAMSUNG=
- d
- /CONFIG_PWM_TEGRA=
- d
- /CONFIG_PHY_RCAR_GEN3_USB2=
- d
- /CONFIG_PHY_HI6220_USB=
- d
- /CONFIG_PHY_SUN4I_USB=
- d
- /CONFIG_PHY_ROCKCHIP_INNO_USB2=
- d
- /CONFIG_PHY_ROCKCHIP_EMMC=
- d
- /CONFIG_PHY_ROCKCHIP_PCIE=
- d
- /CONFIG_PHY_TEGRA_XUSB=
- d
- /CONFIG_ARCH_R8A7796=
- d
- /CONFIG_ARCH_STRATIX10=
- d
- /CONFIG_ARCH_TEGRA=
- d
- /CONFIG_ARCH_SPRD=
- d
- /CONFIG_ARCH_THUNDER=
- d
- /CONFIG_ARCH_THUNDER2=
- d
- wq
- EOF
- # end of delete block2
- ed -s defconfig << EOF
- /CONFIG_ARCH_UNIPHIER=
- d
- /CONFIG_ARCH_VEXPRESS=
- d
- /CONFIG_ARCH_VULCAN=
- d
- /CONFIG_ARCH_XGENE=
- d
- /CONFIG_ARCH_ZX=
- d
- /CONFIG_ARCH_ZYNQMP=
- d
- /CONFIG_IPV6=
- d
- /CONFIG_PCI_LAYERSCAPE=
- d
- /CONFIG_PCIE_QCOM=
- d
- /CONFIG_PCIE_ARMADA_8K=
- d
- /CONFIG_PCI_AARDVARK=
- d
- /CONFIG_PCIE_RCAR=
- d
- /CONFIG_PCIE_ROCKCHIP=
- d
- /CONFIG_RASPBERRYPI_FIRMWARE=
- d
- /CONFIG_AHCI_MVEBU=
- d
- /CONFIG_SATA_RCAR=
- d
- /CONFIG_NET_XGENE=
- d
- /CONFIG_MVNETA=
- d
- /CONFIG_MVPP2=
- d
- /CONFIG_RAVB=
- d
- /CONFIG_WL18XX=
- d
- /CONFIG_WLCORE_SDIO=
- d
- /CONFIG_INPUT_PM8941_PWRKEY=
- d
- /CONFIG_INPUT_HISI_POWERKEY=
- d
- /CONFIG_SERIAL_8250_BCM2835AUX=
- d
- /CONFIG_SERIAL_8250_MT6577=
- d
- /CONFIG_SERIAL_8250_UNIPHIER=
- d
- /CONFIG_SERIAL_SAMSUNG=
- d
- /CONFIG_SERIAL_SAMSUNG_CONSOLE=
- d
- /CONFIG_SERIAL_TEGRA=
- d
- /CONFIG_SERIAL_SH_SCI=
- d
- /CONFIG_SERIAL_SH_SCI_NR_UARTS=
- d
- /CONFIG_SERIAL_SH_SCI_CONSOLE=
- d
- wq
- EOF
- # end of delete block3
- ed -s defconfig << EOF
- /CONFIG_ARCH_SUNXI=
- d
- /CONFIG_ARCH_ALPINE=
- d
- /CONFIG_ARCH_BCM2835=
- d
- /CONFIG_ARCH_BCM_IPROC=
- d
- /CONFIG_ARCH_BERLIN=
- d
- /CONFIG_ARCH_EXYNOS=
- d
- /CONFIG_ARCH_LAYERSCAPE=
- d
- /CONFIG_ARCH_LG1K=
- d
- /CONFIG_ARCH_HISI=
- d
- /CONFIG_ARCH_MEDIATEK=
- d
- /CONFIG_ARCH_MVEBU=
- d
- /CONFIG_ARCH_QCOM=
- d
- /CONFIG_ARCH_ROCKCHIP=
- d
- /CONFIG_ARCH_SEATTLE=
- d
- /CONFIG_ARCH_RENESAS=
- d
- /CONFIG_ARCH_R8A7795=
- d
- /CONFIG_BACKLIGHT_GENERIC=
- d
- /CONFIG_BACKLIGHT_LP855X=
- d
- wq
- EOF
- # end of delete block4
- ed -s defconfig << EOF
- /CONFIG_BRCMFMAC=
- a
- CONFIG_BRCM_TRACING=y
- CONFIG_BRCMDBG=y
- CONFIG_ARCH_BRCMSTB=y
- CONFIG_AMLOGIC_DRIVER=y
- CONFIG_AMLOGIC_MODIFY=y
- CONFIG_AMLOGIC_IOMAP=y
- CONFIG_AMLOGIC_MMC=y
- CONFIG_AMLOGIC_BT_DEVICE=y
- CONFIG_REGULATOR=y
- CONFIG_SND_SIMPLE_CARD=y
- CONFIG_TMPFS=y
- CONFIG_PHY_BRCM_SATA=y
- CONFIG_PHY_SAMSUNG_USB2=y
- CONFIG_BRIDGE_NETFILTER=y
- CONFIG_VEXPRESS_CONFIG=y
- CONFIG_MVMDIO=y
- CONFIG_MDIO_BITBANG=y
- CONFIG_I2C_SLAVE=y
- CONFIG_SPI_BCM_QSPI=y
- CONFIG_POWER_RESET_VEXPRESS=y
- CONFIG_DRM_I2C_CH7006=m
- CONFIG_DRM_I2C_SIL164=m
- CONFIG_DRM_MESON_DW_HDMI=y
- CONFIG_COMMON_CLK_VERSATILE=y
- CONFIG_CLK_SP810=y
- CONFIG_CLK_VEXPRESS_OSC=y
- CONFIG_ARM_TIMER_SP804=y
- CONFIG_MAILBOX=y
- CONFIG_BCM_FLEXRM_MBOX=y
- CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
- CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
- CONFIG_CRYPTO_GHASH_ARM64_CE=y
- CONFIG_CRYPTO_SHA1_ARM64_CE=y
- CONFIG_CRYPTO_SHA2_ARM64_CE=y
- CONFIG_BT_RFCOMM_TTY=y
- CONFIG_BT_RFCOMM=y
- CONFIG_BT_HCIUART_H4=y
- CONFIG_BT_BNEP_MC_FILTER=y
- CONFIG_BT_BNEP_PROTO_FILTER=y
- CONFIG_BT_BNEP=y
- CONFIG_ARM64_CRYPTO=y
- .
- 1
- /CONFIG_RFKILL=m
- d
- a
- CONFIG_RFKILL=y
- .
- 1
- /CONFIG_PWM_MESON=m
- d
- a
- CONFIG_PWM_MESON=y
- .
- 1
- /CONFIG_MESON_GXL_PHY=m
- d
- a
- CONFIG_MESON_GXL_PHY=y
- .
- 1
- /CONFIG_REALTEK_PHY=m
- d
- a
- CONFIG_REALTEK_PHY=y
- .
- 1
- /CONFIG_STMMAC_ETH=m
- d
- a
- CONFIG_STMMAC_ETH=y
- .
- wq
- EOF
- echo '===>> handle block/blk-mq-sched.c ...'
- if [ $SKIP1 -eq 1 ]; then
- echo '#not needed in 4.12.0'
- else
- cd $KERNPATH/block
- cp blk-mq-sched.c blk-mq-sched.c.org
- ed -s blk-mq-sched.c << EOF
- /if (set->flags & BLK_MQ_F_TAG_SHARED) {
- a
- if (!atomic_read(&queue->shared_hctx_restart))
- return;
- .
- wq
- EOF
- fi
- echo '===>> handle block/blk-mq.c ...'
- if [ $SKIP1 -eq 1 ]; then
- echo '#not needed in 4.12.0'
- else
- cp blk-mq.c blk-mq.c.org
- ed -s blk-mq.c << EOF
- /if (shared)
- d
- d
- d
- d
- -1
- a
- REPLACE_ME
- .
- wq
- EOF
- ed -s blk-mq.c << EOF
- /REPLACE_ME
- d
- -1
- a
- if (shared) {
- if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
- atomic_inc(&q->shared_hctx_restart);
- hctx->flags |= BLK_MQ_F_TAG_SHARED;
- } else {
- if (test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
- atomic_dec(&q->shared_hctx_restart);
- hctx->flags &= ~BLK_MQ_F_TAG_SHARED;
- }
- .
- wq
- EOF
- fi
- echo '===>> add drivers/amlogic/* ...'
- \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/amlogic $KERNPATH/drivers/
- echo '===>> handle block.c and inclusion of emmc_partitions.h...'
- cd $KERNPATH/drivers/mmc/core
- cp block.c block.c.org
- ed -s block.c << EOF
- /#include "sd_ops.h"
- a
- #ifdef CONFIG_AMLOGIC_MMC
- #include <linux/mmc/emmc_partitions.h>
- #endif
- .
- /if (mmc_add_disk(md))
- +1a
- #ifdef CONFIG_AMLOGIC_MMC
- /* amlogic add emmc partitions ops */
- aml_emmc_partition_ops(card, md->disk);
- #endif
- .
- wq
- EOF
- # echo '===>> invoke emmc_partitions.h from block.c..'
- # none of these work
- # sed -i "/if \(mmc_add_disk\(md\)\)/a aml_emmc_partition_ops" block.c
- # sed -i "/if \(mmc_add_disk\(md\)\)\n\t*goto out;/a aml_emmc_partition_ops;" block.c
- # sed -E -i 's/if \(mmc_add_disk\(md\)\)\n.*goto out;/\naml_emmc_partition_ops;/g' block.c
- # printf 's/if \(mmc_add_disk\(md\)\)\n.*goto out;/&\naml_emmc_partition_ops;/g' | ed block.c
- echo '===>> handle drivers/Makefile ...'
- cd ${KERNPATH}/drivers
- ed -s Makefile << EOF
- /CONFIG_TEE
- a
- obj-\$(CONFIG_AMLOGIC_DRIVER) += amlogic/
- .
- wq
- EOF
- echo '===>> upgrade drivers/Kconfig ...'
- #cd ${KERNPATH}/drivers
- cp Kconfig Kconfig.org
- ed -s Kconfig << EOF
- /"Device Drivers"
- a
- source "drivers/amlogic/Kconfig"
- .
- wq
- EOF
- echo '===>> handle include/linux/mmc/card.h ...'
- cd ${KERNPATH}/include/linux/mmc/
- ed -s card.h << EOF
- /#define MMC_TYPE_SD_COMBO
- a
- #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
- #define MMC_STATE_READONLY (1<<1) /* card is read-only */
- #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */
- #define MMC_CARD_SDXC (1<<3) /* card is SDXC */
- #define MMC_CARD_REMOVED (1<<4) /* card has been removed */
- #define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */
- #define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */
- .
- /#define mmc_card_sdio(c)
- a
- #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
- #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
- #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
- #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
- #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED))
- #define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS)
- #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED)
- #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
- #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
- #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
- #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
- #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
- #define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS)
- #define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS)
- #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
- #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
- .
- wq
- EOF
- echo '===>> handle include/linux/mmc/host.h ...'
- sed -i "/unsigned int *\t*f_init;/a #ifdef CONFIG_AMLOGIC_MMC\n\tu8 first_init_flag;\n#endif" host.h
- #sed -i "/#define MMC_CAP2_FULL_PWR_CYCLE/a #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */" host.h
- ed -s host.h << EOF
- /#define MMC_CAP2_FULL_PWR_CYCLE
- a
- #ifdef CONFIG_AMLOGIC_MMC
- #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */
- #endif
- .
- wq
- EOF
- echo '===>> add file include/linux/mmc/emmc_partitions.h ..'
- \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/mmc/emmc_partitions.h ${KERNPATH}/include/linux/mmc
- echo '===>> add include/linux/amlogic/*.h ...'
- \cp -rf /home/raxy/project/khadas-build-script/mainlineKernAdditions/include/linux/amlogic $KERNPATH/include/linux
- echo '===>> handle include/linux/blkdev.h ...'
- if [ $SKIP1 -eq 1 ]; then
- echo '#not needed in 4.12.0'
- else
- cd ${KERNPATH}/include/linux
- cp blkdev.h blkdev.h.org
- sed -i "/int *\t*nr_rqs_elvpriv;/a atomic_t\tshared_hctx_restart;" blkdev.h
- fi
- echo '===>> handle mm/mmap.c ...'
- if [ $SKIP1 -eq 1 ]; then
- echo '#not needed in 4.12.0'
- else
- cd ${KERNPATH}/mm
- cp mmap.c mmap.c.org
- ed -s mmap.c << EOF
- /gap_end >= low_limit && gap_end - gap_start >= length
- d
- -1a
- if (gap_end >= low_limit && gap_end > gap_start && gap_end - gap_start >= length)
- .
- /gap_start <= high_limit && gap_end - gap_start >= length
- d
- -1a
- if (gap_start <= high_limit && gap_end > gap_start && gap_end - gap_start >= length)
- .
- /Guard against wrapping around to address 0
- d
- d
- d
- d
- d
- -1a
- /* Guard against exceeding limits of the address space. */
- address &= PAGE_MASK;
- if (address >= TASK_SIZE)
- return -ENOMEM;
- address += PAGE_SIZE;
- .
- /if (gap_addr < address)
- d
- d
- -1a
- /* Guard against overflow */
- if (gap_addr < address || gap_addr > TASK_SIZE)
- gap_addr = TASK_SIZE;
- .
- wq
- EOF
- fi
- echo '===>> handle drivers/clk/meson/Kconfig ...'
- if [ $SKIP1 -eq 1 ]; then
- echo '#not needed in 4.12.0'
- else
- cd ${KERNPATH}/drivers/clk/meson
- cp Kconfig Kconfig.org
- ed -s Kconfig << EOF
- /depends on COMMON_CLK_AMLOGIC
- /depends on COMMON_CLK_AMLOGIC
- n
- a
- select RESET_CONTROLLER
- .
- wq
- EOF
- fi
- echo '===>> mainline source tree now fully patched!'
- }
- system_setup_ubuntu-base () {
- echo
- echo -e "##########################"
- echo -e " system_setup_ubuntu-base : get prebuilt ubuntu tar file"
- echo
- cd ${COMPONENT_ROOT}/ubuntu-base
- while true; do
- read -n1 -p $'\nwget (x)enial 16.04.3 or (z)esty 17.04 ? [x/z]' res
- case $res in
- [x]* ) UBUN_TAR=ubuntu-base-16.04.3-base-arm64.tar.gz;
- wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.3/release/$UBUN_TAR; break;;
- [z]* ) UBUN_TAR=ubuntu-base-17.04-base-arm64.tar.gz;
- wget http://cdimage.ubuntu.com/ubuntu-base/releases/zesty/release/$UBUN_TAR; break;;
- * ) echo -e "\n(x)enial 16.04.3 or (z)esty 17.04 ? ";;
- esac
- done
- echo
- echo -e " END: system_setup_ubuntu-base "
- echo -e "###############################"
- echo
- }
- system_setup_logo-bmp () {
- echo
- echo -e "#######################"
- echo -e " system_setup_logo-bmp : get logo image"
- echo
- cd ${COMPONENT_ROOT}/logo
- echo -e " You don't need to do this! I already included some images, they were only small in size!"
- echo -e " If you want to change them, they must be a 16/24bit bmp file and should be 1080p or less apparently."
- echo -e " This option use to download some images - look at the script if you want to change it."
- #wget https://s-media-cache-ak0.pinimg.com/originals/40/51/01/405101b2b3ccd9aef92d79322eaceb59.jpg skull.jpg
- #wget https://meyer.io/dl/khadasvim/debian-bootup.bmp
- echo
- echo -e " END: system_setup_logo-bmp "
- echo -e "############################"
- echo
- }
- general_question_hdmi () {
- echo
- echo -e "*** NOTICE! ***"
- echo -e "***************\n"
- cd ${COMPONENT_ROOT}/u-boot
- echo -e "HAVE YOU CHECKED: /u-boot/board/khadas/configs/kvim.h ?"
- echo -e "If not, you will probably want to fix it and put 'hdmimode' BACK IN..!"
- echo
- echo -e "I dont know why I have to do it - but if I do not do this I get a blank screen"
- echo -e "during the boot and forever. Everything works, just no HDMI screen."
- echo -e "Add this back in and everything is good again?!?! WHY?! WHY!!"
- echo
- echo -e "Basically add 'hdmimode=1080p60hz' to the bootargs line, like this (it will be all one line in kvim.h):"
- echo
- cat <<EOF
- #### copy/paste the whole line below just under (for non mainline kernels): "bootargs==\" \\
- "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" \\
- EOF
- }
- general_question_macaddr () {
- echo
- echo -e "*** ANOTHER NOTICE! ***"
- echo -e "***********************\n"
- cd ${COMPONENT_ROOT}/u-boot
- echo -e "HAVE YOU SET YOUR specific ethernet MAC addr ?: (Also in /u-boot/board/khadas/configs/kvim.h)"
- echo -e "#define CONFIG_ETHADDR F0:CA:CC:1A:F0:0D"
- echo
- }
- compile_firmware_u-boot () {
- echo
- echo -e "#########################"
- echo -e " compile_firmware_u-boot "
- echo
- cd ${COMPONENT_ROOT}/u-boot
- echo -e " Cleaning up - please wait.. "
- make clean
- make mrproper
- make distclean
- touch .scmversion
- make kvim_defconfig
- if [ $runsOnArm64 -eq 1 ]; then
- make -j4
- else
- make -j4 CROSS_COMPILE=aarch64-linux-gnu-
- fi
- echo
- echo -e "##############################"
- echo -e " END: compile_firmware_u-boot "
- echo
- }
- compile_software_kernel () {
- echo
- echo -e "#############################"
- echo -e " compile_software_kernel "
- echo
- cd ${COMPONENT_ROOT}/linux-kernel
- echo -e " Cleaning up - please wait.. "
- # 10aug :removed sudos
- #make clean
- #make mrproper
- #make distclean
- touch .scmversion
- isMainline=0
- while true; do
- read -n1 -p $'\nCompile (k)hadas (u)middelb mainline (m)torvalds/raxy mainline (n)umbqq 412rc6? [k/u/m/n]' yn
- echo
- case $yn in
- [k]* ) make ARCH=arm64 kvim_defconfig; break;;
- [n]* ) make ARCH=arm64 kvim_defconfig; isMainline=1; break;;
- [u]* ) make ARCH=arm64 gx_defconfig; isMainline=1; break;;
- [m]* ) make ARCH=arm64 defconfig; isMainline=1; break;;
- [q]* ) echo -e "Adios then !!!"; exit;;
- * ) echo -e "\n(k)hadas (u)middelb mainline (m)torvalds/raxy mainline (n)umbqq 412rc6 or (q)uit";;
- esac
- done
- if [ $isMainline -eq 1 ]; then
- SPECIAL_DTB="amlogic/meson-gxl-s905x-khadas-vim.dtb"
- echo SPECIAL_DTB:$SPECIAL_DTB
- make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- $SPECIAL_DTB
- make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules
- make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image
- #make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- $SPECIAL_DTB
- cp ${KERNEL_ROOT}/arch/arm64/boot/dts/$SPECIAL_DTB ${KERNEL_ROOT}/arch/arm64/boot/dts/amlogic/$MY_DTB
- else
- make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image $MY_DTB modules
- fi
- echo
- echo -e " END: compile_software_kernel "
- echo -e "##################################"
- echo
- }
- build_chroot_filesystem () {
- echo
- echo -e "#########################"
- echo -e " build_chroot_filesystem "
- echo
- cd ${APP_ROOT}
- #### NOTE: Bare in mind this size need to be a workable size = in your Chroot Jail workable size...
- #### So 5GB for desktop is a usable operating space for apt-get to be able to do all its shit within the jail.
- #### Once it is done, apt-get clean will get you back some of the space.
- #### 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).
- #### 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!)
- #### This isn't a scripted question because I assume you would ALWAYS normally want to make a GUI!
- dd if=/dev/zero of=${OUTPUT_ROOT}/rootfs.img bs=1M count=0 seek=950
- #### Delete and recreate our mount folder (just making sure its empty)
- rm -rf ${OUTPUT_ROOT}/rootfs && install -d ${OUTPUT_ROOT}/rootfs
- #### Create linux filesystem on the newly created image
- sudo mkfs.ext4 -F -L ROOTFS ${OUTPUT_ROOT}/rootfs.img
- #### Mount image
- echo -e " Slipping a quick mount in.. "
- sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
- #### Remove the unnecessary files
- sudo rm -rf ${OUTPUT_ROOT}/rootfs/lost+found
- #### Do One or the other (second is more internet intensive. Both result in the same though since later we will apt-get upgrade anyway!)
- #### Extract the ubuntu-base tarball into the mounted folder
- if [ $UBUN_TAR = "undefined" ] ;then
- while true; do
- read -n1 -p $'\nexpand (x)enial 16.04.3 or (z)esty 17.04 ? [x/z]' res
- case $res in
- [x]* ) UBUN_TAR=ubuntu-base-16.04.3-base-arm64.tar.gz; break;;
- [z]* ) UBUN_TAR=ubuntu-base-17.04-base-arm64.tar.gz; break;;
- * ) echo -e "\n(x)enial 16.04 or (z)esty 17.04 ? ";;
- esac
- done
- fi
- echo -e "Ubuntu base going in.. "
- sudo tar -xzf ${COMPONENT_ROOT}/ubuntu-base/$UBUN_TAR -C ${OUTPUT_ROOT}/rootfs/
- #### Install Kernel Modules
- echo -e " Kernel modules going in.. "
- #### NOTE: "INSTALL_MOD_STRIP=1" and watch the module size drop by 10X!
- 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/
- #### Mirrors for de ubuntu-ports
- sudo cp -a ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list.orig
- #### http://ftp.tu-chemnitz.de/pub/linux/ubuntu-ports/
- 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
- #### http://mirror.veracruz.co/ubuntu/
- #### http://mirror.vorboss.net/ubuntu-archive/
- #### http://ubuntu-archive.adsolux.com/ubuntu/
- #### http://mirrors.pol.hostinja.com/ubuntu/
- #### Enable the rest of the source locations (so you can install htop, nano etc)
- sudo sed -i "s/\#\ deb/deb/g" ${OUTPUT_ROOT}/rootfs/etc/apt/sources.list
- #### Grab and file linux version (although we know - this might be useful later when we add
- #### kernel-x.y as a new option to this building script
- grep "Linux/arm64" ${COMPONENT_ROOT}/linux-kernel/.config | awk '{print $3}' > ${OUTPUT_ROOT}/linux-version
- sudo cp -r ${OUTPUT_ROOT}/linux-version ${OUTPUT_ROOT}/rootfs/
- echo
- #### copy over initramfs scripts
- echo -e " initramfs scripts going in.. "
- sudo mkdir -p ${OUTPUT_ROOT}/rootfs/etc/initramfs-tools/scripts/local-top/
- 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
- sudo chmod +x ${OUTPUT_ROOT}/rootfs/etc/initramfs-tools/scripts/local-top/khadas_init.sh
- #### copy over rc.local scripts
- echo -e " rc.local scripts going in.. "
- sudo cp -r ${SCRIPT_ROOT}/etc/rc.local ${OUTPUT_ROOT}/rootfs/etc/
- #### firstboot initialization: for 'ROOTFS' partition resize
- sudo touch ${OUTPUT_ROOT}/rootfs/etc/default/FIRSTBOOT
- isMainline=0
- while true; do
- read -n1 -p $'\nwhich is your kernel, (k)hadas (u)middelb mainline (m)torvalds mainline (n)umbqq 412rc6? [k/u/m/m]' yn
- case $yn in
- [k]* ) break;;
- [n]* ) isMainline=1; break;;
- [u]* ) isMainline=1; break;;
- [m]* ) isMainline=1; break;;
- [q]* ) echo "go Fukkkkkk!!!"; exit;;
- * ) echo -e "\n(k)hadas (u)middelb mainline (m)torvalds mainline (n)umbqq 412rc6 or (q)uit";;
- esac
- done
- #### Move in FIRMWARE files for WiFi
- sudo mkdir ${OUTPUT_ROOT}/rootfs/lib/firmware
- sudo cp -r ${COMPONENT_ROOT}/hwpacks/wlan-firmware/brcm/ ${OUTPUT_ROOT}/rootfs/lib/firmware/
- ### adjust country code ininsall.txt for wifi
- sudo sed -i -e 's/ccode=AU/ccode=FR/g' ${OUTPUT_ROOT}/rootfs/lib/firmware/brcm/config.txt
- #### Move in patch files for bluetooth
- sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/brcm_patchram_plus ${OUTPUT_ROOT}/rootfs/usr/local/bin/
- sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas.service ${OUTPUT_ROOT}/rootfs/lib/systemd/system/
- if [ $isMainline -eq 1 ]; then
- sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas-mainline.sh ${OUTPUT_ROOT}/rootfs/usr/local/bin/bluetooth-khadas.sh
- cd ${OUTPUT_ROOT}/rootfs/lib/firmware/brcm
- echo "== mainline kernel needs renamed wifi drivers! =="
- sudo cp fw_bcm43438a1.bin brcmfmac43430-sdio.bin
- sudo cp nvram_ap6212a.txt brcmfmac43430-sdio.txt
- sudo cp fw_bcm43455c0_ag.bin brcmfmac43455-sdio.bin
- sudo cp nvram_ap6255.txt brcmfmac43455-sdio.txt
- cd -
- else
- sudo cp -r ${COMPONENT_ROOT}/hwpacks/bluez/bluetooth-khadas.sh ${OUTPUT_ROOT}/rootfs/usr/local/bin/
- fi
- #### script for executing in chroot
- sudo cp -r ${SCRIPT_ROOT}/99.ChrootScript.sh ${OUTPUT_ROOT}/rootfs/
- #### Setup the Chroot environment
- sudo cp -a /usr/bin/qemu-aarch64-static ${OUTPUT_ROOT}/rootfs/usr/bin/
- #### unmounting
- echo -e " Syncing rootfs."
- sudo sync
- echo -e " unmounting rootfs."
- sudo umount ${OUTPUT_ROOT}/rootfs
- echo
- echo -e " END: build_chroot_filesystem "
- echo -e "##############################"
- echo
- }
- chroot_jail_run () {
- echo
- echo -e "#################"
- echo -e " chroot_jail_run "
- echo
- cd ${APP_ROOT}
- echo -e " Getting my full mount on.. "
- sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
- sudo mount -o bind /proc ${OUTPUT_ROOT}/rootfs/proc
- sudo mount -o bind /sys ${OUTPUT_ROOT}/rootfs/sys
- sudo mount -o bind /dev ${OUTPUT_ROOT}/rootfs/dev
- sudo mount -o bind /dev/pts ${OUTPUT_ROOT}/rootfs/dev/pts
- while true; do
- read -n1 -p $'\nchroot (A)utorun script, (M)anual mode or (B)ack out? [a/m/b]' yn
- case $yn in
- [Aa]* ) echo -e "\n ch'rooting in full auto! "; sudo chroot ${OUTPUT_ROOT}/rootfs/ bash -c "./99.ChrootScript.sh"; break;;
- [Mm]* ) echo -e "\n manual ch'root. Type 'exit' to quit "; sudo chroot ${OUTPUT_ROOT}/rootfs/; break;;
- [Bb]* ) echo -e "\n\n** Shiittt!! *unmounting everything* - you'll probably want to quit on next question! **\n"; break;;
- * ) echo -e "\n(Aa)utorun, (Mm)anual or (Bb)ack out";;
- esac
- done
- echo -e " Syncing rootfs."
- sudo sync
- echo -e " unmount; Climbing off, and flushing the evidence.."
- sudo umount ${OUTPUT_ROOT}/rootfs/dev/pts
- sudo umount ${OUTPUT_ROOT}/rootfs/dev
- sudo umount ${OUTPUT_ROOT}/rootfs/proc
- sudo umount ${OUTPUT_ROOT}/rootfs/sys
- sudo umount ${OUTPUT_ROOT}/rootfs
- echo
- echo -e " END: chroot_jail_run "
- echo -e "######################"
- echo
- }
- chroot_jail_mkinitrfs () {
- echo
- echo -e "#######################"
- echo -e " chroot_jail_mkinitrfs "
- echo
- cd ${APP_ROOT}
- echo -e " Getting my full mount on.. "
- echo
- sudo mount -o loop ${OUTPUT_ROOT}/rootfs.img ${OUTPUT_ROOT}/rootfs
- sudo mount -o bind /proc ${OUTPUT_ROOT}/rootfs/proc
- sudo mount -o bind /sys ${OUTPUT_ROOT}/rootfs/sys
- sudo mount -o bind /dev ${OUTPUT_ROOT}/rootfs/dev
- sudo mount -o bind /dev/pts ${OUTPUT_ROOT}/rootfs/dev/pts
- sudo cp -a /usr/bin/qemu-aarch64-static ${OUTPUT_ROOT}/rootfs/usr/bin/
- sudo chroot ${OUTPUT_ROOT}/rootfs/ mkinitramfs -o /boot/initrd.img $(cat ${OUTPUT_ROOT}/linux-version)
- cp ${OUTPUT_ROOT}/rootfs/boot/initrd.img ${OUTPUT_ROOT}/initrd.img
- sudo rm -f ${OUTPUT_ROOT}/rootfs/boot/initrd.img
- sudo rm -f ${OUTPUT_ROOT}/rootfs/usr/bin/qemu-aarch64-static
- echo -e " Syncing rootfs."
- sudo sync
- echo -e " unmount; Climbing off, and flushing the evidence.."
- sudo umount ${OUTPUT_ROOT}/rootfs/dev/pts
- sudo umount ${OUTPUT_ROOT}/rootfs/dev
- sudo umount ${OUTPUT_ROOT}/rootfs/proc
- sudo umount ${OUTPUT_ROOT}/rootfs/sys
- sudo umount ${OUTPUT_ROOT}/rootfs
- echo
- echo -e " END: chroot_jail_mkinitrfs "
- echo -e "############################"
- echo
- }
- build_firmware_image () {
- echo
- echo -e "######################"
- echo -e " build_firmware_image "
- echo
- cd ${APP_ROOT}
- echo -e " Copying over DTB, kernel Image, U-Boot bins and config files"
- echo
- cp ${COMPONENT_ROOT}/linux-kernel/arch/arm64/boot/dts/amlogic/$MY_DTB ${OUTPUT_ROOT}
- cp ${COMPONENT_ROOT}/linux-kernel/arch/arm64/boot/Image ${OUTPUT_ROOT}/Image
- cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin ${OUTPUT_ROOT}/u-boot.bin
- cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.sd.bin ${OUTPUT_ROOT}/u-boot.bin.sd.bin
- cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.usb.bl2 ${OUTPUT_ROOT}/u-boot.bin.usb.bl2
- cp ${COMPONENT_ROOT}/u-boot/fip/u-boot.bin.usb.tpl ${OUTPUT_ROOT}/u-boot.bin.usb.tpl
- cp ${SCRIPT_ROOT}/img-pack-cfg/aml_sdc_burn.ini ${OUTPUT_ROOT}/aml_sdc_burn.ini
- cp ${SCRIPT_ROOT}/img-pack-cfg/platform.conf ${OUTPUT_ROOT}/platform.conf
- #### Make the images image!
- echo -e " Making the images/logo package"
- echo
- #### first copy all the images we want to the correct label they need.
- cp ${COMPONENT_ROOT}/logo/skull720.bmp ${OUTPUT_ROOT}/addtoimage/bootup.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_error.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_error.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_logo.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_logo.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_unfocus.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_unfocus.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_bar.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_bar.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_fail.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_fail.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_success.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_success.bmp
- cp ${COMPONENT_ROOT}/logo/upgrade_upgrading.bmp ${OUTPUT_ROOT}/addtoimage/upgrade_upgrading.bmp
- #### Now image all those files to the logo.img packaged file.
- ${COMPONENT_ROOT}/utils/logo_img_packer -r ${OUTPUT_ROOT}/addtoimage ${OUTPUT_ROOT}/logo.img
- echo
- echo -e " Making the ramdisk image "
- FINAL_IMG_FOLDER="/media/raxy/ext3part/SBC-Images"
- ${COMPONENT_ROOT}/utils/mkbootimg --kernel ${OUTPUT_ROOT}/Image --ramdisk ${OUTPUT_ROOT}/initrd.img -o ${OUTPUT_ROOT}/ramdisk.img
- echo
- ${COMPONENT_ROOT}/utils/aml_image_v2_packer -r ${SCRIPT_ROOT}/img-pack-cfg/package.conf ${OUTPUT_ROOT}/ ${FINAL_IMG_FOLDER}/update.img
- mv ${FINAL_IMG_FOLDER}/update.img ${FINAL_IMG_FOLDER}/kVimEmmc-`cat ${OUTPUT_ROOT}/linux-version`-`date +"%Y%m%d%H%M"`.img
- echo
- echo -e " END: build_firmware_image "
- echo -e "###########################"
- echo
- }
- ###### SUPPORT FUNCTIONS! ######
- anykey (){
- $1
- echo -e "I'll just wait here while you go and check shall I?"
- read -n1 -rsp $'Press any key to continue ...\n'
- }
- question () {
- while true; do
- read -n1 -p $'\nDo you need to run '$1'? [y/n/q]' yn
- case $yn in
- [Yy]* ) $1; return;;
- [Nn]* ) return;;
- [Qq]* ) echo -e "\n(X) Good Bye."; exit;;
- * ) echo -e "\n(Yy)es, (Nn)o or (Qq)uit";;
- esac
- done
- }
- ###### END SUPPORT FUNCTIONS! ######
- ###### HERE WE GO - KoalaFarts! ######
- question system_setup_aptget
- question system_setup_gitgetuboot
- question system_setup_gitgetkern
- question system_setup_ubuntu-base
- question system_setup_logo-bmp
- anykey general_question_hdmi
- anykey general_question_macaddr
- question compile_firmware_u-boot
- question compile_software_kernel
- question build_chroot_filesystem
- question chroot_jail_run
- question chroot_jail_mkinitrfs
- question build_firmware_image
- echo -e "\nthis is the END!\n"
- cd ${SCRIPT_ROOT}
- ###### the end! ######
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement