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.

[FAQ] TDA4VM: How to modify offsets for boot binaries in eMMC

Part Number: TDA4VM
Other Parts Discussed in Thread: UNIFLASH

I have a different eMMC part on m custom board and the boot0 partition for that is 4MB instead of 8MB on the TDA4 EVM.

I want to boot Linux from the boot partition on this eMMC part. My boot binaries can fit well within 4MB. Can you help me patch the u-boot to get the boot binaries from the modified offsets?

  • Booting from eMMC

    1. Intention will be to flash the boot0 partition with R5 SPL, A72 SPL, A72 u-boot and sysfw.itb and then flash the user partition with a tiny file system.

    2. We use tiny fs right now as the full file system will take a lot of time to flash using JTAG.

    3. Follow the below steps to acheive the above. Note that some commands need to run on TARGET (u-boot prompt) and some on HOST PC.

    4. Physical connections needed:

      • MCU UART
      • JTAG (XDS110/XDS560v2)
    5. Softwares required:

    Modified eMMC layout for boot0

    Each sector is 512B

    				boot0 partition (4 MB)                       user partition
    		 0x0+----------------------------------+    0x0+-------------------------+
    			|     tiboot3.bin (384 KB)         |       |                         |
    	   0x300+----------------------------------+       |                         |
    			|       tispl.bin (768 KB)         |       |                         |
    	   0x900+----------------------------------+       |        rootfs           |
    			|       u-boot.img (2 MB)          |       |                         |
    	  0x1900+----------------------------------+       |                         |
    			|       sysfw.itb (768 KB)         |       |                         |
    	  0x1F00+----------------------------------+       +-------------------------+

    Step1: Patch the u-boot

    The u-boot needs to be patched to change the offsets for the eMMC. Reason being that the eMMC part on the EVM has 8MB boot0 partition

    Modify the offsets according to the layout above.

    1. Apply the patch 0001-Change-the-offsets-for-eMMC-8MB-boot0-partition-to-4.patch

       cd <PATH_TO_UBOOT_DIR>
       git am 0001-Change-the-offsets-for-eMMC-8MB-boot0-partition-to-4.patch
       make mrproper
      
    2. Rebuild the u-boot and SPL

       # use the top level makefile to build u-boot and SPL
       cd <PATH_TO_SDK>
       make u-boot-a53_clean -sj
       make u-boot-a53
       make u-boot-r5_clean -sj
       make u-boot-r5
      
    3. Path to binaries

       ls -la <PATH_TO_SDK>/board-support/u-boot_build/r5/tiboot3.bin
       ls -la <PATH_TO_SDK>/board-support/u-boot_build/a53/tispl.bin
       ls -la <PATH_TO_SDK>/board-support/u-boot_build/a53/u-boot.img
       ls -la <PATH_TO_SDK>/board-support/prebuilt-images/sysfw.itb
      
       # Now copy these 4 binaries to <FULL_PATH_TO_BINS>
      

    Step2: Flashing the eMMC boot0

    Refer http://downloads.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/pdk_jacinto_07_00_00/docs/userguide/board/uniflash.html#getting-started-with-uniflash for more details.

    UNIFLASH Commands to flash to eMMC boot0 partition (restricted to 4MB):

    UNIFLASH uses actual byte offsets rather than sector offsets.

    1. Change boot mode on the board to UART boot mode.
    2. Close the MCU UART (2nd instance, phyically un-plug & plug back in case of windows)
    3. Use below commands to flash the boot0 binaries.

    Below commands run on the HOST

    dslite.bat --mode processors -c COM7 -f C:\ti\uniflash_5.3.1\processors\FlashWriter\j721e_evm\uart_j721e_evm_flash_programmer_release.tiimage -i 0
    dslite.bat --mode processors -c COM7 -f <FULL_PATH_TO_BINS>\tiboot3.bin -d 4 -o 0
    dslite.bat --mode processors -c COM7 -f <FULL_PATH_TO_BINS>\tispl.bin -d 4 -o 60000
    dslite.bat --mode processors -c COM7 -f <FULL_PATH_TO_BINS>\u-boot.img -d 4 -o 120000
    dslite.bat --mode processors -c COM7 -f <FULL_PATH_TO_BINS>\sysfw.itb -d 4 -o 320000
    
    1. Change the boot mode to eMMC boot mode and you should be able to u-boot prompt.

    Step3: Setup u-boot environment

    Halt at u-boot prompt and run the below commands on the TARGET

    setenv mmcdev 0
    setenv bootpart 0
    saveenv
    gpt write mmc 0 ${partitions}
    mmc partconf 0 1 1 1
    mmc bootbus 0 2 0 0
    

    Step4: Flash the eMMC rootfs

    Step a is optional, if you use the attached tisdk-tiny-image.tar.xz then you can stip step a

    a. Create the tisdk-tiny-image.tar.xz

    git clone git://arago-project.org/git/projects/oe-layersetup.git tisdk
    cd tisdk/
    
    # Copy config file from the 7.00 installer yocto-build/configs/psdkla/psdkla-07_00_00.txt
    ./oe-layertool-setup.sh -f psdkla-07_00_00.txt
    
    # export proxy
    export ftp_proxy=<a href="webproxy.ext.ti.com:80">http:/.../a>
    export http_proxy=<a href="webproxy.ext.ti.com:80">http:/.../a>
    export https_proxy=<a href="webproxy.ext.ti.com:80">http:/.../a>
    
    cd build
    # Edit config file if you want to reuse downloads folder
    vi conf/local.conf
    . conf/setenv
    
    # this is the path to the toolchains for ARMv7 and ARMv8
    TOOLCHAIN_BASE=/sdk/tools MACHINE=j7-evm bitbake -k tisdk-tiny-image
    
    # build image can be found here
    la -la tisdk/build/arago-tmp-external-arm-glibc/deploy/images/j7-evm/tisdk-tiny-image-j7-evm.tar.xz
    

    b. Create a tiny rootfs image from the tisdk-tiny-image.tar.xz (attached)

    Below steps need to be run on HOST machine to create the tisdk-tiny-image.img

    # Create an empty image file, seek value will create an image of that size. Typically 100MB should be enough.
    # Size will should be slightly greater than size of untarred tisdk-tiny-image-j7-evm.tar.xz + size (DTBs + Kernel image)
    dd if=/dev/null of= bs=1M seek=100
    
    # Add a filesystem to it
    mkfs.ext4 -F tisdk-tiny-image.img
    
    # Mount it on your local machine to copy DTB and Kernel image
    mkdir example_mnt_pt
    sudo mount -t ext4 -o loop tisdk-tiny-image.img /home/karan/yocto-build/example_mnt_pt
    
    # Untar tisdk-tiny-image-j7-evm.tar.xz on the mounted file system which is currently empty
    cd example_mnt_pt
    sudo tar xvf ../tisdk-tiny-image-j7-evm.tar.xz
    
    # Copy DTB, DTBOs and Kernel Image for your platform
    sudo cp /media/karan/rootfs/boot/Image* example_mnt_pt/boot
    sudo cp /media/karan/rootfs/boot/*dtb* example_mnt_pt/boot
    sync
    
    # Unmount the image, now the tisdk-tiny-image.img is ready
    cd ../
    sudo umount /home/karan/yocto-build/example_mnt_pt
    
    # Now you have the tisdk-tiny-image.img ready  to be flashed.
    

    c. Flash this tisdk-tiny-image.img using JTAG + u-boot

    Do NOT power cycle throught this step

    1. Halt at u-boot

    2. Connect CCS using the XDS110/XDS560v2 and using the appropriate target ccxml (without GELs).

    3. Load the tisdk-tiny-image.img to the DDR address 0x80080000

      • Launch the target ccxml and connect to CortexA72_0_0
      • Open Memory browser and load memory: View -> Memory Browser -> Load Memory
      • Select file tisdk-tiny-image.img and select File Type as Binary, click Next
      • Set Start Address as 0x80080000, click Finish.

        Depending on the JTAG used the time taken to load this will vary. Expect 1Hr with XDS110 and 20mins with XDS560v2.

    4. Now the image in loaded on the RAM, flash it using u-boot

      Code runs at u-boot prompt on the TARGET

       part start mmc 0 rootfs
       
       # what ever the above command outputs, use that below (eg - 0x22)
       mmc write 0x80080000 0x22 0x32000
      
       # after the above completes
       boot
      

    With this you should be able to boot to the tiny file system in eMMC.

    Package/cfs-file/__key/communityserver-discussions-components-files/791/eMMC_5F00_flashing_5F00_package.zip

    Regards,

    Karan