meta-digi: add override files for ccimx93

These are just a verbatim copy of the ccimx8mm ones, so the project is
buildable. This file list should be revisited and adapted for the
ccimx93.

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2022-12-19 18:20:51 +01:00
parent ab52d0ec12
commit cfa581c958
10 changed files with 1134 additions and 0 deletions

View File

@ -0,0 +1,95 @@
#
# U-Boot bootscript for EMMC/SD images created by Yocto.
#
# As the first step in the boot script, check if we are using DualBoot and
# if an upgrade is available. This requires the script to change some variables
# and save them, while the rest of the script changes variables only temporarily
# without saving them.
# Dual boot update verification
if test "${dualboot}" = "yes"; then
if test "${upgrade_available}" = "1"; then
echo "Update detected; Booting new system in ${active_system} (try ${bootcount})"
else
if test "${active_system}" = "linux_a"; then
echo "Booting from system A"
part number mmc ${mmcbootdev} linux_a pi
setenv mmcpart ${pi}
# Save the partition index on variable rootfs_a_index
part number mmc ${mmcbootdev} rootfs_a rootfs_a_index
# Save the rootfs_a UUID into mmcroot_a
part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a
setenv mmcroot PARTUUID=${mmcroot_a}
else
echo "Booting from system B"
part number mmc ${mmcbootdev} linux_b pi
setenv mmcpart ${pi}
# Save the partition index on variable rootfs_b_index
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index
# Save the rootfs_b UUID into mmcroot_b
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b
setenv mmcroot PARTUUID=${mmcroot_b}
fi
fi
else
# 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
fi
# 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
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

View File

@ -0,0 +1,37 @@
#
# U-Boot bootscript for altbootcmd (dual boot fallback after retries)
#
# After an upgrade, active_system has changed. U-Boot tries to boot this system
# for a number of tries. If the limit is reached, altbootcmd is run instead.
# This is the script that it will run. It has to:
# * switch back to previous system
# * reset the firmware update flag
# * run the regular boot command
if test "${dualboot}" = "yes" && test "${upgrade_available}" = "1"; then
echo "## Update failed; Rolling back to previous version."
if test "${active_system}" = "linux_a"; then
setenv active_system linux_b
part number mmc ${mmcbootdev} linux_b linux_b_index
setexpr mmcpart ${linux_b_index}
# Save the partition index on variable rootfs_b_index
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index
# Save the rootfs_b UUID into mmcroot_b
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b
setenv mmcroot PARTUUID=${mmcroot_b}
else
setenv active_system linux_a
part number mmc ${mmcbootdev} linux_a linux_a_index
setexpr mmcpart ${linux_a_index}
# Save the partition index on variable rootfs_a_index
part number mmc ${mmcbootdev} rootfs_a rootfs_a_index
# Save the rootfs_a UUID into mmcroot_a
part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a
setenv mmcroot PARTUUID=${mmcroot_a}
fi
setenv upgrade_available
setenv bootcount 0
saveenv
fi
run bootcmd

View File

@ -0,0 +1,234 @@
#
# U-Boot script for installing Linux images created by Yocto from the SD
# card into the eMMC
#
# Reset temp variables
install_abort=0
BASEFILENAME=0
setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##.bin;
setenv INSTALL_MMCDEV 1
if test -z "${image-name}"; then
setenv image-name ##DEFAULT_IMAGE_NAME##
fi
GRAPHICAL_IMAGES="##GRAPHICAL_IMAGES##"
for g in ${GRAPHICAL_IMAGES}; do
if test "${image-name}" = "${g}"; then
BASEFILENAME="${image-name}-##GRAPHICAL_BACKEND##"
fi
done
if test "${BASEFILENAME}" = "0"; then
BASEFILENAME="${image-name}"
fi
setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.vfat
setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.vfat
setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.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 "${install_abort}" = "1"; then
echo "Aborted.";
exit;
fi
echo "############################################################"
echo "# Linux firmware install from micro SD #"
echo "############################################################"
echo ""
echo " This process will erase your eMMC and will install the following files"
echo " on the partitions of the eMMC."
echo ""
echo " PARTITION FILENAME"
echo " --------- --------"
echo " bootloader ${INSTALL_UBOOT_FILENAME}"
if test "${dualboot}" = "yes"; then
echo " linux_a ${INSTALL_LINUX_FILENAME}"
echo " linux_b ${INSTALL_LINUX_FILENAME}"
echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}"
echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}"
else
echo " linux ${INSTALL_LINUX_FILENAME}"
echo " recovery ${INSTALL_RECOVERY_FILENAME}"
echo " rootfs ${INSTALL_ROOTFS_FILENAME}"
fi
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
# 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 image ${INSTALL_UBOOT_FILENAME} (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
# - Restore 'dualboot' if previously set
# - Save the environment
# - Force on-the-fly updates to avoid possible verification errors
# - Partition the eMMC user data area for Linux
# - If Dual Boot
# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b
# - If Normal Boot:
# - Update the system partitions: linux, recovery, rootfs
# - Erase the 'update' partition
# - Configure recovery to wipe 'update' partition
# - Run 'recovery' and let the system boot after
setenv bootcmd "
env default -a;
setenv dualboot ${dualboot};
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;
if test \"\$\{dualboot\}\" = yes; then
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\";
echo \"\";
echo \"\";
update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_a!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\";
echo \"\";
echo \"\";
update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_b!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\";
echo \"\";
echo \"\";
update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_a partition!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\";
echo \"\";
echo \"\";
update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_b partition!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
else
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\";
echo \"\";
echo \"\";
update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on 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 file ${INSTALL_ROOTFS_FILENAME} on rootfs\";
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;
fi;
setenv otf-update;
saveenv;
echo \"\";
echo \"\";
echo \">> Firmware installation complete.\";
if test \"\$\{dualboot\}\" != yes; then
echo \"Rebooting into recovery mode for final deployment.\";
fi;
echo \"\";
echo \"\";
sleep 1;
reset;
"
saveenv
reset

