From f1f3af5e666841f5cab99b0185701426053d70c3 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 18 May 2021 11:22:18 +0200 Subject: [PATCH] u-boot-dey: improve uuu install script with options Previously, this script only allowed the U-Boot filename as parameter. This commit makes use of getopts() to pass the following options to the script: -h, for help -i, to pass the dey image name that prefixes the firmware filenames -n, to skip the 10 seconds delay that allow you to cancel the process -u, to pass the U-Boot filename The default image name (if none passed) keeps being 'dey-image-qt' but the new option allows reusing this script to install dey-image-webkit or dey-image-aws images. Signed-off-by: Hector Palacios https://jira.digi.com/browse/DEL-7385 --- .../ccimx6ulsbc/install_linux_fw_uuu.sh | 117 ++++++++----- .../ccimx6ulstarter/install_linux_fw_uuu.sh | 117 ++++++++----- .../ccimx8mm-dvk/install_linux_fw_uuu.sh | 72 +++++--- .../ccimx8mn-dvk/install_linux_fw_uuu.sh | 72 +++++--- .../ccimx8x-sbc-pro/install_linux_fw_uuu.sh | 164 ++++++++++-------- 5 files changed, 342 insertions(+), 200 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/install_linux_fw_uuu.sh index 78408f70a..c7d0abc75 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2020 by Digi International Inc. +# Copyright (C) 2020-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -13,6 +13,10 @@ # Script to flash Yocto build artifacts over USB to the target. #=============================================================================== # set -x + +# +# U-Boot script for installing Linux images created by Yocto into the NAND +# clear # Parse uuu cmd output @@ -21,6 +25,21 @@ getenv() uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" } +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to 'dey-image-qt' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} + # Update a NAND partition # Params: # 1. partition @@ -41,28 +60,37 @@ nand_update() uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} } -# -# U-Boot script for installing Linux images created by Yocto into the NAND -# -echo "############################################################" -echo "# Linux firmware install through USB OTG #" -echo "############################################################" -echo "" -echo " This process will erase your NAND and will install a new" -echo " U-Boot and Linux firmware images on the NAND." -echo "" -echo " Press CTRL+C now if you wish to abort or wait 10 seconds" -echo " to continue." +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done -sleep 10 +if [ ! "${NOWAIT}" = true ]; then + echo "############################################################" + echo "# Linux firmware install through USB OTG #" + echo "############################################################" + echo "" + echo " This process will erase your NAND and will install a new" + echo " U-Boot and Linux firmware images on the NAND." + echo "" + echo " Press CTRL+C now if you wish to abort or wait 10 seconds" + echo " to continue." + sleep 10 +fi # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot -# Get U-Boot file name from cmdline when passed -if [ -n "$1" ]; then - INSTALL_UBOOT_FILENAME="$1" -else +# Determine U-Boot filename if not provided +if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then module_variant=$(getenv "module_variant") # Determine U-Boot file to program basing on SOM's variant if [ -n "$module_variant" ]; then @@ -77,33 +105,33 @@ else INSTALL_UBOOT_FILENAME="u-boot-ccimx6ulsbc.imx" fi fi + + # u-boot when the checked value is empty. + if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then + true + else + echo "" + echo "[ERROR] Cannot determine U-Boot file for this module!" + echo "" + echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" + echo " - For a SOM with 1GB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulsbc1GB.imx" + echo " - For a SOM with 512MB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulsbc512MB.imx" + echo " - For a SOM with 256MB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulsbc.imx" + echo "" + echo "2. Run the install script again." + echo "" + echo "Aborted" + echo "" + exit + fi fi # remove redirect uuu fb: ucmd setenv stdout serial -# u-boot when the checked value is empty. -if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then - true -else - echo "" - echo "[ERROR] Cannot determine U-Boot file for this module!" - echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a SOM with 1GB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulsbc1GB.imx" - echo " - For a SOM with 512MB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulsbc512MB.imx" - echo " - For a SOM with 256MB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulsbc.imx" - echo "" - echo "2. Run the install script again." - echo "" - echo "Aborted" - echo "" - exit -fi - # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} @@ -134,9 +162,12 @@ uuu fb: ucmd setenv bootcmd " uuu fb: ucmd saveenv uuu fb: acmd reset -INSTALL_LINUX_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulsbc.boot.ubifs" -INSTALL_RECOVERY_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulsbc.recovery.ubifs" -INSTALL_ROOTFS_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulsbc.ubifs" +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="dey-image-qt" +fi +INSTALL_LINUX_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulsbc.boot.ubifs" +INSTALL_RECOVERY_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulsbc.recovery.ubifs" +INSTALL_ROOTFS_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulsbc.ubifs" # Wait for the target to reset sleep 3 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/install_linux_fw_uuu.sh index 89346f19c..23a517e0a 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2020 by Digi International Inc. +# Copyright (C) 2020-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -13,6 +13,10 @@ # Script to flash Yocto build artifacts over USB to the target. #=============================================================================== # set -x + +# +# U-Boot script for installing Linux images created by Yocto into the NAND +# clear # Parse uuu cmd output @@ -21,6 +25,21 @@ getenv() uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" } +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to 'core-image-base' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} + # Update a NAND partition # Params: # 1. partition @@ -41,28 +60,37 @@ nand_update() uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} } -# -# U-Boot script for installing Linux images created by Yocto into the NAND -# -echo "############################################################" -echo "# Linux firmware install through USB OTG #" -echo "############################################################" -echo "" -echo " This process will erase your NAND and will install a new" -echo " U-Boot and Linux firmware images on the NAND." -echo "" -echo " Press CTRL+C now if you wish to abort or wait 10 seconds" -echo " to continue." +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done -sleep 10 +if [ ! "${NOWAIT}" = true ]; then + echo "############################################################" + echo "# Linux firmware install through USB OTG #" + echo "############################################################" + echo "" + echo " This process will erase your NAND and will install a new" + echo " U-Boot and Linux firmware images on the NAND." + echo "" + echo " Press CTRL+C now if you wish to abort or wait 10 seconds" + echo " to continue." + sleep 10 +fi # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot -# Get U-Boot file name from cmdline when passed -if [ -n "$1" ]; then - INSTALL_UBOOT_FILENAME="$1" -else +# Determine U-Boot filename if not provided +if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then module_variant=$(getenv "module_variant") # Determine U-Boot file to program basing on SOM's variant if [ -n "$module_variant" ]; then @@ -77,33 +105,33 @@ else INSTALL_UBOOT_FILENAME="u-boot-ccimx6ulstarter.imx" fi fi + + # u-boot when the checked value is empty. + if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then + true + else + echo "" + echo "[ERROR] Cannot determine U-Boot file for this module!" + echo "" + echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" + echo " - For a SOM with 1GB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulstarter1GB.imx" + echo " - For a SOM with 512MB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulstarter512MB.imx" + echo " - For a SOM with 256MB DDR3, run:" + echo " => ./install_linux_fs_uuu.sh -u u-boot-ccimx6ulstarter.imx" + echo "" + echo "2. Run the install script again." + echo "" + echo "Aborted" + echo "" + exit + fi fi # remove redirect uuu fb: ucmd setenv stdout serial -# u-boot when the checked value is empty. -if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then - true -else - echo "" - echo "[ERROR] Cannot determine U-Boot file for this module!" - echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a SOM with 1GB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulstarter1GB.imx" - echo " - For a SOM with 512MB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulstarter512MB.imx" - echo " - For a SOM with 256MB DDR3, run:" - echo " => ./install_linux_fs_uuu.sh u-boot-ccimx6ulstarter.imx" - echo "" - echo "2. Run the install script again." - echo "" - echo "Aborted" - echo "" - exit -fi - # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} @@ -134,9 +162,12 @@ uuu fb: ucmd setenv bootcmd " uuu fb: ucmd saveenv uuu fb: acmd reset -INSTALL_LINUX_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulstarter.boot.ubifs" -INSTALL_RECOVERY_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulstarter.recovery.ubifs" -INSTALL_ROOTFS_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx6ulstarter.ubifs" +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="core-image-base" +fi +INSTALL_LINUX_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulstarter.boot.ubifs" +INSTALL_RECOVERY_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulstarter.recovery.ubifs" +INSTALL_ROOTFS_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx6ulstarter.ubifs" # Wait for the target to reset sleep 3 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 index 73f676a80..755847497 100755 --- 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 @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh #=============================================================================== # -# Copyright (C) 2021 by Digi International Inc. +# Copyright (C) 2020-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -14,35 +14,58 @@ #=============================================================================== # set -x +# +# U-Boot script for installing Linux images created by Yocto into the eMMC +# clear # Parse uuu cmd output -function getenv() +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 -# +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to 'dey-image-qt' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} -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." +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done -# Get U-Boot file name from cmdline when passed -if [ -n "$1" ]; then - INSTALL_UBOOT_FILENAME="$1" +if [ ! "${NOWAIT}" = true ]; then + 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." + sleep 10 fi -sleep 10 - if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then INSTALL_UBOOT_FILENAME="imx-boot-ccimx8mm-dvk.bin" fi @@ -91,9 +114,12 @@ 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" +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="dey-image-qt" +fi +INSTALL_LINUX_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.boot.vfat" +INSTALL_RECOVERY_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.recovery.vfat" +INSTALL_ROOTFS_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mm-dvk.ext4" # Wait that target returns from reset sleep 3 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_uuu.sh index 920860858..733660215 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh #=============================================================================== # -# Copyright (C) 2020 by Digi International Inc. +# Copyright (C) 2020-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -14,35 +14,58 @@ #=============================================================================== # set -x +# +# U-Boot script for installing Linux images created by Yocto into the eMMC +# clear # Parse uuu cmd output -function getenv() +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 -# +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to 'dey-image-qt' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} -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." +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done -# Get U-Boot file name from cmdline when passed -if [ -n "$1" ]; then - INSTALL_UBOOT_FILENAME="$1" +if [ ! "${NOWAIT}" = true ]; then + 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." + sleep 10 fi -sleep 10 - if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then INSTALL_UBOOT_FILENAME="imx-boot-ccimx8mn-dvk.bin" fi @@ -91,9 +114,12 @@ uuu fb: ucmd saveenv uuu fb: acmd reset -INSTALL_LINUX_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.boot.vfat" -INSTALL_RECOVERY_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.recovery.vfat" -INSTALL_ROOTFS_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.ext4" +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="dey-image-qt" +fi +INSTALL_LINUX_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.boot.vfat" +INSTALL_RECOVERY_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.recovery.vfat" +INSTALL_ROOTFS_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8mn-dvk.ext4" # Wait that target returns from reset sleep 3 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/install_linux_fw_uuu.sh index 91fc2c772..91288978f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/install_linux_fw_uuu.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/bin/sh #=============================================================================== # -# Copyright (C) 2020 by Digi International Inc. +# Copyright (C) 2020-2021 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -14,35 +14,58 @@ #=============================================================================== # set -x +# +# U-Boot script for installing Linux images created by Yocto into the eMMC +# clear # Parse uuu cmd output -function getenv() +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 -# +show_usage() +{ + echo "Usage: $0 [options]" + echo "" + echo " Options:" + echo " -h Show this help." + echo " -i Image name that prefixes the image filenames, such as 'dey-image-qt', " + echo " 'dey-image-webkit', 'core-image-base'..." + echo " Defaults to 'dey-image-qt' if not provided." + echo " -n No wait. Skips 10 seconds delay to stop script." + echo " -u U-Boot filename." + echo " Auto-determined by variant if not provided." + exit 2 +} -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." +# Command line admits the following parameters: +# -u +# -i +while getopts 'hi:nu:' c +do + case $c in + h) show_usage ;; + i) IMAGE_NAME=${OPTARG} ;; + n) NOWAIT=true ;; + u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; + esac +done -# Get U-Boot file name from cmdline when passed -if [ -n "$1" ]; then - INSTALL_UBOOT_FILENAME="$1" +if [ ! "${NOWAIT}" = true ]; then + 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." + sleep 10 fi -sleep 10 - # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot @@ -54,61 +77,63 @@ if [ -z "${soc_rev}" ]; then fi # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) -bus_width="32bit" +if [ -z ${INSTALL_UBOOT_FILENAME} ]; then + bus_width="32bit" -soc_type=$(getenv "soc_type") -if [ "$soc_type" == "imx8dx" ]; then - bus_width="16bit" -fi + soc_type=$(getenv "soc_type") + if [ "$soc_type" = "imx8dx" ]; then + bus_width="16bit" + fi -module_ram=$(getenv "module_ram") -if [ -z "${module_ram}" ]; then - module_variant=$(getenv "module_variant") - # Determine U-Boot file to program basing on SOM's variant - if [ -n "$module_variant" ]; then - if [ "$module_variant" == "0x01" ] || \ - [ "$module_variant" == "0x04" ] || \ - [ "$module_variant" == "0x05" ]; then - module_ram="1GB" - elif [ "$module_variant" == "0x02" ] || \ - [ "$module_variant" == "0x03" ]; then - module_ram="2GB" - else - module_ram="512MB" + module_ram=$(getenv "module_ram") + if [ -z "${module_ram}" ]; then + module_variant=$(getenv "module_variant") + # Determine U-Boot file to program basing on SOM's variant + if [ -n "$module_variant" ]; then + if [ "$module_variant" == "0x01" ] || \ + [ "$module_variant" == "0x04" ] || \ + [ "$module_variant" == "0x05" ]; then + module_ram="1GB" + elif [ "$module_variant" == "0x02" ] || \ + [ "$module_variant" == "0x03" ]; then + module_ram="2GB" + else + module_ram="512MB" + fi + INSTALL_UBOOT_FILENAME="imx-boot-ccimx8x-sbc-pro-${soc_rev}-${module_ram}_${bus_width}.bin" fi + else INSTALL_UBOOT_FILENAME="imx-boot-ccimx8x-sbc-pro-${soc_rev}-${module_ram}_${bus_width}.bin" fi -else - INSTALL_UBOOT_FILENAME="imx-boot-ccimx8x-sbc-pro-${soc_rev}-${module_ram}_${bus_width}.bin" + + # U-Boot when the checked value is empty. + if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then + true + else + echo "" + echo "[ERROR] Cannot determine U-Boot file for this module!" + echo "" + echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" + echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fs_uuu.sh -u imx-boot-ccimx8x-sbc-pro-${soc_rev}-1GB_32bit.bin" + echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" + echo " => ./install_linux_fs_uuu.sh -u imx-boot-ccimx8x-sbc-pro-${soc_rev}-2GB_32bit.bin" + echo " - For a DualX CPU with 1GB LPDDR4, run:" + echo " => ./install_linux_fs_uuu.sh -u imx-boot-ccimx8x-sbc-pro-${soc_rev}-1GB_16bit.bin" + echo " - For a DualX CPU with 512MB LPDDR4, run:" + echo " => ./install_linux_fs_uuu.sh -u imx-boot-ccimx8x-sbc-pro-${soc_rev}-512MB_16bit.bin" + echo "" + echo "2. Run the install script again." + echo "" + echo "Aborted" + echo "" + exit + fi fi # remove redirect uuu fb: ucmd setenv stdout serial -# u-boot when the checked value is empty. -if [ -n "${INSTALL_UBOOT_FILENAME}" ]; then - true -else - echo "" - echo "[ERROR] Cannot determine U-Boot file for this module!" - echo "" - echo "1. Add U-boot file name, depending on your ConnectCore 8X variant, to script command line:" - echo " - For a QuadXPlus CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fs_uuu.sh imx-boot-ccimx8x-sbc-pro-${soc_rev}-1GB_32bit.bin" - echo " - For a QuadXPlus CPU with 2GB LPDDR4, run:" - echo " => ./install_linux_fs_uuu.sh imx-boot-ccimx8x-sbc-pro-${soc_rev}-2GB_32bit.bin" - echo " - For a DualX CPU with 1GB LPDDR4, run:" - echo " => ./install_linux_fs_uuu.sh imx-boot-ccimx8x-sbc-pro-${soc_rev}-1GB_16bit.bin" - echo " - For a DualX CPU with 512MB LPDDR4, run:" - echo " => ./install_linux_fs_uuu.sh imx-boot-ccimx8x-sbc-pro-${soc_rev}-512MB_16bit.bin" - echo "" - echo "2. Run the install script again." - echo "" - echo "Aborted" - echo "" - exit -fi - # Skip user confirmation for U-Boot update uuu fb: ucmd setenv forced_update 1 @@ -153,9 +178,12 @@ uuu fb: ucmd saveenv uuu fb: acmd reset -INSTALL_LINUX_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.boot.vfat" -INSTALL_RECOVERY_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.recovery.vfat" -INSTALL_ROOTFS_FILENAME="dey-image-qt-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.ext4" +if [ -z "${IMAGE_NAME}" ]; then + IMAGE_NAME="dey-image-qt" +fi +INSTALL_LINUX_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.boot.vfat" +INSTALL_RECOVERY_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.recovery.vfat" +INSTALL_ROOTFS_FILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##-ccimx8x-sbc-pro.ext4" # Wait that target returns from reset sleep 3