This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM572X: Flashing eMMC

Hello,

I am trying to flash eMMC on AM57xx evm, using steps available on below link:

http://processors.wiki.ti.com/index.php/Linux_Core_U-Boot_User's_Guide#Partitioning_eMMC_from_U-Boot

but I dont't know how to create rootfs.ext4 file to flash it on emmc. Also I would like to know if there is any other simple steps by which I can flash eMMC. I have tried to follow many wiki links, but did not get success yet.

 

  • Can you please describe what problem you see.
  • Hi Biser,
    Sorry, I have update my question.
  • Hello,

    Is there any update on this issue?

  • Hi,

    Have a look at the following script for DRA7xx devices (taken from GLSDK7.03): 

    mk-eMMC-boot.txt
    #! /bin/sh
    # Script to create bootable eMMC for OMAP5/DRA7xx evm.
    #
    # Author: Brijesh Singh, Texas Instruments Inc.
    #       : Adapted for dra7xx-evm by Nikhil Devshatwar, Texas Instruments Inc.
    #       : Adapted for bootable eMMC by Alaganraj, Texas Instruments Inc.
    #
    # Licensed under terms of GPLv2
    #
    
    VERSION="0.1"
    mmc_dev="/dev/mmcblk0"
    
    execute ()
    {
        $* >/dev/null
        if [ $? -ne 0 ]; then
            echo
            echo "ERROR: executing $*"
            echo
            exit 1
        fi
    }
    
    version ()
    {
      echo
      echo "`basename $1` version $VERSION"
      echo "Script to create bootable eMMC for omap5/dra7xx evm"
      echo
    
      exit 0
    }
    
    usage ()
    {
      echo "
    Usage: `basename $1` <options> [ files for install partition ]
    
    Mandatory options:
      --device              eMMC block device node (e.g /dev/mmcblk1)
    
    Optional options:
      --version             Print version.
      --help                Print this help message.
    "
      exit 1
    }
    
    check_if_main_drive ()
    {
      mount | grep " on / type " > /dev/null
      if [ "$?" != "0" ]
      then
        echo "-- WARNING: not able to determine current filesystem device"
      else
        main_dev=`mount | grep " on / type " | awk '{print $1}'`
        echo "-- Main device is: $main_dev"
        echo $main_dev | grep "$device" > /dev/null
        [ "$?" = "0" ] && echo "++ ERROR: $device seems to be current main drive ++" && exit 1
      fi
    
    }
    
    
    echo "This has to be run on target, don't run on host"
    echo "Are you running on target? (Press ENTER to continue)"
    read junkdata
    
    # Check if the script was started as root or with sudo
    user=`id -u`
    [ "$user" != "0" ] && echo "++ Must be root/sudo ++" && exit
    
    # Process command line...
    while [ $# -gt 0 ]; do
      case $1 in
        --help | -h)
          usage $0
          ;;
        --device) shift; device=$1; shift; ;;
    #    --sdk) shift; sdkdir=$1; shift; ;;
        --version) version $0;;
        *) copy="$copy $1"; shift; ;;
      esac
    done
    
    #test -z $sdkdir && usage $0
    test -z $device && usage $0
    
    #if [ ! -d $sdkdir ]; then
    #   echo "ERROR: $sdkdir does not exist"
    #   exit 1;
    #fi
    
    if [ ! -b $device ]; then
       echo "ERROR: $device is not a block device file"
       exit 1;
    fi
    
    check_if_main_drive
    
    echo "************************************************************"
    echo "*         THIS WILL DELETE ALL THE DATA ON $device        *"
    echo "*                                                          *"
    echo "*         WARNING! Make sure your computer does not go     *"
    echo "*                  in to idle mode while this script is    *"
    echo "*                  running. The script will complete,      *"
    echo "*                  but your SD card may be corrupted.      *"
    echo "*                                                          *"
    echo "*         Press <ENTER> to confirm....                     *"
    echo "************************************************************"
    read junk
    
    for i in `ls -1 ${device}p?`; do
     echo "unmounting device '$i'"
     umount $i 2>/dev/null
    done
    
    execute "dd if=/dev/zero of=$device bs=1024 count=1024"
    
    sync
    
    cat << END | fdisk -H 255 -S 63 $device
    n
    p
    1
    
    +64M
    n
    p
    2
    
    
    t
    1
    c
    a
    1
    w
    END
    
    # handle various device names.
    PARTITION1=${device}1
    if [ ! -b ${PARTITION1} ]; then
            PARTITION1=${device}p1
    fi
    
    PARTITION2=${device}2
    if [ ! -b ${PARTITION2} ]; then
            PARTITION2=${device}p2
    fi
    
    # make partitions.
    echo "Formating ${device}p1 ..."
    if [ -b ${PARTITION1} ]; then
    	mkfs.vfat -F 32 -n "boot" ${PARTITION1}
    else
    	echo "Cant find boot partition in /dev"
    fi
    
    echo "Formating ${device}p2 ..."
    if [ -b ${PARITION2} ]; then
    	mkfs.ext4 -L "rootfs" ${PARTITION2}
    else
    	echo "Cant find rootfs partition in /dev"
    fi
    
    echo "Preparing for Copy..."
    execute "mkdir -p /tmp/sdk/$$/mmc_boot"
    execute "mkdir -p /tmp/sdk/$$/mmc_rootfs"
    execute "mkdir -p /tmp/sdk/$$/emmc_boot"
    execute "mkdir -p /tmp/sdk/$$/emmc_rootfs"
    
    execute "mount ${mmc_dev}p1 /tmp/sdk/$$/mmc_boot"
    execute "mount ${mmc_dev}p2 /tmp/sdk/$$/mmc_rootfs"
    execute "mount ${device}p1 /tmp/sdk/$$/emmc_boot"
    execute "mount ${device}p2 /tmp/sdk/$$/emmc_rootfs"
    
    echo "Copying boot image from ${mmc_dev}p1 to ${device}p1"
    execute "cp /tmp/sdk/$$/mmc_boot/* /tmp/sdk/$$/emmc_boot/."
    execute "cp /tmp/sdk/$$/mmc_boot/uenv-emmc.txt /tmp/sdk/$$/emmc_boot/uenv.txt"
    
    echo "Copying filesystem from ${mmc_dev}p2 to ${device}p2"
    execute "cp -rvf /tmp/sdk/$$/mmc_rootfs/* /tmp/sdk/$$/emmc_rootfs/."
    
    sync
    echo "unmounting ${mmc_dev}p1,${mmc_dev}p2,${device}p1,${device}p2"
    execute "umount /tmp/sdk/$$/mmc_boot"
    execute "umount /tmp/sdk/$$/mmc_rootfs"
    execute "umount /tmp/sdk/$$/emmc_boot"
    execute "umount /tmp/sdk/$$/emmc_rootfs"
    
    execute "rm -rf /tmp/sdk/$$"
    echo "completed!"
    

    With some slight modifications this should work on AM57xx devices as well. 

    Best Regards, 
    Yordan

  • Hi Rakesh,

    Put your rootfs Tarball in your sd card and then run this script in your target machine using sd card. That should resolve the issue.

    2703.create-emmc.txt
    #!/bin/bash
    
    
    
    # To use this script first Flash your sd-card using
    #Create-sdcard script in SDK located in bin directory.
    #Then tar rootfs and copy the tarball in rootfs partition
    #of sd-card in any subdirectory.Copy this script to sd-card
    #and run it in the target machine using sd-card. 
    #Enter yes if anything is prompted.   
    
    
    
    
    cd /
    
    umount -f /dev/mmcblk1p1
    
    umount -f /dev/mmcblk1p2
    
    cat << EOM
    
    ==============================================================================
                            Current partitions
    ==============================================================================
    
    EOM
    
    fdisk -l /dev/mmcblk1
    
    cat << EOM
    
    ==============================================================================
                            Removing all partitions
    ==============================================================================
    
    EOM
    
    echo "....WARNING...."
    
    echo "Continuing will Erase all the current data and Partitions in EMMC"
    
    CONTINUE=0
    
    while [ $CONTINUE -eq 0 ]
    
    do
    read -p "Do You Want To Continue [y/n] :  " CHOICE
        if [ $CHOICE = 'y' ]
        then 
            CONTINUE=1
        elif [ $CHOICE = 'n' ]
        then
    	CONTINUE=-1
        else
    	echo "Wrong Choice...Enter y or n"
    	CONTINUE=0
        fi
    done
    
    if [ $CONTINUE = -1 ]
        then
    	exit
    fi
    
     
    fdisk /dev/mmcblk1 << EEOF
    d
    2
    d
    w
    EEOF
    
    echo ""
    echo "All partitions removed."
    echo ""
    echo "" 
    
    cat << EOM
    
    ==============================================================================
                                  Creating new partitions
    ==============================================================================
    
    EOM
    
    parted -s /dev/mmcblk1 mklabel msdos
    
    parted -s /dev/mmcblk1  unit cyl mkpart primary fat32 -- 0 9
    
    parted -s /dev/mmcblk1  set 1 boot on
    
    parted -s /dev/mmcblk1 unit cyl mkpart primary ext2 -- 9 -2
    
    cat << EOM
    
    ==============================================================================      
                                   New partitions
    ==============================================================================
    
    EOM
    fdisk -l /dev/mmcblk1                                       
    
    mkfs.vfat -F 32 -n "boot" /dev/mmcblk1p1
    
    mkfs.ext3 -L "rootfs" /dev/mmcblk1p2
    
    sync
    sync
    
    
    if [ -d /temp1 ]
        then 
    	rm -rf temp1
    fi
    
    
    mkdir temp1
    
    cd temp1
    
    mkdir boot
    
    mkdir rootfs
    
    mkdir temp
    
    rm -rf boot/*
    
    rm -rf rootfs/*
    
    
    mount -t vfat /dev/mmcblk1p1 boot/
    
    mount -t ext3 /dev/mmcblk1p2 rootfs/
    
    mount -t vfat /dev/mmcblk0p1 temp/
    
    cat << EOM
    
    =============================================================================
                                     COPYING U-BOOT
    =============================================================================
    
    EOM
    
    cp -R temp/* boot/
    
    
    echo "copying MLO"
    
    echo "copying u-boot"
    
    echo "copying uEnv.txt"
    
    echo "done.."
    
    
    ENTERCORRECTLY=0
    
    while [ $ENTERCORRECTLY -ne 1 ]
    do
    
    read -p "Enter the complete path to rootfs tarball : " ROOTFSPATH
    
    
    
    	if [ -d $ROOTFSPATH ]
    
    	then
    	   ENTERCORRECTLY=1
    
    	else
    
    	echo "Is not a directory OR dirctory does not exist...Enter complete path to directory containing Rootfs"
    
    	   continue
    	fi 
    done
    
    TARBALL=`ls $ROOTFSPATH | grep .tar.gz | awk '{ print $1 }'`
    
    cat << EOM
    
    ==========================================================================
    	               EXTRACTING ROOTFS ... WILL TAKE SOME TIME
    ==========================================================================
    
    EOM
    
    if [ -n $TARBALL ]
     then
    	echo "The rootfs tarball is: " $TARBALL
    
    	tar -zxf $ROOTFSPATH/$TARBALL -C rootfs/
    
    else
    	echo "Tarball does not exist"
    
    	echo "Exiting..."
    fi
    
    umount -f boot
    
    umount -f rootfs
    
    umount -f temp
    
    rm -rf boot
    
    rm -rf rootfs
    
    rm -rf temp
    
    cd ..
    
    rm -rf temp1
    
    cat << EOM
    
    ===========================================================================
                             ...FINISHED...
    ===========================================================================
    
    EOM
    

  • Hello,

    I tried your  issue.2703.create-emmc.txt.However, after running this issue,it accureda problem:not enough space in the sd card.But the truth is that it do have enough space for it.

    So,could give me some advices?

    Thanks a lot!