View File

@ -0,0 +1,235 @@
#
# U-Boot script for installing Linux images created by Yocto from a USB stick
# into the eMMC
#
# Reset temp variables
install_abort=0
BASEFILENAME=0
setenv INSTALL_UBOOT_FILENAME imx-boot-##MACHINE##.bin;
setenv INSTALL_USBDEV 0
if test -z "${image-name}"; then
setenv image-name ##DEFAULT_IMAGE_NAME##
fi
GRAPHICAL_IMAGES="##GRAPHICAL_IMAGES##"
for g in ${GRAPHICAL_IMAGES}; do
if test "${image-name}" = "${g}"; then
BASEFILENAME="${image-name}-##GRAPHICAL_BACKEND##"
fi
done
if test "${BASEFILENAME}" = "0"; then
BASEFILENAME="${image-name}"
fi
setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.vfat
setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.vfat
setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.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 "${install_abort}" = "1"; then
echo "Aborted.";
exit;
fi
echo "############################################################"
echo "# Linux firmware install from USB #"
echo "############################################################"
echo ""
echo " This process will erase your eMMC and will install the following files"
echo " on the partitions of the eMMC."
echo ""
echo " PARTITION FILENAME"
echo " --------- --------"
echo " bootloader ${INSTALL_UBOOT_FILENAME}"
if test "${dualboot}" = "yes"; then
echo " linux_a ${INSTALL_LINUX_FILENAME}"
echo " linux_b ${INSTALL_LINUX_FILENAME}"
echo " rootfs_a ${INSTALL_ROOTFS_FILENAME}"
echo " rootfs_b ${INSTALL_ROOTFS_FILENAME}"
else
echo " linux ${INSTALL_LINUX_FILENAME}"
echo " recovery ${INSTALL_RECOVERY_FILENAME}"
echo " rootfs ${INSTALL_ROOTFS_FILENAME}"
fi
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
# 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 image ${INSTALL_UBOOT_FILENAME} (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 usb ${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
# - Restore 'dualboot' if previously set
# - Save the environment
# - Force on-the-fly updates to avoid possible verification errors
# - Partition the eMMC user data area for Linux
# - If Dual Boot
# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b
# - If Normal Boot:
# - Update the system partitions: linux, recovery, rootfs
# - Erase the 'update' partition
# - Configure recovery to wipe 'update' partition
# - Run 'recovery' and let the system boot after
setenv bootcmd "
env default -a;
setenv dualboot ${dualboot};
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;
if test \"\$\{dualboot\}\" = yes; then
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\";
echo \"\";
echo \"\";
update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_a!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\";
echo \"\";
echo \"\";
update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_b!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\";
echo \"\";
echo \"\";
update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_a partition!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\";
echo \"\";
echo \"\";
update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_b partition!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
else
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\";
echo \"\";
echo \"\";
update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on 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 file ${INSTALL_ROOTFS_FILENAME} on rootfs\";
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;
fi;
setenv otf-update;
saveenv;
echo \"\";
echo \"\";
echo \">> Firmware installation complete.\";
if test \"\$\{dualboot\}\" != yes; then
echo \"Rebooting into recovery mode for final deployment.\";
fi;
echo \"\";
echo \"\";
sleep 1;
reset;
"
saveenv
reset

