Commit 0b58bbdc1321c1745a99782d12693642d165d708
1 parent
723226c1a4
Exists in
8mm_4.14.98_2.0.0_ga_sumo
Initial Release, Yocto Sumo meta layer Support for SMARC-iMX8MM
Showing 13 changed files with 315 additions and 48 deletions Inline Diff
- conf/layer.conf
- conf/machine/smarcimx8mm2g.conf
- conf/machine/smarcimx8mm4g.conf
- recipes-bsp/imx-atf/imx-atf/imx8mm-atf-uart4.patch
- recipes-bsp/imx-atf/imx-atf_2.0.bbappend
- recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend
- recipes-bsp/u-boot/u-boot-smarcimx8mm_2018.03.bb
- recipes-kernel/linux/linux-smarcimx8mm_4.14.98.bb
- scripts/emb_mk_yocto_sdcard/README.txt
- scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh
- scripts/emb_mk_yocto_sdcard/emb-create-yocto-sdcard.sh
- scripts/emb_mk_yocto_sdcard/uEnv.txt
- scripts/emb_mk_yocto_sdcard/uEnv_emmc.txt
conf/layer.conf
1 | # We have a conf and classes directory, add to BBPATH | 1 | # We have a conf and classes directory, add to BBPATH |
2 | BBPATH .= ":${LAYERDIR}" | 2 | BBPATH .= ":${LAYERDIR}" |
3 | 3 | ||
4 | # We have a packages directory, add to BBFILES | 4 | # We have a packages directory, add to BBFILES |
5 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ | 5 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
6 | ${LAYERDIR}/recipes-*/*/*.bbappend" | 6 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
7 | 7 | ||
8 | BBFILE_COLLECTIONS += "smarcimx8m" | 8 | BBFILE_COLLECTIONS += "smarcimx8mm" |
9 | BBFILE_PATTERN_smarcimx8m := "^${LAYERDIR}/" | 9 | BBFILE_PATTERN_smarcimx8mm := "^${LAYERDIR}/" |
10 | BBFILE_PRIORITY_smarcimx8m = "12" | 10 | BBFILE_PRIORITY_smarcimx8mm = "12" |
11 | 11 | ||
12 | LAYERSERIES_COMPAT_smarcimx8m = "sumo" | 12 | LAYERSERIES_COMPAT_smarcimx8mm = "sumo" |
13 | 13 | ||
14 | LICENSE_PATH += "${LAYERDIR}/licenses" | 14 | LICENSE_PATH += "${LAYERDIR}/licenses" |
15 | 15 | ||
16 | BBMASK += "meta-freescale/recipes-graphics/clutter/clutter-1.0_%.bbappend" | 16 | BBMASK += "meta-freescale/recipes-graphics/clutter/clutter-1.0_%.bbappend" |
17 | BBMASK += "meta-freescale/recipes-graphics/cogl/cogl-1.0_%.bbappend" | 17 | BBMASK += "meta-freescale/recipes-graphics/cogl/cogl-1.0_%.bbappend" |
18 | BBMASK += "meta-freescale/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.6-hfp.bb" | 18 | BBMASK += "meta-freescale/recipes-graphics/imx-gpu-viv/imx-gpu-viv_5.0.11.p8.6-hfp.bb" |
19 | BBMASK += "meta-freescale/recipes-graphics/mesa/mesa-demos_%.bbappend" | 19 | BBMASK += "meta-freescale/recipes-graphics/mesa/mesa-demos_%.bbappend" |
20 | BBMASK += "meta-freescale/recipes-graphics/xorg-driver/xf86-video-imxfb-vivante_5.0.11.p8.6.bb" | 20 | BBMASK += "meta-freescale/recipes-graphics/xorg-driver/xf86-video-imxfb-vivante_5.0.11.p8.6.bb" |
21 | 21 | ||
22 | HOSTTOOLS_NONFATAL_append = " sha384sum xxd" | 22 | HOSTTOOLS_NONFATAL_append = " sha384sum xxd" |
23 | 23 | ||
24 | # Enable optee for all builds using this layer, assuming the machine supports it. | 24 | # Enable optee for all builds using this layer, assuming the machine supports it. |
25 | # To remove optee from the build, add the following line to local.conf: | 25 | # To remove optee from the build, add the following line to local.conf: |
26 | # DISTRO_FEATURES_remove = "optee" | 26 | # DISTRO_FEATURES_remove = "optee" |
27 | # DEPRECATED: The ability to remove optee from the build is deprecated and | 27 | # DEPRECATED: The ability to remove optee from the build is deprecated and |
28 | # will be removed in some future release. | 28 | # will be removed in some future release. |
29 | DISTRO_FEATURES_append = " optee" | 29 | DISTRO_FEATURES_append = " optee" |
30 | 30 | ||
31 | DISTRO_FEATURES_FILTER_NATIVESDK += "wayland" | 31 | DISTRO_FEATURES_FILTER_NATIVESDK += "wayland" |
32 | 32 | ||
33 | EMB_UBOOT_MIRROR ?= "git://git@git.embedian.com/developer/smarc-t335x-uboot.git" | 33 | EMB_UBOOT_MIRROR ?= "git://git@git.embedian.com/developer/smarc-t335x-uboot.git" |
34 | EMB_KERNEL_MIRROR ?= "git://git@git.embedian.com/developer/smarc-fsl-linux-kernel.git" | 34 | EMB_KERNEL_MIRROR ?= "git://git@git.embedian.com/developer/smarc-fsl-linux-kernel.git" |
35 | 35 | ||
36 | MIRRORS += " \ | 36 | MIRRORS += " \ |
37 | ${EMB_UBOOT_MIRROR} git://github.com/embedian/smarc-uboot.git;protocol=git;branch=${SRCBRANCH} \n \ | 37 | ${EMB_UBOOT_MIRROR} git://github.com/embedian/smarc-uboot.git;protocol=git;branch=${SRCBRANCH} \n \ |
38 | ${EMB_KERNEL_MIRROR} git://github.com/embedian/smarc-fsl-linux-kernel.git;protocol=git;branch=${SRCBRANCH} \n \ | 38 | ${EMB_KERNEL_MIRROR} git://github.com/embedian/smarc-fsl-linux-kernel.git;protocol=git;branch=${SRCBRANCH} \n \ |
39 | " | 39 | " |
40 | 40 |
conf/machine/smarcimx8mm2g.conf
File was created | 1 | #@TYPE: Machine | |
2 | #@NAME: EMBEDIAN SMARC-iMX8MM COMPUTER ON MODULES with 2GB LPDDR4 MEMORY | ||
3 | #@SOC: i.MX8MM | ||
4 | #@DESCRIPTION: Machine configuration for Embedian SMARC-iMX8MM | ||
5 | #@MAINTAINER: Eric Lee <eric.lee@embedian.com> | ||
6 | # | ||
7 | # http://www.www.embedian.com | ||
8 | |||
9 | MACHINEOVERRIDES =. "mx8:mx8m:mx8mm:" | ||
10 | require conf/machine/include/imx-base.inc | ||
11 | require conf/machine/include/arm/arch-arm64.inc | ||
12 | |||
13 | MACHINE_FEATURES += " usbgadget vfat ext2 alsa serial pci wifi bluetooth" | ||
14 | |||
15 | IMAGE_FEATURES += "package-management" | ||
16 | |||
17 | # Embedian BSP default providers | ||
18 | PREFERRED_PROVIDER_virtual/kernel_smarcimx8mm2g ?= "linux-smarcimx8mm" | ||
19 | PREFERRED_VERSION_linux-smarcimx8mm2g_smarcimx8mm2g = "4.14.98" | ||
20 | |||
21 | KERNEL_DEVICETREE = " \ | ||
22 | embedian/fsl-smarcimx8mm.dtb \ | ||
23 | " | ||
24 | IMAGE_BOOTFILES_DEPENDS += "imx-m4-demos:do_deploy" | ||
25 | IMAGE_BOOTFILES += "imx8mm_m4_TCM_hello_world.bin imx8mm_m4_TCM_rpmsg_lite_pingpong_rtos_linux_remote.bin imx8mm_m4_TCM_rpmsg_lite_str_echo_rtos.bin" | ||
26 | |||
27 | PREFERRED_PROVIDER_u-boot_smarcimx8mm2g = "u-boot-smarcimx8mm" | ||
28 | PREFERRED_PROVIDER_virtual/bootloader_smarcimx8mm2g = "u-boot-smarcimx8mm" | ||
29 | |||
30 | UBOOT_CONFIG ??= "sd" | ||
31 | UBOOT_CONFIG[sd] = "smarcimx8mm_2g_ser3_defconfig,sdcard" | ||
32 | SPL_BINARY = "spl/u-boot-spl.bin" | ||
33 | |||
34 | # Set DDR FIRMWARE | ||
35 | DDR_FIRMWARE_NAME = "lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_dmem.bin" | ||
36 | |||
37 | # Set U-Boot DTB | ||
38 | UBOOT_DTB_NAME = "fsl-smarcimx8mm.dtb" | ||
39 | |||
40 | # Set imx-mkimage boot target | ||
41 | IMXBOOT_TARGETS = "flash_evk" | ||
42 | |||
43 | SERIAL_CONSOLE = "115200 ttymxc1" | ||
44 | |||
45 | IMAGE_BOOTLOADER = "imx-boot" | ||
46 | |||
47 | BOOT_SPACE = "65536" | ||
48 | |||
49 | LOADADDR = "" | ||
50 | UBOOT_SUFFIX = "bin" | ||
51 | UBOOT_MAKE_TARGET = "" | ||
52 | IMX_BOOT_SEEK = "33" | ||
53 | |||
54 | PREFERRED_RPROVIDER_ptpd = "ptpd" | ||
55 | PREFERRED_RPROVIDER_ptpd-dev = "ptpd" | ||
56 | |||
57 | MACHINE_EXTRA_RDEPENDS += " \ | ||
58 | packagegroup-tools-bluetooth \ | ||
59 | pm-utils \ | ||
60 | kmod \ | ||
61 | hdparm \ | ||
62 | gptfdisk \ | ||
63 | lftp \ | ||
64 | vim \ | ||
65 | ntp \ | ||
66 | boost \ | ||
67 | nodejs \ | ||
68 | networkmanager \ | ||
69 | imx-gpu-viv \ | ||
70 | " | ||
71 | |||
72 | BBMASK_prepend = "fsl-image-mfgtool-initramfs " | ||
73 | |||
74 | # Packages added to all images (including core-image-minimal) | ||
75 | IMAGE_INSTALL_append = " \ | ||
76 | firmware-imx-sdma \ | ||
77 | firmware-imx-epdc \ | ||
78 | fsl-rc-local \ | ||
79 | " | ||
80 | |||
81 | IMAGE_FSTYPES = "tar.bz2" | ||
82 | |||
83 | # Ship all kernel modules by default | ||
84 | MACHINE_EXTRA_RRECOMMENDS = "kernel-modules" | ||
85 | |||
86 | MACHINE_FIRMWARE_append_mx8 = " linux-firmware-ath10k" | ||
87 |
conf/machine/smarcimx8mm4g.conf
File was created | 1 | #@TYPE: Machine | |
2 | #@NAME: EMBEDIAN SMARC-iMX8MM COMPUTER ON MODULES with 4GB LPDDR4 MEMORY | ||
3 | #@SOC: i.MX8MM | ||
4 | #@DESCRIPTION: Machine configuration for Embedian SMARC-iMX8MM | ||
5 | #@MAINTAINER: Eric Lee <eric.lee@embedian.com> | ||
6 | # | ||
7 | # http://www.www.embedian.com | ||
8 | |||
9 | MACHINEOVERRIDES =. "mx8:mx8m:mx8mm:" | ||
10 | require conf/machine/include/imx-base.inc | ||
11 | require conf/machine/include/arm/arch-arm64.inc | ||
12 | |||
13 | MACHINE_FEATURES += " usbgadget vfat ext2 alsa serial pci wifi bluetooth" | ||
14 | |||
15 | IMAGE_FEATURES += "package-management" | ||
16 | |||
17 | # Embedian BSP default providers | ||
18 | PREFERRED_PROVIDER_virtual/kernel_smarcimx8mm4g ?= "linux-smarcimx8mm" | ||
19 | PREFERRED_VERSION_linux-smarcimx8mm4g_smarcimx8mm4g = "4.14.98" | ||
20 | |||
21 | KERNEL_DEVICETREE = " \ | ||
22 | embedian/fsl-smarcimx8mm.dtb \ | ||
23 | " | ||
24 | IMAGE_BOOTFILES_DEPENDS += "imx-m4-demos:do_deploy" | ||
25 | IMAGE_BOOTFILES += "imx8mm_m4_TCM_hello_world.bin imx8mm_m4_TCM_rpmsg_lite_pingpong_rtos_linux_remote.bin imx8mm_m4_TCM_rpmsg_lite_str_echo_rtos.bin" | ||
26 | |||
27 | PREFERRED_PROVIDER_u-boot_smarcimx8mm4g = "u-boot-smarcimx8mm" | ||
28 | PREFERRED_PROVIDER_virtual/bootloader_smarcimx8mm4g = "u-boot-smarcimx8mm" | ||
29 | |||
30 | UBOOT_CONFIG ??= "sd" | ||
31 | UBOOT_CONFIG[sd] = "smarcimx8mm_4g_ser3_defconfig,sdcard" | ||
32 | SPL_BINARY = "spl/u-boot-spl.bin" | ||
33 | |||
34 | # Set DDR FIRMWARE | ||
35 | DDR_FIRMWARE_NAME = "lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_dmem.bin" | ||
36 | |||
37 | # Set U-Boot DTB | ||
38 | UBOOT_DTB_NAME = "fsl-smarcimx8mm.dtb" | ||
39 | |||
40 | # Set imx-mkimage boot target | ||
41 | IMXBOOT_TARGETS = "flash_evk" | ||
42 | |||
43 | SERIAL_CONSOLE = "115200 ttymxc1" | ||
44 | |||
45 | IMAGE_BOOTLOADER = "imx-boot" | ||
46 | |||
47 | BOOT_SPACE = "65536" | ||
48 | |||
49 | LOADADDR = "" | ||
50 | UBOOT_SUFFIX = "bin" | ||
51 | UBOOT_MAKE_TARGET = "" | ||
52 | IMX_BOOT_SEEK = "33" | ||
53 | |||
54 | PREFERRED_RPROVIDER_ptpd = "ptpd" | ||
55 | PREFERRED_RPROVIDER_ptpd-dev = "ptpd" | ||
56 | |||
57 | MACHINE_EXTRA_RDEPENDS += " \ | ||
58 | packagegroup-tools-bluetooth \ | ||
59 | pm-utils \ | ||
60 | kmod \ | ||
61 | hdparm \ | ||
62 | gptfdisk \ | ||
63 | lftp \ | ||
64 | vim \ | ||
65 | ntp \ | ||
66 | boost \ | ||
67 | nodejs \ | ||
68 | networkmanager \ | ||
69 | imx-gpu-viv \ | ||
70 | " | ||
71 | |||
72 | BBMASK_prepend = "fsl-image-mfgtool-initramfs " | ||
73 | |||
74 | # Packages added to all images (including core-image-minimal) | ||
75 | IMAGE_INSTALL_append = " \ | ||
76 | firmware-imx-sdma \ | ||
77 | firmware-imx-epdc \ | ||
78 | fsl-rc-local \ | ||
79 | " | ||
80 | |||
81 | IMAGE_FSTYPES = "tar.bz2" | ||
82 | |||
83 | # Ship all kernel modules by default | ||
84 | MACHINE_EXTRA_RRECOMMENDS = "kernel-modules" | ||
85 | |||
86 | MACHINE_FIRMWARE_append_mx8 = " linux-firmware-ath10k" | ||
87 |
recipes-bsp/imx-atf/imx-atf/imx8mm-atf-uart4.patch
File was created | 1 | diff --git a/plat/imx/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8mm/imx8mm_bl31_setup.c | |
2 | index aa1c336e2..8abb61f5a 100644 | ||
3 | --- a/plat/imx/imx8mm/imx8mm_bl31_setup.c | ||
4 | +++ b/plat/imx/imx8mm/imx8mm_bl31_setup.c | ||
5 | @@ -310,7 +310,8 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, | ||
6 | |||
7 | /* Assign M4 to domain 1 */ | ||
8 | mmio_write_32(IMX_RDC_BASE + 0x204, 0x1); | ||
9 | - mmio_write_32(IMX_RDC_BASE + 0x518, 0xfc); | ||
10 | + /* Assign UART4 to domain 0 */ | ||
11 | + mmio_write_32(IMX_RDC_BASE + 0x518, 0xff); | ||
12 | mmio_write_32(IMX_RDC_BASE + 0x5A4, 0xf3); | ||
13 | |||
14 | #if defined (CSU_RDC_TEST) | ||
15 |
recipes-bsp/imx-atf/imx-atf_2.0.bbappend
File was created | 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | |
2 | |||
3 | SRC_URI += "file://imx8mm-atf-uart4.patch" | ||
4 |
recipes-bsp/imx-mkimage/imx-boot_0.2.bbappend
1 | # Workaround to fix do_compile() failure due to missing fsl-imx8mq-evk.dtb | 1 | # Workaround to fix do_compile() failure due to missing fsl-imx8mm-evk.dtb |
2 | do_compile_prepend() { | 2 | do_compile_prepend() { |
3 | echo "Copying DTB" | 3 | echo "Copying DTB" |
4 | if [ -f ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/fsl-smarcimx8mq.dtb ]; then | 4 | if [ -f ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/fsl-smarcimx8mm.dtb ]; then |
5 | cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/fsl-smarcimx8mq.dtb ${S}/iMX8M/fsl-imx8mq-evk.dtb | 5 | cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/fsl-smarcimx8mm.dtb ${S}/iMX8M/fsl-imx8mm-evk.dtb |
6 | fi | 6 | fi |
7 | } | 7 | } |
8 | 8 |
recipes-bsp/u-boot/u-boot-smarcimx8mm_2018.03.bb
File was created | 1 | # Copyright (C) 2013-2016 Freescale Semiconductor | |
2 | # Copyright 2017-2018 NXP | ||
3 | |||
4 | DESCRIPTION = "i.MX U-Boot suppporting i.MX reference boards." | ||
5 | require recipes-bsp/u-boot/u-boot.inc | ||
6 | inherit pythonnative | ||
7 | |||
8 | PROVIDES += "u-boot" | ||
9 | DEPENDS_append = " python dtc-native" | ||
10 | |||
11 | LICENSE = "GPLv2+" | ||
12 | LIC_FILES_CHKSUM = "file://Licenses/gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263" | ||
13 | |||
14 | UBOOT_SRC ?= "${EMB_UBOOT_MIRROR};protocol=ssh" | ||
15 | SRCBRANCH = "smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga" | ||
16 | SRC_URI = "${UBOOT_SRC};branch=${SRCBRANCH}" | ||
17 | SRCREV = "77f9e189ffd989486d49035ba08c1c76e1e19e8c" | ||
18 | |||
19 | S = "${WORKDIR}/git" | ||
20 | |||
21 | inherit fsl-u-boot-localversion | ||
22 | |||
23 | LOCALVERSION ?= "-${SRCBRANCH}" | ||
24 | |||
25 | BOOT_TOOLS = "imx-boot-tools" | ||
26 | |||
27 | do_deploy_append_mx8m () { | ||
28 | # Deploy the mkimage, u-boot-nodtb.bin and fsl-imx8mq-XX.dtb for mkimage to generate boot binary | ||
29 | if [ -n "${UBOOT_CONFIG}" ] | ||
30 | then | ||
31 | for config in ${UBOOT_MACHINE}; do | ||
32 | i=$(expr $i + 1); | ||
33 | for type in ${UBOOT_CONFIG}; do | ||
34 | j=$(expr $j + 1); | ||
35 | if [ $j -eq $i ] | ||
36 | then | ||
37 | install -d ${DEPLOYDIR}/${BOOT_TOOLS} | ||
38 | install -m 0777 ${B}/${config}/arch/arm/dts/${UBOOT_DTB_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} | ||
39 | install -m 0777 ${B}/${config}/tools/mkimage ${DEPLOYDIR}/${BOOT_TOOLS}/mkimage_uboot | ||
40 | install -m 0777 ${B}/${config}/u-boot-nodtb.bin ${DEPLOYDIR}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${UBOOT_CONFIG} | ||
41 | fi | ||
42 | done | ||
43 | unset j | ||
44 | done | ||
45 | unset i | ||
46 | fi | ||
47 | |||
48 | } | ||
49 | |||
50 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
51 | COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" | ||
52 | |||
53 | UBOOT_NAME_mx6 = "u-boot-${MACHINE}.bin-${UBOOT_CONFIG}" | ||
54 | UBOOT_NAME_mx7 = "u-boot-${MACHINE}.bin-${UBOOT_CONFIG}" | ||
55 | UBOOT_NAME_mx8 = "u-boot-${MACHINE}.bin-${UBOOT_CONFIG}" | ||
56 |
recipes-kernel/linux/linux-smarcimx8mm_4.14.98.bb
File was created | 1 | # Copyright (C) 2013-2016 Freescale Semiconductor | |
2 | # Copyright 2017 NXP | ||
3 | # Copyright 2019-2020 Embedian, Inc. | ||
4 | # Released under the MIT license (see COPYING.MIT for the terms) | ||
5 | |||
6 | SUMMARY = "Linux kernel provided and supported by Embedian" | ||
7 | DESCRIPTION = "Linux kernel provided and supported by Embedian (based on the kernel imx_4.14.98_2.0.0_ga provided by NXP) \ | ||
8 | with focus on i.MX Family SOMs. It includes support for many IPs such as GPU, VPU and IPU." | ||
9 | |||
10 | require recipes-kernel/linux/linux-imx.inc | ||
11 | |||
12 | DEPENDS += "lzop-native bc-native" | ||
13 | |||
14 | DEFAULT_PREFERENCE = "1" | ||
15 | |||
16 | SRCBRANCH = "smarc_8mm_imx_4.14.98_2.0.0_ga" | ||
17 | |||
18 | LOCALVERSION = "-${SRCBRANCH}" | ||
19 | KERNEL_DEFCONFIG = "${S}/arch/arm64/configs/smarcimx8mm_defconfig" | ||
20 | DEFAULT_DTB = "fsl-smarcimx8mm" | ||
21 | |||
22 | KERNEL_SRC ?= "git@git.embedian.com:developer/smarc-fsl-linux-kernel.git;protocol=git" | ||
23 | SRC_URI = "${EMB_KERNEL_MIRROR};protocol=ssh;branch=${SRCBRANCH}" | ||
24 | SRCREV = "3d1e6a796a51ee3e393c458b1b2b908ee7bb6827" | ||
25 | |||
26 | S = "${WORKDIR}/git" | ||
27 | |||
28 | addtask copy_defconfig after do_unpack before do_preconfigure | ||
29 | do_copy_defconfig () { | ||
30 | install -d ${B} | ||
31 | mkdir -p ${B} | ||
32 | cp ${KERNEL_DEFCONFIG} ${B}/.config | ||
33 | cp ${KERNEL_DEFCONFIG} ${B}/../defconfig | ||
34 | } | ||
35 | |||
36 | pkg_postinst_kernel-devicetree_append_mx8 () { | ||
37 | cd $D/boot | ||
38 | ln -s ${DEFAULT_DTB}.dtb ${UBOOT_DTB_NAME} | ||
39 | } | ||
40 | |||
41 | COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" | ||
42 | EXTRA_OEMAKE_append_mx8 = " ARCH=arm64" | ||
43 |
scripts/emb_mk_yocto_sdcard/README.txt
1 | How to use the Embedian SD card creation script: | 1 | How to use the Embedian SD card creation script: |
2 | ================================================= | 2 | ================================================= |
3 | 3 | ||
4 | This utility is provided on an "AS IS" basis. | 4 | This utility is provided on an "AS IS" basis. |
5 | This is the script we use to create our recovery SD card. | 5 | This is the script we use to create our recovery SD card. |
6 | For machines with Android support, it is a part of a larger script we use to create our recovery SD card, which also includes Android. | 6 | For machines with Android support, it is a part of a larger script we use to create our recovery SD card, which also includes Android. |
7 | It is a good example for using the output of the Yocto build to create a bootable SD card, and use it to flash the target NAND flash/eMMC. | 7 | It is a good example for using the output of the Yocto build to create a bootable SD card, and use it to flash the target NAND flash/eMMC. |
8 | 8 | ||
9 | Note: | 9 | Note: |
10 | Before running this script you need to bitbake fsl-image-gui. | 10 | Before running this script you need to bitbake fsl-image-gui. |
11 | 11 | ||
12 | 12 | ||
13 | Usage: | 13 | Usage: |
14 | sudo MACHINE=<smarcimx8m2g|smarcimx8m4g> ./emb-create-yocto-sdcard.sh [options] /dev/sdX | 14 | sudo MACHINE=<smarcimx8mm2g|smarcimx8mn4g> ./emb-create-yocto-sdcard.sh [options] /dev/sdX |
15 | (Change /dev/sdX to your device name) | 15 | (Change /dev/sdX to your device name) |
16 | 16 | ||
17 | options: | 17 | options: |
18 | -h Display help message | 18 | -h Display help message |
19 | -s Only show partition sizes to be written, without actually write them | 19 | -s Only show partition sizes to be written, without actually write them |
20 | -a Automatically set the rootfs partition size to fill the SD card | 20 | -a Automatically set the rootfs partition size to fill the SD card |
21 | -r Select alternative rootfs for recovery images (default: build_x11/tmp/deploy/images/<machine name>/fsl-image-validation-imx.tar.bz2) | 21 | -r Select alternative rootfs for recovery images (default: build_x11/tmp/deploy/images/<machine name>/fsl-image-validation-imx.tar.bz2) |
22 | 22 | ||
23 | If you don't use the '-a' option, a default rootfs size of 3700MiB will be used. | 23 | If you don't use the '-a' option, a default rootfs size of 3700MiB will be used. |
24 | The '-r' option allows you to create a bootable sdcard with an alternative image for the installation to NAND flash or eMMC. | 24 | The '-r' option allows you to create a bootable sdcard with an alternative image for the installation to NAND flash or eMMC. |
25 | Example: "-r tmp/deploy/images/<machine name>/fsl-image-qt5-validation-imx" -- selects the "Qt5 image with X11" recovery image | 25 | Example: "-r tmp/deploy/images/<machine name>/fsl-image-qt5-validation-imx" -- selects the "Qt5 image with X11" recovery image |
26 | 26 | ||
27 | 27 | ||
28 | Once the script is done, use the SD card to boot, and then to flash your internal storage/s either use the icons, | 28 | Once the script is done, use the SD card to boot, and then to flash your internal storage/s either use the icons, |
29 | or the following linux shell script: | 29 | or the following linux shell script: |
30 | install_yocto.sh | 30 | install_yocto.sh |
31 | 31 |
scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh
1 | #!/bin/bash -e | 1 | #!/bin/bash -e |
2 | 2 | ||
3 | blue_underlined_bold_echo() | 3 | blue_underlined_bold_echo() |
4 | { | 4 | { |
5 | echo -e "\e[34m\e[4m\e[1m$@\e[0m" | 5 | echo -e "\e[34m\e[4m\e[1m$@\e[0m" |
6 | } | 6 | } |
7 | 7 | ||
8 | blue_bold_echo() | 8 | blue_bold_echo() |
9 | { | 9 | { |
10 | echo -e "\e[34m\e[1m$@\e[0m" | 10 | echo -e "\e[34m\e[1m$@\e[0m" |
11 | } | 11 | } |
12 | 12 | ||
13 | red_bold_echo() | 13 | red_bold_echo() |
14 | { | 14 | { |
15 | echo -e "\e[31m\e[1m$@\e[0m" | 15 | echo -e "\e[31m\e[1m$@\e[0m" |
16 | } | 16 | } |
17 | 17 | ||
18 | IMGS_PATH=/opt/images/Yocto | 18 | IMGS_PATH=/opt/images/Yocto |
19 | UBOOT_IMAGE=imx-boot-sd.bin | 19 | UBOOT_IMAGE=imx-boot-sd.bin |
20 | KERNEL_IMAGE=Image | 20 | KERNEL_IMAGE=Image |
21 | ROOTFS_IMAGE=rootfs.tar.bz2 | 21 | ROOTFS_IMAGE=rootfs.tar.bz2 |
22 | BOOTLOADER_RESERVED_SIZE=2 | 22 | BOOTLOADER_RESERVED_SIZE=2 |
23 | PART1_SIZE=48 | 23 | PART1_SIZE=48 |
24 | BOOTLOADER_OFFSET=33 | 24 | BOOTLOADER_OFFSET=33 |
25 | DISPLAY=-hdmi | ||
26 | PART=p | 25 | PART=p |
27 | BOOTPART=1 | 26 | BOOTPART=1 |
28 | ROOTFSPART=2 | 27 | ROOTFSPART=2 |
29 | BOOTDIR=/boot | 28 | BOOTDIR=/boot |
30 | 29 | ||
31 | check_board() | 30 | check_board() |
32 | { | 31 | { |
33 | if grep -q "i.MX8M" /sys/devices/soc0/soc_id; then | 32 | if grep -q "i.MX8M" /sys/devices/soc0/soc_id; then |
34 | BOARD=smarc-imx8m | 33 | BOARD=smarc-imx8mm |
35 | DTB_PREFIX=fsl-smarcimx8mq | 34 | DTB_PREFIX=fsl-smarcimx8mm |
36 | BLOCK=mmcblk0 | 35 | BLOCK=mmcblk0 |
37 | |||
38 | if [[ $DISPLAY != "-lvds" && $DISPLAY != "-hdmi" && \ | ||
39 | $DISPLAY != "-dual-display" && $DISPLAY != "" ]]; then | ||
40 | red_bold_echo "ERROR: invalid display, should be lvds, hdmi, dual-display or empty" | ||
41 | exit 1 | ||
42 | fi | ||
43 | else | ||
44 | red_bold_echo "ERROR: Unsupported board" | ||
45 | exit 1 | ||
46 | fi | 36 | fi |
47 | 37 | ||
48 | 38 | ||
49 | if [[ ! -b /dev/${BLOCK} ]] ; then | 39 | if [[ ! -b /dev/${BLOCK} ]] ; then |
50 | red_bold_echo "ERROR: Can't find eMMC device (/dev/${BLOCK})." | 40 | red_bold_echo "ERROR: Can't find eMMC device (/dev/${BLOCK})." |
51 | red_bold_echo "Please verify you are using the correct options for your SMARC Module." | 41 | red_bold_echo "Please verify you are using the correct options for your SMARC Module." |
52 | exit 1 | 42 | exit 1 |
53 | fi | 43 | fi |
54 | } | 44 | } |
55 | 45 | ||
56 | check_images() | 46 | check_images() |
57 | { | 47 | { |
58 | if [[ ! -f $IMGS_PATH/$UBOOT_IMAGE ]] ; then | 48 | if [[ ! -f $IMGS_PATH/$UBOOT_IMAGE ]] ; then |
59 | red_bold_echo "ERROR: \"$IMGS_PATH/$UBOOT_IMAGE\" does not exist" | 49 | red_bold_echo "ERROR: \"$IMGS_PATH/$UBOOT_IMAGE\" does not exist" |
60 | exit 1 | 50 | exit 1 |
61 | fi | 51 | fi |
62 | 52 | ||
63 | if [[ ! -f $IMGS_PATH/$KERNEL_IMAGE ]] ; then | 53 | if [[ ! -f $IMGS_PATH/$KERNEL_IMAGE ]] ; then |
64 | red_bold_echo "ERROR: \"$IMGS_PATH/$KERNEL_IMAGE\" does not exist" | 54 | red_bold_echo "ERROR: \"$IMGS_PATH/$KERNEL_IMAGE\" does not exist" |
65 | exit 1 | 55 | exit 1 |
66 | fi | 56 | fi |
67 | 57 | ||
68 | if [[ ! -f $IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb ]] ; then | 58 | if [[ ! -f $IMGS_PATH/${DTB_PREFIX}.dtb ]] ; then |
69 | red_bold_echo "ERROR: \"$IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb\" does not exist" | 59 | red_bold_echo "ERROR: \"$IMGS_PATH/${DTB_PREFIX}.dtb\" does not exist" |
70 | exit 1 | 60 | exit 1 |
71 | fi | 61 | fi |
72 | 62 | ||
73 | if [[ ! -f $IMGS_PATH/uEnv.txt ]] ; then | 63 | if [[ ! -f $IMGS_PATH/uEnv.txt ]] ; then |
74 | red_bold_echo "ERROR: \"$IMGS_PATH/uEnv.txt\" does not exist" | 64 | red_bold_echo "ERROR: \"$IMGS_PATH/uEnv.txt\" does not exist" |
75 | exit 1 | 65 | exit 1 |
76 | fi | 66 | fi |
77 | 67 | ||
78 | if [[ ! -f $IMGS_PATH/$ROOTFS_IMAGE ]] ; then | 68 | if [[ ! -f $IMGS_PATH/$ROOTFS_IMAGE ]] ; then |
79 | red_bold_echo "ERROR: \"$IMGS_PATH/$ROOTFS_IMAGE\" does not exist" | 69 | red_bold_echo "ERROR: \"$IMGS_PATH/$ROOTFS_IMAGE\" does not exist" |
80 | exit 1 | 70 | exit 1 |
81 | fi | 71 | fi |
82 | } | 72 | } |
83 | 73 | ||
84 | delete_emmc() | 74 | delete_emmc() |
85 | { | 75 | { |
86 | echo | 76 | echo |
87 | blue_underlined_bold_echo "Deleting current partitions" | 77 | blue_underlined_bold_echo "Deleting current partitions" |
88 | 78 | ||
89 | umount /dev/${BLOCK}${PART}* 2>/dev/null || true | 79 | umount /dev/${BLOCK}${PART}* 2>/dev/null || true |
90 | 80 | ||
91 | for ((i=1; i<=16; i++)); do | 81 | for ((i=1; i<=16; i++)); do |
92 | if [[ -e /dev/${BLOCK}${PART}${i} ]]; then | 82 | if [[ -e /dev/${BLOCK}${PART}${i} ]]; then |
93 | dd if=/dev/zero of=/dev/${BLOCK}${PART}${i} bs=1M count=1 2>/dev/null || true | 83 | dd if=/dev/zero of=/dev/${BLOCK}${PART}${i} bs=1M count=1 2>/dev/null || true |
94 | fi | 84 | fi |
95 | done | 85 | done |
96 | sync | 86 | sync |
97 | 87 | ||
98 | dd if=/dev/zero of=/dev/${BLOCK} bs=1M count=${BOOTLOADER_RESERVED_SIZE} | 88 | dd if=/dev/zero of=/dev/${BLOCK} bs=1M count=${BOOTLOADER_RESERVED_SIZE} |
99 | 89 | ||
100 | sync; sleep 1 | 90 | sync; sleep 1 |
101 | } | 91 | } |
102 | 92 | ||
103 | create_emmc_parts() | 93 | create_emmc_parts() |
104 | { | 94 | { |
105 | echo | 95 | echo |
106 | blue_underlined_bold_echo "Creating new partitions" | 96 | blue_underlined_bold_echo "Creating new partitions" |
107 | 97 | ||
108 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/hw_sector_size` | 98 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/hw_sector_size` |
109 | PART1_FIRST_SECT=$(($BOOTLOADER_RESERVED_SIZE * 1024 * 1024 / $SECT_SIZE_BYTES)) | 99 | PART1_FIRST_SECT=$(($BOOTLOADER_RESERVED_SIZE * 1024 * 1024 / $SECT_SIZE_BYTES)) |
110 | PART1_END_SECT=$((($BOOTLOADER_RESERVED_SIZE + $PART1_SIZE) * 1024 * 1024 / $SECT_SIZE_BYTES)) | 100 | PART1_END_SECT=$((($BOOTLOADER_RESERVED_SIZE + $PART1_SIZE) * 1024 * 1024 / $SECT_SIZE_BYTES)) |
111 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1` | 101 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1` |
112 | 102 | ||
113 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ | 103 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ |
114 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ | 104 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ |
115 | echo $PART2_FIRST_SECT; echo; \ | 105 | echo $PART2_FIRST_SECT; echo; \ |
116 | echo p; echo w) | fdisk -u /dev/${BLOCK} > /dev/null | 106 | echo p; echo w) | fdisk -u /dev/${BLOCK} > /dev/null |
117 | 107 | ||
118 | sync; sleep 1 | 108 | sync; sleep 1 |
119 | fdisk -u -l /dev/${BLOCK} | 109 | fdisk -u -l /dev/${BLOCK} |
120 | } | 110 | } |
121 | 111 | ||
122 | format_emmc_parts() | 112 | format_emmc_parts() |
123 | { | 113 | { |
124 | echo | 114 | echo |
125 | blue_underlined_bold_echo "Formatting partitions" | 115 | blue_underlined_bold_echo "Formatting partitions" |
126 | 116 | ||
127 | mkfs.vfat -F 16 /dev/${BLOCK}${PART}${BOOTPART} -n boot | 117 | mkfs.vfat -F 16 /dev/${BLOCK}${PART}${BOOTPART} -n boot |
128 | mkfs.ext4 /dev/${BLOCK}${PART}${ROOTFSPART} -L rootfs | 118 | mkfs.ext4 /dev/${BLOCK}${PART}${ROOTFSPART} -L rootfs |
129 | 119 | ||
130 | sync; sleep 1 | 120 | sync; sleep 1 |
131 | } | 121 | } |
132 | 122 | ||
133 | install_bootloader_to_emmc() | 123 | install_bootloader_to_emmc() |
134 | { | 124 | { |
135 | echo | 125 | echo |
136 | blue_underlined_bold_echo "Installing booloader" | 126 | blue_underlined_bold_echo "Installing booloader" |
137 | 127 | ||
138 | dd if=${IMGS_PATH}/${UBOOT_IMAGE} of=/dev/${BLOCK} bs=1K seek=${BOOTLOADER_OFFSET} | 128 | dd if=${IMGS_PATH}/${UBOOT_IMAGE} of=/dev/${BLOCK} bs=1K seek=${BOOTLOADER_OFFSET} |
139 | sync | 129 | sync |
140 | } | 130 | } |
141 | 131 | ||
142 | install_kernel_to_emmc() | 132 | install_kernel_to_emmc() |
143 | { | 133 | { |
144 | echo | 134 | echo |
145 | blue_underlined_bold_echo "Installing kernel" | 135 | blue_underlined_bold_echo "Installing kernel" |
146 | 136 | ||
147 | MOUNTDIR=/run/media/${BLOCK}${PART}${BOOTPART} | 137 | MOUNTDIR=/run/media/${BLOCK}${PART}${BOOTPART} |
148 | mkdir -p ${MOUNTDIR} | 138 | mkdir -p ${MOUNTDIR} |
149 | mount /dev/${BLOCK}${PART}${BOOTPART} ${MOUNTDIR} | 139 | mount /dev/${BLOCK}${PART}${BOOTPART} ${MOUNTDIR} |
150 | mkdir -p ${MOUNTDIR}/dtbs/ | 140 | mkdir -p ${MOUNTDIR}/dtbs/ |
151 | cp -v ${IMGS_PATH}/${KERNEL_IMAGE} ${MOUNTDIR} | 141 | cp -v ${IMGS_PATH}/${KERNEL_IMAGE} ${MOUNTDIR} |
152 | cp -v ${IMGS_PATH}/${DTB_PREFIX}${DISPLAY}.dtb ${MOUNTDIR}/dtbs/fsl-smarcimx8mq.dtb | 142 | cp -v ${IMGS_PATH}/${DTB_PREFIX}.dtb ${MOUNTDIR}/dtbs/fsl-smarcimx8mm.dtb |
153 | cp -v ${IMGS_PATH}/uEnv.txt ${MOUNTDIR} | 143 | cp -v ${IMGS_PATH}/uEnv.txt ${MOUNTDIR} |
154 | 144 | ||
155 | echo | 145 | echo |
156 | sync | 146 | sync |
157 | 147 | ||
158 | umount ${MOUNTDIR} | 148 | umount ${MOUNTDIR} |
159 | } | 149 | } |
160 | 150 | ||
161 | install_rootfs_to_emmc() | 151 | install_rootfs_to_emmc() |
162 | { | 152 | { |
163 | echo | 153 | echo |
164 | blue_underlined_bold_echo "Installing rootfs" | 154 | blue_underlined_bold_echo "Installing rootfs" |
165 | 155 | ||
166 | MOUNTDIR=/run/media/${BLOCK}${PART}${ROOTFSPART} | 156 | MOUNTDIR=/run/media/${BLOCK}${PART}${ROOTFSPART} |
167 | mkdir -p ${MOUNTDIR} | 157 | mkdir -p ${MOUNTDIR} |
168 | mount /dev/${BLOCK}${PART}${ROOTFSPART} ${MOUNTDIR} | 158 | mount /dev/${BLOCK}${PART}${ROOTFSPART} ${MOUNTDIR} |
169 | 159 | ||
170 | printf "Extracting files" | 160 | printf "Extracting files" |
171 | tar --warning=no-timestamp -jxvf ${IMGS_PATH}/${ROOTFS_IMAGE} -C ${MOUNTDIR} --checkpoint=.1200 | 161 | tar --warning=no-timestamp -jxvf ${IMGS_PATH}/${ROOTFS_IMAGE} -C ${MOUNTDIR} --checkpoint=.1200 |
172 | 162 | ||
173 | # Create DTB symlink | 163 | # Create DTB symlink |
174 | (cd ${MOUNTDIR}/${BOOTDIR}; ln -fs ${DTB_PREFIX}${DISPLAY}.dtb ${DTB_PREFIX}.dtb) | 164 | (cd ${MOUNTDIR}/${BOOTDIR}; ln -fs ${DTB_PREFIX}.dtb ${DTB_PREFIX}.dtb) |
175 | 165 | ||
176 | echo | 166 | echo |
177 | sync | 167 | sync |
178 | 168 | ||
179 | umount ${MOUNTDIR} | 169 | umount ${MOUNTDIR} |
180 | } | 170 | } |
181 | 171 | ||
182 | stop_udev() | 172 | stop_udev() |
183 | { | 173 | { |
184 | if [ -f /lib/systemd/system/systemd-udevd.service ]; then | 174 | if [ -f /lib/systemd/system/systemd-udevd.service ]; then |
185 | systemctl -q mask --runtime systemd-udevd | 175 | systemctl -q mask --runtime systemd-udevd |
186 | systemctl -q stop systemd-udevd | 176 | systemctl -q stop systemd-udevd |
187 | fi | 177 | fi |
188 | } | 178 | } |
189 | 179 | ||
190 | start_udev() | 180 | start_udev() |
191 | { | 181 | { |
192 | if [ -f /lib/systemd/system/systemd-udevd.service ]; then | 182 | if [ -f /lib/systemd/system/systemd-udevd.service ]; then |
193 | systemctl -q unmask --runtime systemd-udevd | 183 | systemctl -q unmask --runtime systemd-udevd |
194 | systemctl -q start systemd-udevd | 184 | systemctl -q start systemd-udevd |
195 | fi | 185 | fi |
196 | } | 186 | } |
197 | 187 | ||
198 | usage() | 188 | usage() |
199 | { | 189 | { |
200 | echo | 190 | echo |
201 | echo "This script installs Yocto Rootfs on the SMARC-iMX8M's internal eMMC storage device" | 191 | echo "This script installs Yocto Rootfs on the SMARC-iMX8M's internal eMMC storage device" |
202 | echo | 192 | echo |
203 | echo " Usage: $(basename $0) <option>" | 193 | echo " Usage: $(basename $0) <option>" |
204 | echo | 194 | echo |
205 | echo " options:" | 195 | echo " options:" |
206 | echo " -h show help message" | 196 | echo " -h show help message" |
207 | echo " -d <lvds|hdmi|dual-display> set display type, default is lvds" | 197 | echo " -d <lvds|hdmi|dual-display> set display type, default is lvds" |
208 | echo | 198 | echo |
209 | } | 199 | } |
210 | 200 | ||
211 | finish() | 201 | finish() |
212 | { | 202 | { |
213 | echo | 203 | echo |
214 | blue_bold_echo "Yocto Sumo installed successfully" | 204 | blue_bold_echo "Yocto Sumo installed successfully" |
215 | exit 0 | 205 | exit 0 |
216 | } | 206 | } |
217 | 207 | ||
218 | ################################################# | 208 | ################################################# |
219 | # Execution starts here # | 209 | # Execution starts here # |
220 | ################################################# | 210 | ################################################# |
221 | 211 | ||
222 | if [[ $EUID != 0 ]] ; then | 212 | if [[ $EUID != 0 ]] ; then |
223 | red_bold_echo "This script must be run with super-user privileges" | 213 | red_bold_echo "This script must be run with super-user privileges" |
224 | exit 1 | 214 | exit 1 |
225 | fi | 215 | fi |
226 | 216 | ||
227 | blue_underlined_bold_echo "*** Embedian SMARC-iMX8M on-module eMMC Recovery ***" | 217 | blue_underlined_bold_echo "*** Embedian SMARC-iMX8M on-module eMMC Recovery ***" |
228 | echo | 218 | echo |
229 | 219 | ||
230 | while getopts d:h OPTION; | 220 | while getopts d:h OPTION; |
231 | do | 221 | do |
232 | case $OPTION in | 222 | case $OPTION in |
233 | d) | 223 | d) |
234 | DISPLAY=$OPTARG | 224 | DISPLAY=$OPTARG |
235 | ;; | 225 | ;; |
236 | h) | 226 | h) |
237 | usage | 227 | usage |
238 | exit 0 | 228 | exit 0 |
239 | ;; | 229 | ;; |
240 | *) | 230 | *) |
241 | usage | 231 | usage |
242 | exit 1 | 232 | exit 1 |
243 | ;; | 233 | ;; |
244 | esac | 234 | esac |
245 | done | 235 | done |
246 | 236 | ||
247 | printf "Board: " | 237 | printf "Board: " |
248 | blue_bold_echo $BOARD | 238 | blue_bold_echo $BOARD |
249 | 239 | ||
250 | printf "Installing to internal storage device: " | 240 | printf "Installing to internal storage device: " |
251 | blue_bold_echo eMMC | 241 | blue_bold_echo eMMC |
252 | 242 | ||
253 | check_board | 243 | check_board |
254 | check_images | 244 | check_images |
255 | stop_udev | 245 | stop_udev |
256 | delete_emmc | 246 | delete_emmc |
257 | create_emmc_parts | 247 | create_emmc_parts |
258 | format_emmc_parts | 248 | format_emmc_parts |
259 | install_bootloader_to_emmc | 249 | install_bootloader_to_emmc |
260 | install_kernel_to_emmc | 250 | install_kernel_to_emmc |
261 | install_rootfs_to_emmc | 251 | install_rootfs_to_emmc |
262 | start_udev | 252 | start_udev |
263 | finish | 253 | finish |
264 | 254 |
scripts/emb_mk_yocto_sdcard/emb-create-yocto-sdcard.sh
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | set -e | 2 | set -e |
3 | 3 | ||
4 | #### Script version #### | 4 | #### Script version #### |
5 | SCRIPT_NAME=${0##*/} | 5 | SCRIPT_NAME=${0##*/} |
6 | readonly SCRIPT_VERSION="0.7" | 6 | readonly SCRIPT_VERSION="0.7" |
7 | 7 | ||
8 | #### Exports Variables #### | 8 | #### Exports Variables #### |
9 | #### global variables #### | 9 | #### global variables #### |
10 | readonly ABSOLUTE_FILENAME=`readlink -e "$0"` | 10 | readonly ABSOLUTE_FILENAME=`readlink -e "$0"` |
11 | readonly ABSOLUTE_DIRECTORY=`dirname ${ABSOLUTE_FILENAME}` | 11 | readonly ABSOLUTE_DIRECTORY=`dirname ${ABSOLUTE_FILENAME}` |
12 | readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY} | 12 | readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY} |
13 | readonly SCRIPT_START_DATE=`date +%Y%m%d` | 13 | readonly SCRIPT_START_DATE=`date +%Y%m%d` |
14 | 14 | ||
15 | readonly YOCTO_ROOT="${SCRIPT_POINT}/../../../../" | 15 | readonly YOCTO_ROOT="${SCRIPT_POINT}/../../../../" |
16 | 16 | ||
17 | readonly BSP_TYPE="YOCTO" | 17 | readonly BSP_TYPE="YOCTO" |
18 | readonly YOCTO_BUILD=${YOCTO_ROOT}/imx8m-build-qt5wayland | 18 | readonly YOCTO_BUILD=${YOCTO_ROOT}/imx8mm-build-qt5wayland |
19 | readonly YOCTO_DEFAULT_IMAGE=fsl-image-qt5-validation-imx | 19 | readonly YOCTO_DEFAULT_IMAGE=fsl-image-qt5-validation-imx |
20 | 20 | ||
21 | readonly YOCTO_SCRIPTS_PATH=${SCRIPT_POINT} | 21 | readonly YOCTO_SCRIPTS_PATH=${SCRIPT_POINT} |
22 | readonly YOCTO_IMGS_PATH=${YOCTO_BUILD}/tmp/deploy/images/${MACHINE} | 22 | readonly YOCTO_IMGS_PATH=${YOCTO_BUILD}/tmp/deploy/images/${MACHINE} |
23 | 23 | ||
24 | ## display (one of "-hdmi", "-lcdif-lvds", "-dp", "-dcss-lvds", "-dual-display", "-edp") | ||
25 | readonly DISPLAY="-hdmi" | ||
26 | |||
27 | # $1 -- block device | 24 | # $1 -- block device |
28 | # $2 -- output images dir | 25 | # $2 -- output images dir |
29 | readonly LPARAM_BLOCK_DEVICE=${1} | 26 | readonly LPARAM_BLOCK_DEVICE=${1} |
30 | readonly LPARAM_OUTPUT_DIR=${2} | 27 | readonly LPARAM_OUTPUT_DIR=${2} |
31 | readonly P1_MOUNT_DIR="${G_TMP_DIR}/p1" | 28 | readonly P1_MOUNT_DIR="${G_TMP_DIR}/p1" |
32 | readonly P2_MOUNT_DIR="${G_TMP_DIR}/p2" | 29 | readonly P2_MOUNT_DIR="${G_TMP_DIR}/p2" |
33 | 30 | ||
34 | readonly BOOTLOAD_RESERVE_SIZE=2 | 31 | readonly BOOTLOAD_RESERVE_SIZE=2 |
35 | readonly PART1_SIZE=48 | 32 | readonly PART1_SIZE=48 |
36 | readonly BOOTPART=1 | 33 | readonly BOOTPART=1 |
37 | readonly ROOTFSPART=2 | 34 | readonly ROOTFSPART=2 |
38 | readonly SPARE_SIZE=4 | 35 | readonly SPARE_SIZE=4 |
39 | 36 | ||
40 | # Sizes are in MiB | 37 | # Sizes are in MiB |
41 | BOOTLOADER_OFFSET=33 | 38 | BOOTLOADER_OFFSET=33 |
42 | 39 | ||
43 | AUTO_FILL_SD=0 | 40 | AUTO_FILL_SD=0 |
44 | LOOP_MAJOR=7 | 41 | LOOP_MAJOR=7 |
45 | 42 | ||
46 | # This function performs sanity check to verify that the target device is removable devise of proper size | 43 | # This function performs sanity check to verify that the target device is removable devise of proper size |
47 | function check_device() | 44 | function check_device() |
48 | { | 45 | { |
49 | # Check that parameter is a valid block device | 46 | # Check that parameter is a valid block device |
50 | if [ ! -b "$1" ]; then | 47 | if [ ! -b "$1" ]; then |
51 | echo "$1 is not a valid block device, exiting" | 48 | echo "$1 is not a valid block device, exiting" |
52 | exit 1 | 49 | exit 1 |
53 | fi | 50 | fi |
54 | 51 | ||
55 | local dev=$(basename $1) | 52 | local dev=$(basename $1) |
56 | 53 | ||
57 | # Check that /sys/block/$dev exists | 54 | # Check that /sys/block/$dev exists |
58 | if [ ! -d /sys/block/$dev ]; then | 55 | if [ ! -d /sys/block/$dev ]; then |
59 | echo "Directory /sys/block/${dev} missing, exiting" | 56 | echo "Directory /sys/block/${dev} missing, exiting" |
60 | exit 1 | 57 | exit 1 |
61 | fi | 58 | fi |
62 | 59 | ||
63 | # Get device parameters | 60 | # Get device parameters |
64 | local removable=$(cat /sys/block/${dev}/removable) | 61 | local removable=$(cat /sys/block/${dev}/removable) |
65 | local size_bytes=$((512*$(cat /sys/class/block/${dev}/size))) | 62 | local size_bytes=$((512*$(cat /sys/class/block/${dev}/size))) |
66 | local size_gb=$((size_bytes/1000000000)) | 63 | local size_gb=$((size_bytes/1000000000)) |
67 | 64 | ||
68 | # Non-removable SD card readers require additional check | 65 | # Non-removable SD card readers require additional check |
69 | if [ "${removable}" != "1" ]; then | 66 | if [ "${removable}" != "1" ]; then |
70 | local drive=$(udisksctl info -b /dev/${dev}|grep "Drive:"|cut -d"'" -f 2) | 67 | local drive=$(udisksctl info -b /dev/${dev}|grep "Drive:"|cut -d"'" -f 2) |
71 | local mediaremovable=$(gdbus call --system --dest org.freedesktop.UDisks2 \ | 68 | local mediaremovable=$(gdbus call --system --dest org.freedesktop.UDisks2 \ |
72 | --object-path ${drive} --method org.freedesktop.DBus.Properties.Get \ | 69 | --object-path ${drive} --method org.freedesktop.DBus.Properties.Get \ |
73 | org.freedesktop.UDisks2.Drive MediaRemovable) | 70 | org.freedesktop.UDisks2.Drive MediaRemovable) |
74 | if [[ "${mediaremovable}" = *"true"* ]]; then | 71 | if [[ "${mediaremovable}" = *"true"* ]]; then |
75 | removable=1 | 72 | removable=1 |
76 | fi | 73 | fi |
77 | fi | 74 | fi |
78 | 75 | ||
79 | # Check that device is either removable or loop | 76 | # Check that device is either removable or loop |
80 | if [ "$removable" != "1" -a $(stat -c '%t' /dev/$dev) != ${LOOP_MAJOR} ]; then | 77 | if [ "$removable" != "1" -a $(stat -c '%t' /dev/$dev) != ${LOOP_MAJOR} ]; then |
81 | echo "$1 is not a removable device, exiting" | 78 | echo "$1 is not a removable device, exiting" |
82 | exit 1 | 79 | exit 1 |
83 | fi | 80 | fi |
84 | 81 | ||
85 | # Check that device is attached | 82 | # Check that device is attached |
86 | if [ ${size_bytes} -eq 0 ]; then | 83 | if [ ${size_bytes} -eq 0 ]; then |
87 | echo "$1 is not attached, exiting" | 84 | echo "$1 is not attached, exiting" |
88 | exit 1 | 85 | exit 1 |
89 | fi | 86 | fi |
90 | 87 | ||
91 | # Check that device has a valid size | 88 | # Check that device has a valid size |
92 | echo "Detected removable device $1, size=${size_gb}GB" | 89 | echo "Detected removable device $1, size=${size_gb}GB" |
93 | } | 90 | } |
94 | 91 | ||
95 | YOCTO_RECOVERY_ROOTFS_PATH=${YOCTO_IMGS_PATH} | 92 | YOCTO_RECOVERY_ROOTFS_PATH=${YOCTO_IMGS_PATH} |
96 | 93 | ||
97 | echo "================================================" | 94 | echo "================================================" |
98 | echo "= Embedian recovery SD card creation script =" | 95 | echo "= Embedian recovery SD card creation script =" |
99 | echo "================================================" | 96 | echo "================================================" |
100 | 97 | ||
101 | help() { | 98 | help() { |
102 | bn=`basename $0` | 99 | bn=`basename $0` |
103 | echo " Usage: MACHINE=<smarcimx8m2g|smarcimx8m4g> $bn <options> device_node" | 100 | echo " Usage: MACHINE=<smarcimx8mm2g|smarcimx8mm4g> $bn <options> device_node" |
104 | echo | 101 | echo |
105 | echo " options:" | 102 | echo " options:" |
106 | echo " -h display this Help message" | 103 | echo " -h display this Help message" |
107 | echo " -s only Show partition sizes to be written, without actually write them" | 104 | echo " -s only Show partition sizes to be written, without actually write them" |
108 | echo " -a Automatically set the rootfs partition size to fill the SD card (leaving spare ${SPARE_SIZE}MiB)" | 105 | echo " -a Automatically set the rootfs partition size to fill the SD card (leaving spare ${SPARE_SIZE}MiB)" |
109 | echo " -r ROOTFS_NAME select an alternative Rootfs for recovery images" | 106 | echo " -r ROOTFS_NAME select an alternative Rootfs for recovery images" |
110 | echo " (default: \"${YOCTO_RECOVERY_ROOTFS_PATH}/${YOCTO_DEFAULT_IMAGE}\")" | 107 | echo " (default: \"${YOCTO_RECOVERY_ROOTFS_PATH}/${YOCTO_DEFAULT_IMAGE}\")" |
111 | echo " -n TEXT_FILE add a release Notes text file" | 108 | echo " -n TEXT_FILE add a release Notes text file" |
112 | echo | 109 | echo |
113 | } | 110 | } |
114 | 111 | ||
115 | if [[ $EUID -ne 0 ]] ; then | 112 | if [[ $EUID -ne 0 ]] ; then |
116 | echo "This script must be run with super-user privileges" | 113 | echo "This script must be run with super-user privileges" |
117 | exit 1 | 114 | exit 1 |
118 | fi | 115 | fi |
119 | 116 | ||
120 | if [[ $MACHINE != "smarcimx8m2g" && $MACHINE != "smarcimx8m4g" ]] ; then | 117 | if [[ $MACHINE != "smarcimx8mm2g" && $MACHINE != "smarcimx8mm4g" ]] ; then |
121 | help | 118 | help |
122 | exit 1 | 119 | exit 1 |
123 | fi | 120 | fi |
124 | 121 | ||
125 | 122 | ||
126 | # Parse command line | 123 | # Parse command line |
127 | moreoptions=1 | 124 | moreoptions=1 |
128 | node="na" | 125 | node="na" |
129 | cal_only=0 | 126 | cal_only=0 |
130 | 127 | ||
131 | while [ "$moreoptions" = 1 -a $# -gt 0 ]; do | 128 | while [ "$moreoptions" = 1 -a $# -gt 0 ]; do |
132 | case $1 in | 129 | case $1 in |
133 | -h) help; exit 3 ;; | 130 | -h) help; exit 3 ;; |
134 | -s) cal_only=1 ;; | 131 | -s) cal_only=1 ;; |
135 | -a) AUTO_FILL_SD=1 ;; | 132 | -a) AUTO_FILL_SD=1 ;; |
136 | -r) shift; | 133 | -r) shift; |
137 | YOCTO_RECOVERY_ROOTFS_MASK_PATH=`readlink -e "${1}.tar.bz2"`; | 134 | YOCTO_RECOVERY_ROOTFS_MASK_PATH=`readlink -e "${1}.tar.bz2"`; |
138 | YOCTO_RECOVERY_ROOTFS_PATH=`dirname ${YOCTO_RECOVERY_ROOTFS_MASK_PATH}` | 135 | YOCTO_RECOVERY_ROOTFS_PATH=`dirname ${YOCTO_RECOVERY_ROOTFS_MASK_PATH}` |
139 | YOCTO_RECOVERY_ROOTFS_BASE_IN_NAME=`basename ${1}` | 136 | YOCTO_RECOVERY_ROOTFS_BASE_IN_NAME=`basename ${1}` |
140 | ;; | 137 | ;; |
141 | -n) shift; | 138 | -n) shift; |
142 | RELEASE_NOTES_FILE=${1} | 139 | RELEASE_NOTES_FILE=${1} |
143 | ;; | 140 | ;; |
144 | *) moreoptions=0;; | 141 | *) moreoptions=0;; |
145 | esac | 142 | esac |
146 | [ "$moreoptions" = 0 ] && [ $# -gt 1 ] && help && exit 1 | 143 | [ "$moreoptions" = 0 ] && [ $# -gt 1 ] && help && exit 1 |
147 | [ "$moreoptions" = 1 ] && shift | 144 | [ "$moreoptions" = 1 ] && shift |
148 | done | 145 | done |
149 | 146 | ||
150 | part="" | 147 | part="" |
151 | if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then | 148 | if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then |
152 | part="p" | 149 | part="p" |
153 | fi | 150 | fi |
154 | 151 | ||
155 | # allow only removable/loopback devices, to protect host PC | 152 | # allow only removable/loopback devices, to protect host PC |
156 | echo "MACHINE=${MACHINE}" | 153 | echo "MACHINE=${MACHINE}" |
157 | echo "SD card rootfs: ${YOCTO_DEFAULT_IMAGE}" | 154 | echo "SD card rootfs: ${YOCTO_DEFAULT_IMAGE}" |
158 | echo "Recovery rootfs: ${YOCTO_DEFAULT_IMAGE}" | 155 | echo "Recovery rootfs: ${YOCTO_DEFAULT_IMAGE}" |
159 | echo "================================================" | 156 | echo "================================================" |
160 | check_device ${LPARAM_BLOCK_DEVICE} | 157 | check_device ${LPARAM_BLOCK_DEVICE} |
161 | echo "================================================" | 158 | echo "================================================" |
162 | read -p "Press Enter to continue" | 159 | read -p "Press Enter to continue" |
163 | 160 | ||
164 | function delete_device | 161 | function delete_device |
165 | { | 162 | { |
166 | echo | 163 | echo |
167 | echo "Deleting current partitions" | 164 | echo "Deleting current partitions" |
168 | for ((i=0; i<10; i++)) | 165 | for ((i=0; i<10; i++)) |
169 | do | 166 | do |
170 | if [ `ls ${LPARAM_BLOCK_DEVICE}${part}$i 2> /dev/null | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then | 167 | if [ `ls ${LPARAM_BLOCK_DEVICE}${part}$i 2> /dev/null | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then |
171 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 | 168 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 |
172 | fi | 169 | fi |
173 | done | 170 | done |
174 | sync | 171 | sync |
175 | 172 | ||
176 | ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true | 173 | ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true |
177 | sync | 174 | sync |
178 | 175 | ||
179 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1M count=${BOOTLOAD_RESERVE_SIZE} | 176 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1M count=${BOOTLOAD_RESERVE_SIZE} |
180 | sync; sleep 1 | 177 | sync; sleep 1 |
181 | } | 178 | } |
182 | 179 | ||
183 | function ceildiv | 180 | function ceildiv |
184 | { | 181 | { |
185 | local num=$1 | 182 | local num=$1 |
186 | local div=$2 | 183 | local div=$2 |
187 | echo $(( (num + div - 1) / div )) | 184 | echo $(( (num + div - 1) / div )) |
188 | } | 185 | } |
189 | 186 | ||
190 | function create_parts | 187 | function create_parts |
191 | { | 188 | { |
192 | echo | 189 | echo |
193 | echo "Creating new partitions" | 190 | echo "Creating new partitions" |
194 | # Get total card size | 191 | # Get total card size |
195 | TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}` | 192 | TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}` |
196 | TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024` | 193 | TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024` |
197 | ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}` | 194 | ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}` |
198 | 195 | ||
199 | echo "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}" | 196 | echo "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}" |
200 | 197 | ||
201 | BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3` | 198 | BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3` |
202 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size` | 199 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size` |
203 | 200 | ||
204 | BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024)) | 201 | BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024)) |
205 | PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024)) | 202 | PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024)) |
206 | PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}` | 203 | PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}` |
207 | ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024)) | 204 | ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024)) |
208 | 205 | ||
209 | PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}` | 206 | PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}` |
210 | PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}` | 207 | PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}` |
211 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 ` | 208 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 ` |
212 | 209 | ||
213 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ | 210 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ |
214 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ | 211 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ |
215 | echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null | 212 | echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null |
216 | 213 | ||
217 | sleep 2; sync; | 214 | sleep 2; sync; |
218 | fdisk -l ${LPARAM_BLOCK_DEVICE} | 215 | fdisk -l ${LPARAM_BLOCK_DEVICE} |
219 | 216 | ||
220 | sleep 2; sync; | 217 | sleep 2; sync; |
221 | } | 218 | } |
222 | 219 | ||
223 | function format_parts | 220 | function format_parts |
224 | { | 221 | { |
225 | echo | 222 | echo |
226 | echo "Formatting partitions" | 223 | echo "Formatting partitions" |
227 | mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot | 224 | mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot |
228 | mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs | 225 | mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs |
229 | sync; sleep 1 | 226 | sync; sleep 1 |
230 | } | 227 | } |
231 | 228 | ||
232 | function install_bootloader | 229 | function install_bootloader |
233 | { | 230 | { |
234 | echo | 231 | echo |
235 | echo "Installing U-Boot" | 232 | echo "Installing U-Boot" |
236 | dd if=${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-flash_evk of=${LPARAM_BLOCK_DEVICE} bs=1K seek=${BOOTLOADER_OFFSET}; sync | 233 | dd if=${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-flash_evk of=${LPARAM_BLOCK_DEVICE} bs=1K seek=${BOOTLOADER_OFFSET}; sync |
237 | } | 234 | } |
238 | 235 | ||
239 | function mount_parts | 236 | function mount_parts |
240 | { | 237 | { |
241 | mkdir -p ${P1_MOUNT_DIR} | 238 | mkdir -p ${P1_MOUNT_DIR} |
242 | mkdir -p ${P2_MOUNT_DIR} | 239 | mkdir -p ${P2_MOUNT_DIR} |
243 | sync | 240 | sync |
244 | 241 | ||
245 | mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR} | 242 | mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR} |
246 | mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR} | 243 | mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR} |
247 | sleep 2; sync; | 244 | sleep 2; sync; |
248 | } | 245 | } |
249 | 246 | ||
250 | function unmount_parts | 247 | function unmount_parts |
251 | { | 248 | { |
252 | umount ${P1_MOUNT_DIR} | 249 | umount ${P1_MOUNT_DIR} |
253 | umount ${P2_MOUNT_DIR} | 250 | umount ${P2_MOUNT_DIR} |
254 | 251 | ||
255 | rm -rf ${P1_MOUNT_DIR} | 252 | rm -rf ${P1_MOUNT_DIR} |
256 | rm -rf ${P2_MOUNT_DIR} | 253 | rm -rf ${P2_MOUNT_DIR} |
257 | } | 254 | } |
258 | 255 | ||
259 | function install_yocto | 256 | function install_yocto |
260 | { | 257 | { |
261 | echo | 258 | echo |
262 | echo "Flashing \"Image, device tree and uEnv.txt\" partition" | 259 | echo "Flashing \"Image, device tree and uEnv.txt\" partition" |
263 | cp -v ${YOCTO_IMGS_PATH}/Image ${P1_MOUNT_DIR}/ | 260 | cp -v ${YOCTO_IMGS_PATH}/Image ${P1_MOUNT_DIR}/ |
264 | mkdir -p ${P1_MOUNT_DIR}/dtbs/ | 261 | mkdir -p ${P1_MOUNT_DIR}/dtbs/ |
265 | cp -v ${YOCTO_IMGS_PATH}/fsl-smarcimx8mq${DISPLAY}.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mq.dtb | 262 | cp -v ${YOCTO_IMGS_PATH}/fsl-smarcimx8mm.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mm.dtb |
266 | cp -v ${YOCTO_SCRIPTS_PATH}/uEnv.txt ${P1_MOUNT_DIR}/ | 263 | cp -v ${YOCTO_SCRIPTS_PATH}/uEnv.txt ${P1_MOUNT_DIR}/ |
267 | 264 | ||
268 | echo | 265 | echo |
269 | echo "Installing Yocto Root File System" | 266 | echo "Installing Yocto Root File System" |
270 | tar jxvf ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 -C ${P2_MOUNT_DIR}/ | 267 | tar jxvf ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 -C ${P2_MOUNT_DIR}/ |
271 | sync | 268 | sync |
272 | } | 269 | } |
273 | 270 | ||
274 | function copy_images | 271 | function copy_images |
275 | { | 272 | { |
276 | echo | 273 | echo |
277 | echo "Copying Yocto images to /opt/images/" | 274 | echo "Copying Yocto images to /opt/images/" |
278 | mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto | 275 | mkdir -p ${P2_MOUNT_DIR}/opt/images/Yocto |
279 | 276 | ||
280 | # Copy image for eMMC | 277 | # Copy image for eMMC |
281 | if [ -f ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 ]; then | 278 | if [ -f ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 ]; then |
282 | pv ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 > ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2 | 279 | pv ${YOCTO_IMGS_PATH}/${YOCTO_DEFAULT_IMAGE}-${MACHINE}.tar.bz2 > ${P2_MOUNT_DIR}/opt/images/Yocto/rootfs.tar.bz2 |
283 | else | 280 | else |
284 | echo "rootfs.tar.gz file is not present. Installation on \"eMMC\" will not be supported." | 281 | echo "rootfs.tar.gz file is not present. Installation on \"eMMC\" will not be supported." |
285 | fi | 282 | fi |
286 | 283 | ||
287 | echo | 284 | echo |
288 | echo "Copying Kernel Images to /opt/images/" | 285 | echo "Copying Kernel Images to /opt/images/" |
289 | cp ${YOCTO_IMGS_PATH}/Image ${P2_MOUNT_DIR}/opt/images/Yocto/Image | 286 | cp ${YOCTO_IMGS_PATH}/Image ${P2_MOUNT_DIR}/opt/images/Yocto/Image |
290 | 287 | ||
291 | echo | 288 | echo |
292 | echo "Copying Kernel Device Tree Blob to /opt/images/" | 289 | echo "Copying Kernel Device Tree Blob to /opt/images/" |
293 | cp -v ${YOCTO_IMGS_PATH}/*.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ | 290 | cp -v ${YOCTO_IMGS_PATH}/*.dtb ${P2_MOUNT_DIR}/opt/images/Yocto/ |
294 | 291 | ||
295 | echo | 292 | echo |
296 | echo "Copying Kernel Parameter uEnv.txt to /opt/images/" | 293 | echo "Copying Kernel Parameter uEnv.txt to /opt/images/" |
297 | cp -v ${YOCTO_SCRIPTS_PATH}/uEnv_emmc.txt ${P2_MOUNT_DIR}/opt/images/Yocto/uEnv.txt | 294 | cp -v ${YOCTO_SCRIPTS_PATH}/uEnv_emmc.txt ${P2_MOUNT_DIR}/opt/images/Yocto/uEnv.txt |
298 | 295 | ||
299 | if [[ $MACHINE = "smarcimx8m2g" || ${MACHINE} = "smarcimx8m4g" ]]; then | 296 | if [[ $MACHINE = "smarcimx8mm2g" || ${MACHINE} = "smarcimx8mm4g" ]]; then |
300 | cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-* ${P2_MOUNT_DIR}/opt/images/Yocto | 297 | cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin-* ${P2_MOUNT_DIR}/opt/images/Yocto |
301 | (cd ${P2_MOUNT_DIR}/opt/images/Yocto; ln -fs imx-boot-${MACHINE}-sd.bin-flash_evk imx-boot-sd.bin) | 298 | (cd ${P2_MOUNT_DIR}/opt/images/Yocto; ln -fs imx-boot-${MACHINE}-sd.bin-flash_evk imx-boot-sd.bin) |
302 | else | 299 | else |
303 | cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/imx-boot-sd.bin | 300 | cp ${YOCTO_IMGS_PATH}/imx-boot-${MACHINE}-sd.bin ${P2_MOUNT_DIR}/opt/images/Yocto/imx-boot-sd.bin |
304 | fi | 301 | fi |
305 | } | 302 | } |
306 | 303 | ||
307 | function copy_scripts | 304 | function copy_scripts |
308 | { | 305 | { |
309 | echo | 306 | echo |
310 | echo "Copying scripts" | 307 | echo "Copying scripts" |
311 | 308 | ||
312 | cp ${YOCTO_SCRIPTS_PATH}/emb-create-yocto-emmc.sh ${P2_MOUNT_DIR}/usr/bin/ | 309 | cp ${YOCTO_SCRIPTS_PATH}/emb-create-yocto-emmc.sh ${P2_MOUNT_DIR}/usr/bin/ |
313 | } | 310 | } |
314 | 311 | ||
315 | umount ${LPARAM_BLOCK_DEVICE}${part}* 2> /dev/null || true | 312 | umount ${LPARAM_BLOCK_DEVICE}${part}* 2> /dev/null || true |
316 | 313 | ||
317 | delete_device | 314 | delete_device |
318 | create_parts | 315 | create_parts |
319 | format_parts | 316 | format_parts |
320 | 317 | ||
321 | mount_parts | 318 | mount_parts |
322 | install_yocto | 319 | install_yocto |
323 | copy_images | 320 | copy_images |
324 | copy_scripts | 321 | copy_scripts |
325 | 322 | ||
326 | echo | 323 | echo |
327 | echo "Syncing" | 324 | echo "Syncing" |
328 | sync | pv -t | 325 | sync | pv -t |
329 | 326 | ||
330 | unmount_parts | 327 | unmount_parts |
331 | 328 | ||
332 | install_bootloader | 329 | install_bootloader |
333 | 330 | ||
334 | echo | 331 | echo |
335 | echo "Done" | 332 | echo "Done" |
336 | echo "========Flash to SD card Completed!=========" | 333 | echo "========Flash to SD card Completed!=========" |
337 | 334 | ||
338 | exit 0 | 335 | exit 0 |
339 | 336 |
scripts/emb_mk_yocto_sdcard/uEnv.txt
1 | optargs="video=HDMI-A-1:1920x1080-32@60 consoleblank=0" | ||
2 | #optargs="video=HDMI-A-1:3840x2160-32@30 consoleblank=0" | ||
3 | #optargs="video=HDMI-A-1:3840x2160-32@60 consoleblank=0" | ||
4 | #console port SER3 | 1 | #console port SER3 |
5 | console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200 | 2 | console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 |
6 | #console port SER2 | 3 | #console port SER2 |
7 | #console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 | ||
8 | #console port SER1 | ||
9 | #console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200 | 4 | #console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200 |
5 | #console port SER1 | ||
6 | #console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200 | ||
10 | #console port SER0 | 7 | #console port SER0 |
11 | #console=ttymxc3,115200 earlycon=ec_imx6q,0x30A60000,115200 | 8 | #console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200 |
12 | mmcdev=1 | 9 | mmcdev=1 |
13 | mmcpart=1 | 10 | mmcpart=1 |
14 | image=Image | 11 | image=Image |
15 | loadaddr=0x40480000 | 12 | loadaddr=0x40480000 |
16 | fdt_addr=0x43000000 | 13 | fdt_addr=0x43000000 |
17 | mmcroot=/dev/mmcblk1p2 rw | 14 | mmcroot=/dev/mmcblk1p2 rw |
18 | usbroot=/dev/sda2 rw | 15 | usbroot=/dev/sda2 rw |
19 | mmcrootfstype=ext4 rootwait fixrtc | 16 | mmcrootfstype=ext4 rootwait fixrtc |
20 | netdev=eth0 | 17 | netdev=eth0 |
21 | ethact=FEC0 | 18 | ethact=FEC0 |
22 | ipaddr=192.168.1.150 | 19 | ipaddr=192.168.1.150 |
23 | serverip=192.168.1.53 | 20 | serverip=192.168.1.53 |
24 | gatewayip=192.168.1.254 | 21 | gatewayip=192.168.1.254 |
25 | mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs} | 22 | mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs} cma=400M |
26 | uenvcmd=run loadimage; run loadfdt; run mmcboot | 23 | uenvcmd=run loadimage; run loadfdt; run mmcboot |
27 | # USB Boot | 24 | # USB Boot |
28 | #usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs} | 25 | #usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs} |
scripts/emb_mk_yocto_sdcard/uEnv_emmc.txt
1 | optargs="video=HDMI-A-1:1920x1080-32@60 consoleblank=0" | ||
2 | #optargs="video=HDMI-A-1:3840x2160-32@30 consoleblank=0" | ||
3 | #optargs="video=HDMI-A-1:3840x2160-32@60 consoleblank=0" | ||
4 | #console port SER3 | 1 | #console port SER3 |
5 | console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200 | 2 | console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 |
6 | #console port SER2 | 3 | #console port SER2 |
7 | #console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 | ||
8 | #console port SER1 | ||
9 | #console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200 | 4 | #console=ttymxc2,115200 earlycon=ec_imx6q,0x30880000,115200 |
5 | #console port SER1 | ||
6 | #console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200 | ||
10 | #console port SER0 | 7 | #console port SER0 |
11 | #console=ttymxc3,115200 earlycon=ec_imx6q,0x30A60000,115200 | 8 | #console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200 |
12 | mmcdev=0 | 9 | mmcdev=0 |
13 | mmcpart=1 | 10 | mmcpart=1 |
14 | image=Image | 11 | image=Image |
15 | loadaddr=0x40480000 | 12 | loadaddr=0x40480000 |
16 | fdt_addr=0x43000000 | 13 | fdt_addr=0x43000000 |
17 | mmcroot=/dev/mmcblk0p2 rw | 14 | mmcroot=/dev/mmcblk0p2 rw |
18 | usbroot=/dev/sda2 rw | 15 | usbroot=/dev/sda2 rw |
19 | mmcrootfstype=ext4 rootwait fixrtc | 16 | mmcrootfstype=ext4 rootwait fixrtc |
20 | netdev=eth0 | 17 | netdev=eth0 |
21 | ethact=FEC0 | 18 | ethact=FEC0 |
22 | ipaddr=192.168.1.150 | 19 | ipaddr=192.168.1.150 |
23 | serverip=192.168.1.53 | 20 | serverip=192.168.1.53 |
24 | gatewayip=192.168.1.254 | 21 | gatewayip=192.168.1.254 |
25 | mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs} | 22 | mmcargs=setenv bootargs console=${console} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs} cma=400M |
26 | uenvcmd=run loadimage; run loadfdt; run mmcboot | 23 | uenvcmd=run loadimage; run loadfdt; run mmcboot |
27 | # USB Boot | 24 | # USB Boot |
28 | #usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs} | 25 | #usbargs=setenv bootargs console=${console} root=${usbroot} rootfstype=${mmcrootfstype} ${optargs} |