From 8b01fe57a94b576a643e524e18971b2e1a42021b Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Wed, 27 Jan 2021 14:51:10 +0100 Subject: [PATCH] uboot: add support to ConnectCore 8M Mini DVK platform Add initial support cloned from ccimx8mn-dvk https://jira.digi.com/browse/DEL-7397 Signed-off-by: Arturo Buzarra --- .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 66 ++++++++ .../ccimx8mm-dvk/install_linux_fw_sd.txt | 146 +++++++++++++++++ .../ccimx8mm-dvk/install_linux_fw_usb.txt | 147 ++++++++++++++++++ .../ccimx8mm-dvk/install_linux_fw_uuu.sh | 119 ++++++++++++++ .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 6 +- 5 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt create mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_sd.txt create mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_usb.txt create mode 100755 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_uuu.sh diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt new file mode 100644 index 000000000..3e921656f --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -0,0 +1,66 @@ +# +# U-Boot bootscript for EMMC/SD images created by Yocto. +# + +# Back up environment variables +setenv ORIG_overlays ${overlays} +setenv ORIG_extra_bootargs ${extra_bootargs} + +# Set SOC type to "imx8mm" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mm" +fi + +# +# Determine overlays to apply depending on the hardware capabilities +# described by the HWID, SOM version, and carrier board version. +# +if test -n "${module_ram}"; then + setexpr som_hv ${hwid_2} \& 38 + setexpr som_hv ${som_hv} / 8 + + setexpr module_has_wifi ${hwid_2} \& 10000 + setexpr module_has_wifi ${module_has_wifi} / 10000 + setexpr module_has_bt ${hwid_2} \& 20000 + setexpr module_has_bt ${module_has_bt} / 20000 + + if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then + setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} + fi + + if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then + setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} + fi +fi + +# Apply quad overlay if the SOC type is "imx8mm" +if test "${soc_type}" = "imx8mm"; then + setenv overlays _ov_som_quad_ccimx8m.dtbo,${overlays} +fi + +# Get the UUID of the configured boot partition. +part uuid mmc ${mmcbootdev}:${mmcpart} bootpart +# Check the boot source. +if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true +elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img +else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 +fi +setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} +dboot linux mmc ${mmcbootdev}:${mmcpart} + + + +# We only get here in case of an error on the dboot command. + +# Undo changes to environment variables +setenv overlays ${ORIG_overlays} +setenv ORIG_overlays +setenv extra_bootargs ${ORIG_extra_bootargs} +setenv ORIG_extra_bootargs diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_sd.txt new file mode 100644 index 000000000..7b0e037ca --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_sd.txt @@ -0,0 +1,146 @@ +# +# U-Boot script for installing Linux images created by Yocto from the SD +# card into the eMMC +# + +echo "############################################################" +echo "# Linux firmware install from micro SD #" +echo "############################################################" +echo "" +echo " This process will erase your eMMC and will install a new" +echo " U-Boot and Linux firmware images on the eMMC." +echo "" +echo " Press CTRL+C now if you wish to abort or wait 10 seconds" +echo " to continue." + +sleep 10 +if test $? -eq 1; then + echo "Aborted by user."; + exit; +fi + +setenv INSTALL_UBOOT_FILENAME imx-boot-ccimx8mm-dvk.bin; +setenv INSTALL_MMCDEV 1 +setenv INSTALL_LINUX_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.boot.vfat +setenv INSTALL_RECOVERY_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.recovery.vfat +setenv INSTALL_ROOTFS_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.ext4 + +# Check for presence of firmware files on the SD card +for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}; do + if test ! -e mmc ${INSTALL_MMCDEV} ${install_f}; then + echo "ERROR: Could not find file ${install_f}"; + install_abort=1; + fi; +done +if test -n "${install_abort}"; then + echo "Aborted."; + exit; +fi + +# Skip user confirmation for U-Boot update +setenv forced_update 1 + +# Set bootdelay to zero so that firmware update is run immediately after +# the first reset. +setenv bootdelay 0 + +# Set target MMC device index to eMMC +setenv mmcdev 0 + +# Update U-Boot +echo "" +echo "" +echo ">> Installing U-Boot boot loader (target will reset)" +echo "" +echo "" +update uboot mmc ${INSTALL_MMCDEV} ${INSTALL_UBOOT_FILENAME} +if test $? -eq 1; then + # Use old-style update with source file system argument + update uboot mmc ${INSTALL_MMCDEV} fat ${INSTALL_UBOOT_FILENAME} + if test $? -eq 1; then + echo "[ERROR] Failed to update U-Boot boot loader!"; + echo ""; + echo "Aborted."; + exit; + fi +fi + +# Set 'bootcmd' to the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Force on-the-fly updates to avoid possible verification errors +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +# - Configure recovery to wipe 'update' partition +# - Disable on-the-fly updates +# - Run 'recovery' and let the system boot after +setenv bootcmd " + env default -a; + saveenv; + setenv otf-update yes; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing Linux kernel and device tree files\"; + echo \"\"; + echo \"\"; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing recovery\"; + echo \"\"; + echo \"\"; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing Linux root file system\"; + echo \"\"; + echo \"\"; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; + setenv otf-update; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \"\"; + echo \"\"; + sleep 1; + reset; +" + +saveenv +reset diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_usb.txt new file mode 100644 index 000000000..425f94f98 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_usb.txt @@ -0,0 +1,147 @@ +# +# U-Boot script for installing Linux images created by Yocto from a USB stick +# into the eMMC +# + +echo "#######################################################" +echo "# Linux firmware install from USB #" +echo "#######################################################" +echo "" +echo " This process will erase your eMMC and will install a new" +echo " U-Boot and Linux firmware images on the eMMC." +echo "" +echo " Press CTRL+C now if you wish to abort or wait 10 seconds" +echo " to continue." + +sleep 10 +if test $? -eq 1; then + echo "Aborted by user."; + exit; +fi + +setenv INSTALL_UBOOT_FILENAME imx-boot-ccimx8mm-dvk.bin; +setenv INSTALL_USBDEV 0 +setenv INSTALL_LINUX_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.boot.vfat +setenv INSTALL_RECOVERY_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.recovery.vfat +setenv INSTALL_ROOTFS_FILENAME dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.ext4 + +# Check for presence of firmware files on the USB +for install_f in ${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}; do + if test ! -e usb ${INSTALL_USBDEV} ${install_f}; then + echo "ERROR: Could not find file ${install_f}"; + install_abort=1; + fi; +done +if test -n "${install_abort}"; then + echo "Aborted."; + exit; +fi + +# Skip user confirmation for U-Boot update +setenv forced_update 1 + +# Set bootdelay to zero so that firmware update is run immediately after +# the first reset. +setenv bootdelay 0 + +# Set target MMC device index to eMMC +setenv mmcdev 0 + +# Update U-Boot +echo "" +echo "" +echo ">> Installing U-Boot boot loader (target will reset)" +echo "" +echo "" +update uboot usb ${INSTALL_USBDEV} ${INSTALL_UBOOT_FILENAME} +if test $? -eq 1; then + # Use old-style update with source file system argument + update uboot mmc ${INSTALL_USBDEV} fat ${INSTALL_UBOOT_FILENAME} + if test $? -eq 1; then + echo "[ERROR] Failed to update U-Boot boot loader!"; + echo ""; + echo "Aborted."; + exit; + fi +fi + +# Set 'bootcmd' to the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Force on-the-fly updates to avoid possible verification errors +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +# - Configure recovery to wipe 'update' partition +# - Disable on-the-fly updates +# - Run 'recovery' and let the system boot after +setenv bootcmd " + env default -a; + saveenv; + setenv otf-update yes; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + usb start; + echo \"\"; + echo \"\"; + echo \">> Installing Linux kernel and device tree files\"; + echo \"\"; + echo \"\"; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update linux partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing recovery\"; + echo \"\"; + echo \"\"; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update recovery partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Installing Linux root file system\"; + echo \"\"; + echo \"\"; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + if test \$? -eq 1; then + echo \"[ERROR] Failed to update rootfs partition!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + setenv boot_recovery yes; + setenv recovery_command wipe_update; + setenv otf-update; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Firmware installation complete. Rebooting into recovery mode for final deployment.\"; + echo \"\"; + echo \"\"; + sleep 1; + reset; +" + +saveenv +reset diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_uuu.sh new file mode 100755 index 000000000..73f676a80 --- /dev/null +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/install_linux_fw_uuu.sh @@ -0,0 +1,119 @@ +#!/bin/bash +#=============================================================================== +# +# Copyright (C) 2021 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# Description: +# Script to flash Yocto build artifacts over USB to the target. +#=============================================================================== +# set -x + +clear + +# Parse uuu cmd output +function getenv() +{ + uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" +} + +# +# U-Boot script for installing Linux images created by Yocto into the eMMC +# + +echo "############################################################" +echo "# Linux firmware install through USB OTG #" +echo "############################################################" +echo "" +echo " This process will erase your eMMC and will install a new" +echo " U-Boot and Linux firmware images on the eMMC." +echo "" +echo " Press CTRL+C now if you wish to abort or wait 10 seconds" +echo " to continue." + +# Get U-Boot file name from cmdline when passed +if [ -n "$1" ]; then + INSTALL_UBOOT_FILENAME="$1" +fi + +sleep 10 + +if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then + INSTALL_UBOOT_FILENAME="imx-boot-ccimx8mm-dvk.bin" +fi + +# Skip user confirmation for U-Boot update +uuu fb: ucmd setenv forced_update 1 + +# Update U-Boot +uuu fb: flash bootloader ${INSTALL_UBOOT_FILENAME} + +# Set MMC to boot from BOOT1 partition +uuu fb: ucmd mmc partconf 0 1 1 1 + +# Set 'bootcmd' for the second part of the script that will +# - Reset environment to defaults +# - Save the environment +# - Partition the eMMC user data area for Linux +# - Update the 'linux' partition +# - Update the 'recovery' partition +# - Update the 'rootfs' partition +uuu fb: ucmd setenv bootcmd " + env default -a; + saveenv; + echo \"\"; + echo \"\"; + echo \">> Creating Linux partition table on the eMMC\"; + echo \"\"; + echo \"\"; + run partition_mmc_linux; + if test \$? -eq 1; then + echo \"[ERROR] Failed to create Linux partition table!\"; + echo \"\"; + echo \"Aborted.\"; + exit; + fi; + echo \"\"; + echo \"\"; + echo \">> Start installation Linux firmware files\"; + echo \"\"; + echo \"\"; + saveenv; + fastboot 0; +" + +uuu fb: ucmd saveenv + +uuu fb: acmd reset + +INSTALL_LINUX_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.boot.vfat" +INSTALL_RECOVERY_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.recovery.vfat" +INSTALL_ROOTFS_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.ext4" + +# Wait that target returns from reset +sleep 3 + +# Update Linux +uuu fb: flash -raw2sparse linux ${INSTALL_LINUX_FILENAME} + +# Update Recovery +uuu fb: flash -raw2sparse recovery ${INSTALL_RECOVERY_FILENAME} + +# Update Rootfs +uuu fb: flash -raw2sparse rootfs ${INSTALL_ROOTFS_FILENAME} + +# Configure u-boot to boot into recovery mode +uuu fb: ucmd setenv boot_recovery yes +uuu fb: ucmd setenv recovery_command wipe_update + +uuu fb: ucmd saveenv + +# Reset the target +uuu fb: acmd reset + +exit diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 78414f805..79b2feb04 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -25,11 +25,11 @@ if test -n "${module_ram}"; then setexpr module_has_bt ${module_has_bt} / 20000 if test "${module_has_bt}" = "1" && test -z "${disable_bt}"; then - setenv overlays _ov_som_bt_ccimx8mn.dtbo,${overlays} + setenv overlays _ov_som_bt_ccimx8m.dtbo,${overlays} fi if test "${module_has_wifi}" = "1" && test -z "${disable_wifi}"; then - setenv overlays _ov_som_wifi_ccimx8mn.dtbo,${overlays} + setenv overlays _ov_som_wifi_ccimx8m.dtbo,${overlays} fi if test "${som_hv}" = "1"; then @@ -39,7 +39,7 @@ fi # Apply quad overlay if the SOC type is "imx8mn" if test "${soc_type}" = "imx8mn"; then - setenv overlays _ov_som_quad_ccimx8mn.dtbo,${overlays} + setenv overlays _ov_som_quad_ccimx8m.dtbo,${overlays} fi # Apply DVK v1-v2 overlay if the board version is < 3