From 7f6479988cca603dcd1a4384b07075996e0a2658 Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 5 Sep 2019 11:26:58 -0500 Subject: Make /etc/init.d/config support eMMC, and eliminate MTD nand flash requirement --- recipes-core/multitech/config/config.init | 36 +++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'recipes-core/multitech') diff --git a/recipes-core/multitech/config/config.init b/recipes-core/multitech/config/config.init index d821f4c..27b067f 100644 --- a/recipes-core/multitech/config/config.init +++ b/recipes-core/multitech/config/config.init @@ -41,10 +41,21 @@ mount_config() { mkdir -p ${CONFIG_DIR} mount ${CONFIG_DIR} - # Prepare flash for JFFS2 if mount fails + # Prepare flash for JFFS2 or EXT4 if mount fails if [ $? -ne 0 ]; then echo "Creating ${CONFIG_DIR}" - flash_erase -j ${CONFIG_MTDC} 0 0 + fs=$(mount -fvn ${CONFIG_DIR}) + if [[ $fs =~ [[:space:]]*(/dev/(...)[^[:space:]]*) ]] ; then + if [[ ${BASH_REMATCH[2]} == mmc ]] ; then + # One more check for empty + mdev="${BASH_REMATCH[1]}" + if [[ $(dd if=$mdev count=4 2>/dev/null | tr -d '\0' | wc -c) == 0 ]] ; then + mkfs.ext4 -O 64bit ${mdev} + fi + else + flash_erase -j ${CONFIG_MTDC} 0 0 + fi + fi mount ${CONFIG_DIR} fi } @@ -54,10 +65,21 @@ mount_oem() { mkdir -p ${OEM_DIR} mount ${OEM_DIR} - # Prepare flash for JFFS2 if mount fails + # Prepare flash for JFFS2 or EXT4 if mount fails + # Prepare flash for JFFS2 or EXT4 if mount fails if [ $? -ne 0 ]; then echo "Creating ${OEM_DIR}" - flash_erase -j ${OEM_MTDC} 0 0 + fs=$(mount -fvn ${OEM_DIR}) + if [[ $fs =~ [[:space:]]*(/dev/(...)[^[:space:]]*) ]] ; then + if [[ ${BASH_REMATCH[2]} == mmc ]] ; then + mdev="${BASH_REMATCH[1]}" + if [[ $(dd if=$mdev count=4 2>/dev/null | tr -d '\0' | wc -c) == 0 ]] ; then + mkfs.ext4 -O 64bit ${mdev} + fi + else + flash_erase -j ${OEM_MTDC} 0 0 + fi + fi mount ${OEM_DIR} fi } @@ -65,15 +87,15 @@ mount_oem() { case $1 in start) # mount config if not already mounted - if ! grep -q "^${CONFIG_MTDB} " /proc/mounts; then + if ! grep -q " ${CONFIG_DIR} " /proc/mounts; then mount_config else echo "$CONFIG_DIR already mounted" fi # mount oem if specified in /etc/fstab and it isn't already mounted - if grep -qE "^${OEM_MTDB}\s+${OEM_DIR}\s+" /etc/fstab; then - if ! grep -q "^${OEM_MTDB} " /proc/mounts; then + if mount -fvn "${OEM_DIR}" ; then + if ! grep -q " ${OEM_DIR} " /proc/mounts; then mount_oem else echo "$OEM_DIR already mounted" -- cgit v1.2.3