View File

@ -0,0 +1,277 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2020-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
#
# U-Boot script for installing Linux images created by Yocto
#
# Exit on any error
set -e
# Parse uuu cmd output
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 <dey-image-name> Image name that prefixes the image filenames, such as 'dey-image-qt', "
echo " 'dey-image-webkit', 'core-image-base'..."
echo " Defaults to '##DEFAULT_IMAGE_NAME##' if not provided."
echo " -n No wait. Skips 10 seconds delay to stop script."
echo " -u <u-boot-filename> U-Boot filename."
echo " Auto-determined by variant if not provided."
exit 2
}
# Update a partition
# Params:
# 1. partition
# 2. file
part_update()
{
echo "\033[36m"
echo "====================================================================================="
echo "Updating '${1}' partition with file: ${2}"
echo "====================================================================================="
echo "\033[0m"
if [ "${1}" = "bootloader" ]; then
uuu fb: flash "${1}" "${2}"
else
uuu fb: flash -raw2sparse "${1}" "${2}"
fi
}
clear
echo "############################################################"
echo "# Linux firmware install through USB OTG #"
echo "############################################################"
# Command line admits the following parameters:
# -u <u-boot-filename>
# -i <image-name>
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
# Enable the redirect support to get u-boot variables values
uuu fb: ucmd setenv stdout serial,fastboot
# Check if dualboot variable is active
dualboot=$(getenv "dualboot")
if [ "${dualboot}" = "yes" ]; then
DUALBOOT=true;
fi
# remove redirect
uuu fb: ucmd setenv stdout serial
echo ""
echo "Determining image files to use..."
# Determine U-Boot file to program basing on SOM's SOC type (linked to bus width)
if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then
INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##.bin"
fi
# Determine linux, recovery, and rootfs image filenames to update
if [ -z "${IMAGE_NAME}" ]; then
IMAGE_NAME="##DEFAULT_IMAGE_NAME##"
fi
GRAPHICAL_IMAGES="##GRAPHICAL_IMAGES##"
for g in ${GRAPHICAL_IMAGES}; do
if [ "${IMAGE_NAME}" = "${g}" ]; then
BASEFILENAME="${IMAGE_NAME}-##GRAPHICAL_BACKEND##"
fi
done
if [ -z "${BASEFILENAME}" ]; then
BASEFILENAME="${IMAGE_NAME}"
fi
INSTALL_LINUX_FILENAME="${BASEFILENAME}-##MACHINE##.boot.vfat"
INSTALL_RECOVERY_FILENAME="${BASEFILENAME}-##MACHINE##.recovery.vfat"
INSTALL_ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.ext4"
COMPRESSED_ROOTFS_IMAGE="${INSTALL_ROOTFS_FILENAME}.gz"
# If the rootfs image is compressed, make sure to decompress it before the update
if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ ! -f ${INSTALL_ROOTFS_FILENAME} ]; then
echo "\033[36m"
echo "====================================================================================="
echo "Decompressing rootfs image '${COMPRESSED_ROOTFS_IMAGE}'"
echo "====================================================================================="
echo "\033[0m"
gzip -d -k -f "${COMPRESSED_ROOTFS_IMAGE}"
fi
# Verify existance of files before starting the update
FILES="${INSTALL_UBOOT_FILENAME} ${INSTALL_LINUX_FILENAME} ${INSTALL_RECOVERY_FILENAME} ${INSTALL_ROOTFS_FILENAME}"
for f in ${FILES}; do
if [ ! -f ${f} ]; then
echo "\033[31m[ERROR] Could not find file '${f}'\033[0m"
ABORT=true
fi
done;
[ "${ABORT}" = true ] && exit 1
# parts names
LINUX_NAME="linux"
RECOVERY_NAME="recovery"
ROOTFS_NAME="rootfs"
# Print warning about storage media being deleted
if [ "${NOWAIT}" != true ]; then
WAIT=10
printf "\n"
printf " ====================\n"
printf " = IMPORTANT! =\n"
printf " ====================\n"
printf " This process will erase your eMMC and will install the following files\n"
printf " on the partitions of the eMMC.\n"
printf "\n"
printf " PARTITION\tFILENAME\n"
printf " ---------\t--------\n"
printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n"
if [ "${DUALBOOT}" = true ]; then
printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n"
printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n"
printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n"
printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n"
else
printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n"
printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n"
printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n"
fi
printf "\n"
printf " Press CTRL+C now if you wish to abort.\n"
printf "\n"
while [ ${WAIT} -gt 0 ]; do
printf "\r Update process starts in %d " ${WAIT}
sleep 1
WAIT=$(( ${WAIT} - 1 ))
done
printf "\r \n"
printf " Starting update process\n"
fi
# Set fastboot buffer address to $loadaddr, just in case
uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
# Skip user confirmation for U-Boot update
uuu fb: ucmd setenv forced_update 1
# Update U-Boot
part_update "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;
setenv dualboot \${dualboot};
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
# Wait for the target to reset
sleep 3
# Restart fastboot with the latest MMC partition configuration
uuu fb: ucmd setenv fastboot_dev sata
uuu fb: ucmd setenv fastboot_dev mmc
# Set fastboot buffer address to $loadaddr, just in case
uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
if [ "${DUALBOOT}" = true ]; then
# Update Linux A
part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}"
# Update Linux B
part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}"
# Update Rootfs A
part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}"
# Update Rootfs B
part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}"
else
# Update Linux
part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}"
# Update Recovery
part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}"
# Update Rootfs
part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}"
fi
# If the rootfs image was originally compressed, remove the uncompressed image
if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then
rm -f "${INSTALL_ROOTFS_FILENAME}"
fi
if [ "${DUALBOOT}" != true ]; then
# Configure u-boot to boot into recovery mode
uuu fb: ucmd setenv boot_recovery yes
uuu fb: ucmd setenv recovery_command wipe_update
fi
uuu fb: ucmd saveenv
# Reset the target
uuu fb: acmd reset
echo "\033[32m"
echo "============================================================="
echo "Done! Wait for the target to complete first boot process."
echo "============================================================="
echo "\033[0m"
exit

