From 723226c1a4151e4e1b89c58bff7b045baba16588 Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Fri, 7 Feb 2020 19:09:45 +0800 Subject: [PATCH] Yocto Sumo Support for SMARC-iMX8M, Based on Linux 4.14.98_2.0.0_ga, Initial Release --- conf/machine/smarcimx8m2g.conf | 3 +- conf/machine/smarcimx8m2gind.conf | 91 ------ conf/machine/smarcimx8m4g.conf | 3 +- recipes-bsp/u-boot/u-boot-smarcimx8m_2018.03.bb | 4 +- recipes-kernel/linux/linux-smarcimx8m_4.14.78.bb | 42 --- recipes-kernel/linux/linux-smarcimx8m_4.14.98.bb | 42 +++ scripts/emb_mk_yocto_sdcard/README.txt | 30 ++ .../emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh | 263 ++++++++++++++++ .../emb_mk_yocto_sdcard/emb-create-yocto-sdcard.sh | 338 +++++++++++++++++++++ scripts/emb_mk_yocto_sdcard/uEnv.txt | 29 ++ scripts/emb_mk_yocto_sdcard/uEnv_emmc.txt | 29 ++ 11 files changed, 737 insertions(+), 137 deletions(-) delete mode 100644 conf/machine/smarcimx8m2gind.conf delete mode 100644 recipes-kernel/linux/linux-smarcimx8m_4.14.78.bb create mode 100644 recipes-kernel/linux/linux-smarcimx8m_4.14.98.bb create mode 100644 scripts/emb_mk_yocto_sdcard/README.txt create mode 100755 scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh create mode 100755 scripts/emb_mk_yocto_sdcard/emb-create-yocto-sdcard.sh create mode 100644 scripts/emb_mk_yocto_sdcard/uEnv.txt create mode 100644 scripts/emb_mk_yocto_sdcard/uEnv_emmc.txt diff --git a/conf/machine/smarcimx8m2g.conf b/conf/machine/smarcimx8m2g.conf index abf24b7..5263ef5 100644 --- a/conf/machine/smarcimx8m2g.conf +++ b/conf/machine/smarcimx8m2g.conf @@ -16,7 +16,7 @@ IMAGE_FEATURES += "package-management" # Embedian BSP default providers PREFERRED_PROVIDER_virtual/kernel_smarcimx8m2g ?= "linux-smarcimx8m" -PREFERRED_VERSION_linux-smarcimx8m2g_smarcimx8m2g = "4.14.78" +PREFERRED_VERSION_linux-smarcimx8m2g_smarcimx8m2g = "4.14.98" KERNEL_DEVICETREE = " \ embedian/fsl-smarcimx8mq.dtb \ @@ -72,6 +72,7 @@ MACHINE_EXTRA_RDEPENDS += " \ boost \ nodejs \ networkmanager \ + imx-gpu-viv \ " BBMASK_prepend = "fsl-image-mfgtool-initramfs " diff --git a/conf/machine/smarcimx8m2gind.conf b/conf/machine/smarcimx8m2gind.conf deleted file mode 100644 index 46c5e34..0000000 --- a/conf/machine/smarcimx8m2gind.conf +++ /dev/null @@ -1,91 +0,0 @@ -#@TYPE: Machine -#@NAME: EMBEDIAN SMARC-iMX8M COMPUTER ON MODULES with 2GB LPDDR4 MEMORY -#@SOC: i.MX8MQ -#@DESCRIPTION: Machine configuration for Embedian SMARC-iMX8M -#@MAINTAINER: Eric Lee -# -# http://www.www.embedian.com - -MACHINEOVERRIDES =. "mx8:mx8m:mx8mq:" -require conf/machine/include/imx-base.inc -require conf/machine/include/arm/arch-arm64.inc - -MACHINE_FEATURES += " usbgadget vfat ext2 alsa serial pci wifi bluetooth" - -IMAGE_FEATURES += "package-management" - -# Embedian BSP default providers -PREFERRED_PROVIDER_virtual/kernel_smarcimx8m2gind ?= "linux-smarcimx8m" -PREFERRED_VERSION_linux-smarcimx8m_smarcimx8m2gind = "4.14.78" - -KERNEL_DEVICETREE = " \ - embedian/fsl-smarcimx8mq.dtb \ - embedian/fsl-smarcimx8mq-dcss-lvds.dtb \ - embedian/fsl-smarcimx8mq-lcdif-lvds.dtb \ - embedian/fsl-smarcimx8mq-hdmi.dtb \ - embedian/fsl-smarcimx8mq-dp.dtb \ - embedian/fsl-smarcimx8mq-edp.dtb \ - embedian/fsl-smarcimx8mq-dual-display.dtb \ -" -IMAGE_BOOTFILES_DEPENDS += "imx-m4-demos:do_deploy" -IMAGE_BOOTFILES += "imx8mq_m4_TCM_hello_world.bin imx8mq_m4_TCM_rpmsg_lite_pingpong_rtos_linux_remote.bin imx8mq_m4_TCM_rpmsg_lite_str_echo_rtos.bin" - -PREFERRED_PROVIDER_u-boot_smarcimx8m2gind = "u-boot-smarcimx8m" -PREFERRED_PROVIDER_virtual/bootloader_smarcimx8m2gind = "u-boot-smarcimx8m" - -UBOOT_CONFIG ??= "sd" -UBOOT_CONFIG[sd] = "smarcimx8mq_2g_ser3_ind_defconfig,sdcard" -SPL_BINARY = "spl/u-boot-spl.bin" - -# Set DDR FIRMWARE -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" - -# Set U-Boot DTB -UBOOT_DTB_NAME = "fsl-smarcimx8mq.dtb" - -# Set imx-mkimage boot target -IMXBOOT_TARGETS = "flash_evk flash_evk_no_hdmi flash_dp_evk" - -SERIAL_CONSOLE = "115200 ttymxc0" - -IMAGE_BOOTLOADER = "imx-boot" - -BOOT_SPACE = "65536" - -LOADADDR = "" -UBOOT_SUFFIX = "bin" -UBOOT_MAKE_TARGET = "" -IMX_BOOT_SEEK = "33" - -PREFERRED_RPROVIDER_ptpd = "ptpd" -PREFERRED_RPROVIDER_ptpd-dev = "ptpd" - -MACHINE_EXTRA_RDEPENDS += " \ - packagegroup-tools-bluetooth \ - pm-utils \ - kmod \ - hdparm \ - gptfdisk \ - lftp \ - vim \ - ntp \ - boost \ - nodejs \ - networkmanager \ - " - -BBMASK_prepend = "fsl-image-mfgtool-initramfs " - -# Packages added to all images (including core-image-minimal) -IMAGE_INSTALL_append = " \ - firmware-imx-sdma \ - firmware-imx-epdc \ - fsl-rc-local \ -" - -IMAGE_FSTYPES = "tar.bz2" - -# Ship all kernel modules by default -MACHINE_EXTRA_RRECOMMENDS = "kernel-modules" - -MACHINE_FIRMWARE_append_mx8 = " linux-firmware-ath10k" diff --git a/conf/machine/smarcimx8m4g.conf b/conf/machine/smarcimx8m4g.conf index 288db9b..cbde960 100644 --- a/conf/machine/smarcimx8m4g.conf +++ b/conf/machine/smarcimx8m4g.conf @@ -16,7 +16,7 @@ IMAGE_FEATURES += "package-management" # Embedian BSP default providers PREFERRED_PROVIDER_virtual/kernel_smarcimx8m4g ?= "linux-smarcimx8m" -PREFERRED_VERSION_linux-smarcimx8m_smarcimx8m4g = "4.14.78" +PREFERRED_VERSION_linux-smarcimx8m_smarcimx8m4g = "4.14.98" KERNEL_DEVICETREE = " \ embedian/fsl-smarcimx8mq.dtb \ @@ -72,6 +72,7 @@ MACHINE_EXTRA_RDEPENDS += " \ boost \ nodejs \ networkmanager \ + imx-gpu-viv \ " BBMASK_prepend = "fsl-image-mfgtool-initramfs " diff --git a/recipes-bsp/u-boot/u-boot-smarcimx8m_2018.03.bb b/recipes-bsp/u-boot/u-boot-smarcimx8m_2018.03.bb index a2fee51..7920524 100644 --- a/recipes-bsp/u-boot/u-boot-smarcimx8m_2018.03.bb +++ b/recipes-bsp/u-boot/u-boot-smarcimx8m_2018.03.bb @@ -12,9 +12,9 @@ LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://Licenses/gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263" UBOOT_SRC ?= "${EMB_UBOOT_MIRROR};protocol=ssh" -SRCBRANCH = "smarc-imx_v2018.03_4.14.78_1.0.0_ga" +SRCBRANCH = "smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga" SRC_URI = "${UBOOT_SRC};branch=${SRCBRANCH}" -SRCREV = "2a0a07c75344130b0c43ae5cecc657afc2672a30" +SRCREV = "f5822d3223a48fbb57c8bde92579b125ef26fd1f" S = "${WORKDIR}/git" diff --git a/recipes-kernel/linux/linux-smarcimx8m_4.14.78.bb b/recipes-kernel/linux/linux-smarcimx8m_4.14.78.bb deleted file mode 100644 index cc6888d..0000000 --- a/recipes-kernel/linux/linux-smarcimx8m_4.14.78.bb +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2013-2016 Freescale Semiconductor -# Copyright 2017 NXP -# Copyright 2018-2019 Embedian, Inc. -# Released under the MIT license (see COPYING.MIT for the terms) - -SUMMARY = "Linux kernel provided and supported by Embedian" -DESCRIPTION = "Linux kernel provided and supported by Embedian (based on the kernel imx_4.14.78_1.0.0_ga provided by NXP) \ -with focus on i.MX Family SOMs. It includes support for many IPs such as GPU, VPU and IPU." - -require recipes-kernel/linux/linux-imx.inc - -DEPENDS += "lzop-native bc-native" - -DEFAULT_PREFERENCE = "1" - -SRCBRANCH = "smarc_8m_imx_4.14.78_1.0.0_ga" - -LOCALVERSION = "-${SRCBRANCH}" -KERNEL_DEFCONFIG = "${S}/arch/arm64/configs/smarcimx8m_defconfig" -DEFAULT_DTB = "fsl-smarcimx8mq" - -KERNEL_SRC ?= "git@git.embedian.com:developer/smarc-fsl-linux-kernel.git;protocol=git" -SRC_URI = "${EMB_KERNEL_MIRROR};protocol=ssh;branch=${SRCBRANCH}" -SRCREV = "5391ef46f0e83d177b39b575518a70df15d8dcc2" - -S = "${WORKDIR}/git" - -addtask copy_defconfig after do_unpack before do_preconfigure -do_copy_defconfig () { - install -d ${B} - mkdir -p ${B} - cp ${KERNEL_DEFCONFIG} ${B}/.config - cp ${KERNEL_DEFCONFIG} ${B}/../defconfig -} - -pkg_postinst_kernel-devicetree_append_mx8 () { - cd $D/boot - ln -s ${DEFAULT_DTB}.dtb ${UBOOT_DTB_NAME} -} - -COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" -EXTRA_OEMAKE_append_mx8 = " ARCH=arm64" diff --git a/recipes-kernel/linux/linux-smarcimx8m_4.14.98.bb b/recipes-kernel/linux/linux-smarcimx8m_4.14.98.bb new file mode 100644 index 0000000..37c21c9 --- /dev/null +++ b/recipes-kernel/linux/linux-smarcimx8m_4.14.98.bb @@ -0,0 +1,42 @@ +# Copyright (C) 2013-2016 Freescale Semiconductor +# Copyright 2017 NXP +# Copyright 2018-2019 Embedian, Inc. +# Released under the MIT license (see COPYING.MIT for the terms) + +SUMMARY = "Linux kernel provided and supported by Embedian" +DESCRIPTION = "Linux kernel provided and supported by Embedian (based on the kernel imx_4.14.78_1.0.0_ga provided by NXP) \ +with focus on i.MX Family SOMs. It includes support for many IPs such as GPU, VPU and IPU." + +require recipes-kernel/linux/linux-imx.inc + +DEPENDS += "lzop-native bc-native" + +DEFAULT_PREFERENCE = "1" + +SRCBRANCH = "smarc_8m_imx_4.14.98_2.0.0_ga" + +LOCALVERSION = "-${SRCBRANCH}" +KERNEL_DEFCONFIG = "${S}/arch/arm64/configs/smarcimx8m_defconfig" +DEFAULT_DTB = "fsl-smarcimx8mq" + +KERNEL_SRC ?= "git@git.embedian.com:developer/smarc-fsl-linux-kernel.git;protocol=git" +SRC_URI = "${EMB_KERNEL_MIRROR};protocol=ssh;branch=${SRCBRANCH}" +SRCREV = "eded7c98ab8eccc988eddf2dcbca68c937c324e8" + +S = "${WORKDIR}/git" + +addtask copy_defconfig after do_unpack before do_preconfigure +do_copy_defconfig () { + install -d ${B} + mkdir -p ${B} + cp ${KERNEL_DEFCONFIG} ${B}/.config + cp ${KERNEL_DEFCONFIG} ${B}/../defconfig +} + +pkg_postinst_kernel-devicetree_append_mx8 () { + cd $D/boot + ln -s ${DEFAULT_DTB}.dtb ${UBOOT_DTB_NAME} +} + +COMPATIBLE_MACHINE = "(mx6|mx7|mx8)" +EXTRA_OEMAKE_append_mx8 = " ARCH=arm64" diff --git a/scripts/emb_mk_yocto_sdcard/README.txt b/scripts/emb_mk_yocto_sdcard/README.txt new file mode 100644 index 0000000..8747d67 --- /dev/null +++ b/scripts/emb_mk_yocto_sdcard/README.txt @@ -0,0 +1,30 @@ +How to use the Embedian SD card creation script: +================================================= + +This utility is provided on an "AS IS" basis. +This is the script we use to create our recovery SD card. +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. +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. + +Note: +Before running this script you need to bitbake fsl-image-gui. + + +Usage: +sudo MACHINE= ./emb-create-yocto-sdcard.sh [options] /dev/sdX +(Change /dev/sdX to your device name) + +options: + -h Display help message + -s Only show partition sizes to be written, without actually write them + -a Automatically set the rootfs partition size to fill the SD card + -r Select alternative rootfs for recovery images (default: build_x11/tmp/deploy/images//fsl-image-validation-imx.tar.bz2) + +If you don't use the '-a' option, a default rootfs size of 3700MiB will be used. +The '-r' option allows you to create a bootable sdcard with an alternative image for the installation to NAND flash or eMMC. +Example: "-r tmp/deploy/images//fsl-image-qt5-validation-imx" -- selects the "Qt5 image with X11" recovery image + + +Once the script is done, use the SD card to boot, and then to flash your internal storage/s either use the icons, +or the following linux shell script: +install_yocto.sh diff --git a/scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh b/scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh new file mode 100755 index 0000000..f102f4a --- /dev/null +++ b/scripts/emb_mk_yocto_sdcard/emb-create-yocto-emmc.sh @@ -0,0 +1,263 @@ +#!/bin/bash -e + +blue_underlined_bold_echo() +{ + echo -e "\e[34m\e[4m\e[1m$@\e[0m" +} + +blue_bold_echo() +{ + echo -e "\e[34m\e[1m$@\e[0m" +} + +red_bold_echo() +{ + echo -e "\e[31m\e[1m$@\e[0m" +} + +IMGS_PATH=/opt/images/Yocto +UBOOT_IMAGE=imx-boot-sd.bin +KERNEL_IMAGE=Image +ROOTFS_IMAGE=rootfs.tar.bz2 +BOOTLOADER_RESERVED_SIZE=2 +PART1_SIZE=48 +BOOTLOADER_OFFSET=33 +DISPLAY=-hdmi +PART=p +BOOTPART=1 +ROOTFSPART=2 +BOOTDIR=/boot + +check_board() +{ + if grep -q "i.MX8M" /sys/devices/soc0/soc_id; then + BOARD=smarc-imx8m + DTB_PREFIX=fsl-smarcimx8mq + BLOCK=mmcblk0 + + if [[ $DISPLAY != "-lvds" && $DISPLAY != "-hdmi" && \ + $DISPLAY != "-dual-display" && $DISPLAY != "" ]]; then + red_bold_echo "ERROR: invalid display, should be lvds, hdmi, dual-display or empty" + exit 1 + fi + else + red_bold_echo "ERROR: Unsupported board" + exit 1 + fi + + + if [[ ! -b /dev/${BLOCK} ]] ; then + red_bold_echo "ERROR: Can't find eMMC device (/dev/${BLOCK})." + red_bold_echo "Please verify you are using the correct options for your SMARC Module." + exit 1 + fi +} + +check_images() +{ + if [[ ! -f $IMGS_PATH/$UBOOT_IMAGE ]] ; then + red_bold_echo "ERROR: \"$IMGS_PATH/$UBOOT_IMAGE\" does not exist" + exit 1 + fi + + if [[ ! -f $IMGS_PATH/$KERNEL_IMAGE ]] ; then + red_bold_echo "ERROR: \"$IMGS_PATH/$KERNEL_IMAGE\" does not exist" + exit 1 + fi + + if [[ ! -f $IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb ]] ; then + red_bold_echo "ERROR: \"$IMGS_PATH/${DTB_PREFIX}${DISPLAY}.dtb\" does not exist" + exit 1 + fi + + if [[ ! -f $IMGS_PATH/uEnv.txt ]] ; then + red_bold_echo "ERROR: \"$IMGS_PATH/uEnv.txt\" does not exist" + exit 1 + fi + + if [[ ! -f $IMGS_PATH/$ROOTFS_IMAGE ]] ; then + red_bold_echo "ERROR: \"$IMGS_PATH/$ROOTFS_IMAGE\" does not exist" + exit 1 + fi +} + +delete_emmc() +{ + echo + blue_underlined_bold_echo "Deleting current partitions" + + umount /dev/${BLOCK}${PART}* 2>/dev/null || true + + for ((i=1; i<=16; i++)); do + if [[ -e /dev/${BLOCK}${PART}${i} ]]; then + dd if=/dev/zero of=/dev/${BLOCK}${PART}${i} bs=1M count=1 2>/dev/null || true + fi + done + sync + + dd if=/dev/zero of=/dev/${BLOCK} bs=1M count=${BOOTLOADER_RESERVED_SIZE} + + sync; sleep 1 +} + +create_emmc_parts() +{ + echo + blue_underlined_bold_echo "Creating new partitions" + + SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/hw_sector_size` + PART1_FIRST_SECT=$(($BOOTLOADER_RESERVED_SIZE * 1024 * 1024 / $SECT_SIZE_BYTES)) + PART1_END_SECT=$((($BOOTLOADER_RESERVED_SIZE + $PART1_SIZE) * 1024 * 1024 / $SECT_SIZE_BYTES)) + PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1` + + (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ + echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ + echo $PART2_FIRST_SECT; echo; \ + echo p; echo w) | fdisk -u /dev/${BLOCK} > /dev/null + + sync; sleep 1 + fdisk -u -l /dev/${BLOCK} +} + +format_emmc_parts() +{ + echo + blue_underlined_bold_echo "Formatting partitions" + + mkfs.vfat -F 16 /dev/${BLOCK}${PART}${BOOTPART} -n boot + mkfs.ext4 /dev/${BLOCK}${PART}${ROOTFSPART} -L rootfs + + sync; sleep 1 +} + +install_bootloader_to_emmc() +{ + echo + blue_underlined_bold_echo "Installing booloader" + + dd if=${IMGS_PATH}/${UBOOT_IMAGE} of=/dev/${BLOCK} bs=1K seek=${BOOTLOADER_OFFSET} + sync +} + +install_kernel_to_emmc() +{ + echo + blue_underlined_bold_echo "Installing kernel" + + MOUNTDIR=/run/media/${BLOCK}${PART}${BOOTPART} + mkdir -p ${MOUNTDIR} + mount /dev/${BLOCK}${PART}${BOOTPART} ${MOUNTDIR} + mkdir -p ${MOUNTDIR}/dtbs/ + cp -v ${IMGS_PATH}/${KERNEL_IMAGE} ${MOUNTDIR} + cp -v ${IMGS_PATH}/${DTB_PREFIX}${DISPLAY}.dtb ${MOUNTDIR}/dtbs/fsl-smarcimx8mq.dtb + cp -v ${IMGS_PATH}/uEnv.txt ${MOUNTDIR} + + echo + sync + + umount ${MOUNTDIR} +} + +install_rootfs_to_emmc() +{ + echo + blue_underlined_bold_echo "Installing rootfs" + + MOUNTDIR=/run/media/${BLOCK}${PART}${ROOTFSPART} + mkdir -p ${MOUNTDIR} + mount /dev/${BLOCK}${PART}${ROOTFSPART} ${MOUNTDIR} + + printf "Extracting files" + tar --warning=no-timestamp -jxvf ${IMGS_PATH}/${ROOTFS_IMAGE} -C ${MOUNTDIR} --checkpoint=.1200 + + # Create DTB symlink + (cd ${MOUNTDIR}/${BOOTDIR}; ln -fs ${DTB_PREFIX}${DISPLAY}.dtb ${DTB_PREFIX}.dtb) + + echo + sync + + umount ${MOUNTDIR} +} + +stop_udev() +{ + if [ -f /lib/systemd/system/systemd-udevd.service ]; then + systemctl -q mask --runtime systemd-udevd + systemctl -q stop systemd-udevd + fi +} + +start_udev() +{ + if [ -f /lib/systemd/system/systemd-udevd.service ]; then + systemctl -q unmask --runtime systemd-udevd + systemctl -q start systemd-udevd + fi +} + +usage() +{ + echo + echo "This script installs Yocto Rootfs on the SMARC-iMX8M's internal eMMC storage device" + echo + echo " Usage: $(basename $0)