dualboot: change the way to determine if device is using nand or emmc

'environment' partition is not available in the ccmp15.

The solution suggested is read the "/proc/mounts" and check if the 'rootfs' is
'ubifs' mounted.

Related to commits 7c07b15370 and
678eaaf0fc4ce74e67682387e3465eb29659bd47

Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
Tatiana Leon 2023-03-21 17:55:59 +01:00
parent eca521f505
commit dba8dbdab4
1 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2021 by Digi International Inc.
# Copyright (C) 2021-2023 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
@ -16,14 +16,16 @@
dualboot_init () {
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
if [ -z "${ACTIVE_SYSTEM}" ]; then
if grep -qs environment /proc/mtd; then
MTD_BOOT_PART="$(fw_printenv -n mtdbootpart 2>/dev/null)"
fw_setenv active_system "${MTD_BOOT_PART}"
else
# Check if the rootfs is ubifs to determine if it is a nand or emmc device
NANDROOTFS="$(grep -qs '[[:blank:]]\+/[[:blank:]]\+ubifs.*' /proc/mounts 2>/dev/null && echo 1)"
if [ -z "${NANDROOTFS}" ]; then
BOOT_PART="$(fw_printenv -n mmcpart 2>/dev/null)"
BOOT_DEV="$(fw_printenv -n mmcbootdev 2>/dev/null)"
CURRENT_PART="$(sed -ne 's,PARTNAME=,,g;T;p' /sys/class/block/mmcblk"${BOOT_DEV}"p"${BOOT_PART}"/uevent)"
fw_setenv active_system "${CURRENT_PART}"
else
MTD_BOOT_PART="$(fw_printenv -n mtdbootpart 2>/dev/null)"
fw_setenv active_system "${MTD_BOOT_PART}"
fi
fi