View File

@ -0,0 +1,18 @@
ACTION!="add|change|move|bind", GOTO="mm_net_device_blacklist_end"
# ModemManager documentation states that the best practice is to use the DEVPATH
# this way rather than other rules such as KERNEL, so be careful when modifying
# Remove Ethernet interfaces from ModemManager probing
SUBSYSTEM=="net", DEVPATH=="/devices/platform/30be0000.ethernet*", ENV{ID_MM_CANDIDATE}="0", ENV{ID_MM_DEVICE_IGNORE}="1"
# Remove SPI-to-CAN interface from ModemManager probing
SUBSYSTEM=="net", DEVPATH=="/devices/platform/30840000.ecspi*", ENV{ID_MM_CANDIDATE}="0", ENV{ID_MM_DEVICE_IGNORE}="1"
# Remove MMC interfaces from ModemManager probing
SUBSYSTEM=="net", DEVPATH=="/devices/platform/30b40000.mmc*", ENV{ID_MM_CANDIDATE}="0", ENV{ID_MM_DEVICE_IGNORE}="1"
# Remove PCIe interfaces from ModemManager probing
SUBSYSTEM=="net", DEVPATH=="/devices/platform/33800000.pcie*", ENV{ID_MM_CANDIDATE}="0", ENV{ID_MM_DEVICE_IGNORE}="1"
LABEL="mm_net_device_blacklist_end"

View File

@ -0,0 +1,3 @@
#s_type n_type(hex) s_code n_code value description
EV_KEY 0x01 KEY_SLEEP 142 1 pswitch-standby
EV_KEY 0x01 KEY_POWER 116 1 pswitch-poweroff

View File

