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.

TDA4VM: Regarding TI debugger for EMMC flash

Part Number: TDA4VM

Dear Sir/Mam,

I have related question for flashing EMMC (with rootfs & boot contents) using TI debugger. Will it be possible to flash/copy with the boot and rootfs contents after partitioning is done ?

Already got info on copying using SD card below --> 

http://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-jacinto7/latest/exports/docs/linux/How_to_Guides/Target/How_to_flash_emmc_device.html 

Regards

Manish

  • Hi Manish,

    Let me check if it's possible to update eMMC using CCS and get back to you.
    This is your question right?

    Regards,
    Vishal

  • Hello Vishal ,

    Yes you got it right. Thanks a lot.

    Regards

    Manish

  • Hi Manish,

    I am checking with the team about this.

    There is a SD card slot on your board, may I know the reason why you are looking in to this option?

    Regards,
    Vishal

  • Hi Manish,

    Linux rootfs copying can be done via CCS and debugger.
    You can use CCS to connect to A72 and use the memory browser --> Load Memory option to load the images to memory and then disconnect from A72 and use the u-boot mmc write command to write rootfs to eMMC.

    Bootloader binaries cannot be flashed to emmc via debugger.
    You would have to use other methods like dfu (over usb) or uart boot mode.

    If this will work, I can provide the CCS steps for rootfs.

    Regards,
    Vishal

  • Hi Vishal,

    We were looking into the possibilities of flashing the emmc once we have ramp -up in production.

    Regards

    Manish

  • Hi Vishal,

    First thanks a lot for the info. Bootloader binaries we are already following uart boot mode method. 

    Please provide CCS steps for rootfs , as I would like to try it and compare to the formal method.

    Regards

    Manish

  • Hi Manish,

    Procedure below for loading from CCS to eMMC, the steps involve both CCS and u-boot command prompt.
    Not sure if this is good method for flashing for production.

    1. Boot the board and stop at u-boot prompt
    2. Launch CCS and connect to CoretexA72_0_0
    3. Click from menu View --> Memory Browser
    4. In Memory Browser, click on Load Memory (As shown in picture)
    5. Choose the rootfs .img file, set the File Type as Binary
    6. Click Next and choose Start Address as 0x80080000, and click Finish
    7. Wait for the memory to be loaded. based on the debugger used the time will vary (xds560 is faster)
    8. Once loading is done, disconnect from CoretexA72_0_0 and return to u-boot prompt
    9. On u-boot prompt do the following
    1. Create partition table (Ignore this step if already created)
      gpt write mmc 0 ${partitions}
    2. Get the start address of rootfs parition (Note down the start address from below command)
      part start mmc 0 rootfs
    3. Write to eMMC
      mmc write <LOAD_ADDRESS> <START> <SIZE>
      Ex: mc write 0x80080000 0x22 0x32000
    4. Update emmc as default boot (Ignore if done already)
      setenv mmcdev 0
      setenv bootpart 0
      saveenv




  • Hi Vishal ,

    Some questions on the above procedure :

    1) How to create rootfs.img file as what i see at the moment in the SDK_Install_Folder > filesystem > tisdk-rootfs-image-j7-evm.tar.xz file have lot of folders than a img file ?

    2) You are loading the rootfs here in DDR memory and than writing it to emmc here right ?

    3) gpt write mmc 0 ${partitions} - Is this command used to partition the emmc ? We were using the mkemmcboot.sh before to partition and copy the rootfs in emmc.(Attachment)

    Thanks a lot for the support.

    Regards

    Manish

    #! /bin/sh
    # Script to enable boot from eMMC flash for DRA7xx evm.
    #
    
    VERSION="0.1"
    
    execute ()
    {
      echo "Executing $*"
    }
    
    version ()
    {
      echo
      echo "`basename $1` version $VERSION"
      echo "Script to create bootable eMMC flash for Linux"
      echo
    
      exit 0
    }
    
    usage ()
    {
      echo "
    Usage: `basename $1` <options>
    
    Mandatory options:
    
    Optional options:
      --version             Print version.
      --help                Print this help message.
    "
      exit 1
    }
    
    if [ ! -r /bin/mkemmcboot1.sh ]; then
       echo "ERROR: /bin/mkemmcboot1.sh does not exist"
       exit 1;
    fi
    
    #Make sure the script has execute permissions
    chmod +x /bin/mkemmcboot1.sh
    
    if [ ! -x /bin/mkemmcboot1.sh ]; then
       echo "ERROR: /bin/mkemmcboot1.sh is not executeable"
       exit 1;
    fi
    
    echo "Unmount the eMMC partitions from root kernel"
    umount /dev/mmcblk0*
    
    echo "Stop the udev daemon to avoid auto mounting the partitions while we are formatting the eMMC"
    udevadm control -s
    
    echo "Partition the eMMC device using mkemmcboot1.sh script"
    #/bin/mkemmcboot1.sh --device /dev/mmcblk0 --sdk /home/root/sdk --part 2
    /bin/mkemmcboot1.sh --device /dev/mmcblk0 --part 2
    #read -p "Continue:Enter, Exit:Ctrl-c"
    
    echo "completed!"
    echo "After rebooting the board, the rootfs from eMMC can be used."
    
    #! /bin/sh
    # Script to create SD card for DRA7xx evm.
    #
    # Author: Brijesh Singh, Texas Instruments Inc.
    #       : Adapted for dra8xx-evm by Nikhil Devshatwar, Texas Instruments Inc.
    #
    # Licensed under terms of GPLv2
    #
    
    VERSION="0.1"
    
    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 SD card for Linux"
      echo
    
      exit 0
    }
    
    usage ()
    {
      echo "
    Usage: `basename $1` <options> [ files for install partition ]
    
    Mandatory options:
      --device              SD block device node (e.g /dev/sdd)
    
    Optional options:
      --sdk                 Path to SDK directory
      --part                Number of partitions
      --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
    
    }
    
    check_if_big_size ()
    {
      partname=`basename $device`
      size=`cat /proc/partitions | grep $partname | head -1 | awk '{print $3}'`
      if [ $size -gt 17000000 ]; then
        cat << EOM
    
    ************************* WARNING ***********************************
    *                                                                   *
    *      Selected Device is greater then 16GB                         *
    *      Continuing past this point will erase data from device       *
    *      Double check that this is the correct SD Card                *
    *                                                                   *
    *********************************************************************
    EOM
    
        ENTERCORRECTLY=0
        while [ $ENTERCORRECTLY -ne 1 ]
        do
          read -p 'Would you like to continue [y/n] : ' SIZECHECK
          echo ""
          echo " "
          ENTERCORRECTLY=1
          case $SIZECHECK in
            "y")  ;;
            "n")  exit;;
            *)  echo "Please enter y or n";ENTERCORRECTLY=0;;
          esac
          echo ""
        done
      fi
    }
    
    unmount_all_partitions ()
    {
      for i in `ls -1 $device*`; do
        echo "unmounting device '$i'"
        umount $i 2>/dev/null
      done
      mount | grep $device
    }
    
    # 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; ;;
        --part) shift; part=$1; shift; ;;
        --sdk) shift; sdkdir=$1; shift; ;;
        --version) version $0;;
        *) copy="$copy $1"; shift; ;;
      esac
    done
    
    test -z $device && usage $0
    
    if [ ! -z $sdkdir ] && [ ! -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
    
    check_if_big_size
    
    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
    
    udevadm control -s
    unmount_all_partitions
    
    root@j7-evm:~# echo 0 > /sys/block/mmcblk0/force_ro
    root@j7-evm:~# echo 0 > /sys/block/mmcblk0boot0/force_ro
    root@j7-evm:~# echo 0 > /sys/block/mmcblk0boot1/force_ro
    
    cat << EOMCUR
    
    ==============================================================================
                            Current partitions
    ==============================================================================
    
    EOMCUR
    fdisk -l $device
    
    execute "dd if=/dev/zero of=$device bs=1024 count=1024"
    
    sync
    
    if [ ! -z $part ] && [ $part -gt 1 ]; then
    
    #The partitioning steps are as follows:
    #
    #Create 1st partition (n,p,1,default,+62M)
    #Create 2nd partition (n,p,2,default,default)
    #Change 1st partition type to FAT32 (t,1,c)
    #Make 1st partition ACTIVE (a,1)
    #Write (w)
    
    cat << F2END | fdisk $device
    n
    p
    1
    
    +62M
    n
    p
    2
    
    
    t
    1
    c
    a
    1
    w
    F2END
    
    else
    
    #The partitioning steps are as follows:
    #
    #Create 1st partition (n,p,1,default,default)
    #Make 1st partition ACTIVE (a,1)
    #Write (w)
    
    cat << F1END | fdisk $device
    n
    p
    1
    
    
    a
    1
    w
    F1END
    
    fi
    
    cat << EOMNEW
    
    ==============================================================================      
                                   New partitions
    ==============================================================================
    
    EOMNEW
    fdisk -l ${device}
    
    unmount_all_partitions
    
    # 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
    
    if [ ! -z $part ] && [ $part -gt 1 ]; then
    
        # make partitions.
        echo "Formatting ${device} ..."
        if [ -b ${PARTITION1} ]; then
            mkfs.vfat -F 32 -n "boot" ${PARTITION1}
        else
            echo "Cant find boot partition in /dev"
        fi
     
        if [ -b ${PARITION2} ]; then
            mkfs.ext4 -L "rootfs" ${PARTITION2}
        else
            echo "Cant find rootfs partition in /dev"
        fi
    
    else
    
        # make partitions.
        echo "Formatting ${device} ..."
        if [ -b ${PARTITION1} ]; then
            mkfs.ext4 -L "rootfs" ${PARTITION1}
        else
            echo "Cant find rootfs partition in /dev"
        fi
    
    fi
    
    
    echo "Partitioning and formatting completed!"
    mount | grep $device
    
    
    if [ ! -z $part ] && [ $part -gt 1 ]; then
    
      echo "Copying filesystem on $PARTITION1, $PARTITION2"
      execute "mkdir -p /tmp/emmc/$$/boot"
      execute "mkdir -p /tmp/emmc/$$/rootfs"
      execute "mount $PARTITION1 /tmp/emmc/$$/boot"
      execute "mount $PARTITION2 /tmp/emmc/$$/rootfs"
    
      if [ -z $sdkdir ]; then
        echo "Now copy the contents of SD card into eMMC device"
        #read -p "Continue:Enter, Exit:Ctrl-c"
        execute "umount /run/media/mmcblk1p1"
        execute "mkdir -p /tmp/sd/$$/boot"
        execute "mkdir -p /tmp/sd/$$/rootfs"
        execute "mount /dev/mmcblk1p1 /tmp/sd/$$/boot"
        execute "mount /dev/mmcblk1p2 /tmp/sd/$$/rootfs"
        echo "Next copy action takes some time"
        execute "/bin/cp -r /tmp/sd/$$/boot/* /tmp/emmc/$$/boot"
        execute "/bin/cp -r /tmp/sd/$$/rootfs/* /tmp/emmc/$$/rootfs"
        sync
        umount /tmp/sd/$$/boot
        umount /tmp/sd/$$/rootfs
        rmdir /tmp/sd/$$/boot
        rmdir /tmp/sd/$$/rootfs
        rmdir /tmp/sd/$$
        rmdir /tmp/sd
      else    
        boot_tar="$sdkdir/board-support/prebuilt-images/boot-j7-evm.tar.gz"
        execute "tar -zxf $boot_tar -C /tmp/emmc/$$/boot"
        execute "chown -R root:root /tmp/emmc/$$/boot"
        root_fs="$sdkdir/filesystem/tisdk-rootfs-image-j7-evm.tar.xz"
        execute "tar -xf $root_fs -C /tmp/emmc/$$/rootfs"
        sync
      fi
    
      echo "unmounting $PARTITION1, $PARTITION2"
      umount /tmp/emmc/$$/boot
      umount /tmp/emmc/$$/rootfs
      rmdir /tmp/emmc/$$/boot
      rmdir /tmp/emmc/$$/rootfs
      rmdir /tmp/emmc/$$
      rmdir /tmp/emmc
    
    else
    
      echo "Copying filesystem on $PARTITION1"
      echo "mkdir -p /tmp/emmc/$$/rootfs"
      execute "mkdir -p /tmp/emmc/$$/rootfs"
      echo "mount $PARTITION1 /tmp/emmc/$$/rootfs"
      execute "mount $PARTITION1 /tmp/emmc/$$/rootfs"
    
      if [ -z $sdkdir ]; then
        echo "Now copy the contents of SD card into eMMC device"
        echo "cp -r /tmp/sd/$$/rootfs/* /tmp/emmc/$$/rootfs"
        #read -p "Continue:Enter, Exit:Ctrl-c"
        execute "umount /run/media/mmcblk1p1"
        execute "mkdir -p /tmp/sd/$$/rootfs"
        execute "mount /dev/mmcblk1p2 /tmp/sd/$$/rootfs"
        echo "Next copy action takes some time"
        execute "cp -r /tmp/sd/$$/rootfs/* /tmp/emmc/$$/rootfs"
        sync
        umount /tmp/sd/$$/rootfs
        rmdir /tmp/sd/$$/rootfs
        rmdir /tmp/sd/$$
        rmdir /tmp/sd
      else    
        root_fs="$sdkdir/filesystem/tisdk-rootfs-image-j7-evm.tar.xz"
        execute "tar -xf $root_fs -C /tmp/emmc/$$/rootfs"
        execute "sync"
      fi
    
      echo "unmounting $PARTITION1"
      umount /tmp/emmc/$$/rootfs
      rmdir /tmp/emmc/$$/rootfs
      rmdir /tmp/emmc/$$
      rmdir /tmp/emmc
    
    fi
    
    udevadm control -S
    echo "completed!"
    

  • Hi Manish,

    -1-
    Let me check and get back on this one.

    -2-
    Yes.
    On second thought the file system may be too big to copy to memory and then transfer to emmc. 
    This method works for small file system.

    -3-
    'gpt write' command is one way to write partition table from u-boot command prompt. Ignore this if partition table is written by another method.


    Regards,
    Vishal

  • Hi Vishal ,

    I could create the root file system image with the procedure below : 

    1) You need to create an empty image file (here 1GB) take care how much your image will be (DDR memory constraint and time to copy)
    dd if=/dev/null of=example.img bs=1M seek=1024
    2) You need to add a filesystem to it (Here linux default filesystem ext4)
    mkfs.ext4 -F example.img
    3) you need to mount it on your local machine so you can copy your folder data to it:
    mkdir /mnt/example_img
    mount -t ext4 -o loop exmaple.img /mnt/example_img
    5) you need to copy the files from the extracted rootfs (untar) to it:
    tar -xvzf rootfs.tar.gz
    cp -r rootfs/* /mnt/example_img/
    6) Umount the image:
    umount /mnt/example_img
    This image can then directly used to be sent to the machine using the CCS

    The ISSUE is the entire root fs is 2.5 GB and i don't think i will be able to do that on custom board with 1 GB DDR. Also there is a failure when i try to load at the given address above. Please see the attachment when i try to load the  memory .

    Actually for once we can use the SD card to copy the rootfs on the eMMC that is not the issue but for example when we have changes inside the board-support >linux/u-boot device trees what will be the best method to copy the deltas inside eMMC (over the long run we will switch to ROM flash )

    Regards

  • Hi Manish,

    CCS method may not be suitable for flashing big images.
    Does your board have USB interface?

    Regards,
    Vishal

  • Hi Vishal ,

    We are able to use SD card to copy both boot and root filesystem into eMMC. Just wanted to see the option to flash using debugger. 

    And what did you mean above by flashing small root filesystem ? 

    Can we use CCS to flash dtb files in rootfs>boot ? Also what is the best way to copy the tispl.bin , u-boot.img & tiboot3.bin into the eMMC>boot ?

    Regards

    Manish

  • Hi Manish,

    I meant minimal file system, not full file system.
    CCS method I mentioned above is for flashing entire partition. Not for individual files.

    Regards,
    Vishal

  • Hi Vishal,

    Is SCP the best option to copy the files in root fs and boot ? 

    Also what would be the minimal filesystem for example ?

    Regards

    Manish 

  • Hi Manish,

    For individual file update to eMMC, there are many methods, you can choose one that best works for you.
    -> scp over ethernet connection
    -> Copy from SD card or USB stick connected to the board to the eMMC.
    -> from u-boot use ums command to mount the partitions and update the file.

    Minimal file system idea is to cut down the rootfs to have a minimal file system, it won't have all the features.
    Check in your build output if you have a arago-tiny rootfs. You have to add the Kernel images on top of it.

    Regards,
    Vishal

  • Hello Vishal,

    Alright got it , I am closing the thread now.

    Regards

    Manish