@ -0,0 +1,116 @@
#!/bin/sh
#===============================================================================
#
# standby
#
# Copyright (C) 2020 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: suspend system to RAM
#
#===============================================================================
scriptname="$(basename $(readlink -f ${0}))"
syspower="/sys/power/state"
lockfile="/var/lock/${scriptname}.lock"
lockfd="9"
BT_INIT="/etc/init.d/bluetooth-init"
BT_DAEMON="/etc/init.d/bluetooth"
NM_DAEMON="/etc/init.d/networkmanager"
usage() {
printf "\nSuspend system to RAM memory\n"
printf "\nUsage: ${scriptname} [OPTIONS]\n
-h Show this help
\n"
}
suspend_interfaces() {
# Stop NetworkManager before suspend
${NM_DAEMON} stop
# Suspend wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do
ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}"
done
grep -qs '^wlan' /proc/modules && rmmod wlan
fi
# Suspend bluetooth interface
if [ -d "/proc/device-tree/bluetooth" ]; then
hciconfig hci0 2>&1 | grep -qs UP && up_bt_on_resume="1"
${BT_DAEMON} stop >/dev/null
${BT_INIT} stop >/dev/null
fi
}
resume_interfaces() {
# Resume wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
# Trigger wireless module loading event, and wait until the interface exists
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A"
timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
# Bring up the interfaces that were bring down on suspend
for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do
grep -qs "^${i}" /var/run/ifstate || ifup "${i}"
done
fi
# Resume bluetooth interface
if [ -d "/proc/device-tree/bluetooth" ]; then
if [ -n "${up_bt_on_resume}" ]; then
${BT_INIT} start >/dev/null
${BT_DAEMON} start >/dev/null
fi
fi
# Resume NetworkManager after suspend
${NM_DAEMON} start
}
enter_critical_section() {
# Create lock file
eval "exec ${lockfd}>${lockfile}"
# Acquire the lock in non blocking mode. Otherwise, additional calls
# to the script will be queued and the system will endlessly go in
# and out of suspend to ram
flock -n "${lockfd}" || exit 0
}
exit_critical_section() {
# Release the lock
flock -u "${lockfd}"
}
while getopts "h" c; do
case "${c}" in
h) usage; exit;;
esac
done
if [ -f "${syspower}" ]; then
# Avoid running multiple instances of this script in parallel
enter_critical_section
# Pre-suspend actions
suspend_interfaces
# Suspend the device
printf "mem" > ${syspower}
# Post-resume actions
resume_interfaces
exit_critical_section
else
printf "\n[ERROR] File ${syspower} not found\n\n"
fi

View File

@ -0,0 +1,83 @@
#!/bin/sh
#===============================================================================
#
# standby-actions
#
# Copyright (C) 2020 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: manage interfaces before suspending and after resuming from
# suspend
#
#===============================================================================
if [ "${1}" == "pre" ]; then
# Stop NetworkManager before suspend
systemctl stop NetworkManager
# Suspend wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do
ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}"
done
echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces
grep -qs '^wlan' /proc/modules && rmmod wlan
fi
# Suspend bluetooth interface
if [ -d "/proc/device-tree/bluetooth" ]; then
hciconfig hci0 2>&1 | grep -qs UP && touch /tmp/up_bt_on_resume
systemctl stop bluetooth
systemctl stop bluetooth-init
fi
# Configure Power LED for blinking in standby
if [ -d "/sys/class/leds/power:green" ]; then
# Configure LED for blinking
echo timer > /sys/class/leds/power\:green/trigger
# Turn LED on at max brightness
echo 19 > /sys/class/leds/power\:green/brightness
# Configure blinking timings
echo 100 > /sys/class/leds/power\:green/delay_on
echo 1000 > /sys/class/leds/power\:green/delay_off
fi
elif [ "${1}" == "post" ]; then
# Resume wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
# Trigger wireless module loading event, and wait until the interface exists
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A"
timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
# Bring up the interfaces that were brought down on suspend
for i in $(cat /tmp/suspend_wlan_ifaces | tr ' ' '\n' | sort); do
grep -qs "^${i}" /var/run/ifstate || ifup "${i}"
done
rm -f /tmp/suspend_wlan_ifaces
fi
# Resume NetworkManager after suspend
systemctl start NetworkManager
# Resume bluetooth interface
if [ -d "/proc/device-tree/bluetooth" ]; then
if [ -e "/tmp/up_bt_on_resume" ]; then
systemctl start bluetooth-init
systemctl start bluetooth
rm -f /tmp/up_bt_on_resume
fi
fi
# Configure Power LED solid on after resume
if [ -d "/sys/class/leds/power:green" ]; then
# Reset LED settings by writing 0 to brigtness descriptor
echo 0 > /sys/class/leds/power\:green/brightness
# Turn LED on at max brightness
echo 19 > /sys/class/leds/power\:green/brightness
fi
fi

View File

@ -0,0 +1,36 @@
[board]
model = Digi International ConnectCore 8M Mini DVK.
[GPIO]
# USER LED1
USER_LED = mca-gpio,12
USER_LED1 = mca-gpio,12
# USER_LED2
USER_LED2 = mca-gpio,18
# USER_LED3
USER_LED3 = gpio2,19
# USER BUTTON1
USER_BUTTON = mca-gpio,10
USER_BUTTON1 = mca-gpio,10
# USER BUTTON2
USER_BUTTON2 = gpio2,20
[I2C]
# I2C-4 on Expansion connector.
DEFAULT_I2C_BUS = 4
[PWM]
# PWM0 channel 1 USER_LED1.
DEFAULT_PWM = 0,1
[ADC]
# MCA_IO1 (channel 1) at XBEE1_UART_TX. Not enabled by default.
DEFAULT_ADC = 0,1