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.

SK-AM62B-P1: Switching Mechanism between two Rootfs

Part Number: SK-AM62B-P1

Tool/software:

Hello TI Experts,

By default the board is booting from the eMMC first partition but if the board has to be booted from the second partition then how we can boot the board without setting the environment in uboot?

In U-boot environment is defined as:

mmcdev = 0
bootpart = 0:1

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1307234/processor-sdk-am62x-am62x-backup-image-switching-mechanism/4965575#4965575

By following this should i add two variables into the uEnv.txt file in that first is to detect the current boot partition and second variable to automatically switch between partitions and this will be the script which i can call in bootcmd variable!

will it reflect in the uboot environment? Please, how should I approach? I need some clarity.

Best Regards,

Suraj Singh

 

  • Hi Suraj,

    Thanks for reaching out to Texas Instruments E2E support forum.

    Our domain expert is out of office today. Responses to this thread might be delayed.

    Regards,

    Tushar

  • Hello Tushar,

    Thanks for considering, if possible today will they get back!

    Regards,

    Suraj Singh

  • e2e.ti.com/.../4965575

    As explained in this thread, you may define a "uenvcmd" variable with the commands for your logic to determine the partition & accordingly set the "mmcdev" & "bootpart" variable to boot the Linux Kernel from the determined partition.

  • Hello Prashant,

    # mmcdev=0
    # bootpart=0:2
    optargs="maxcpus=2"
    name_overlays=k3-am625-sk-dual-core.dtbo

    I have attached uEnv.txt and in U-boot environment mentioned as

    mmcdev = 0
    bootpart = 0:1

    Now if I want to automate the process instead of of manually entering the command from u-boot prompt. then what will I have to write in uEnv.txt ?

    Regards,

    Suraj Singh
     

  • then what will I have to write in uEnv.txt ?

    Isn't this explained in the other thread?

    The "uenvcmd" may look like this: uenvcmd='setenv mmcdev 0;setenv bootpart 0:2'

  • Hello Prashant,

    => run envboot
    switch to partitions #0, OK
    mmc0(part 0) is current device
    SD/MMC found on device 0
    Failed to load 'boot.scr'
    Can't set block device
    

    after using this command is not able to load!

    Regards,

    Suraj Singh

  • Hello Prashant,

    To load the uenv.txt file & runs the uenvcmd which boot mode should I keep sd card or emmc boot mode!

    Regards,

    Suraj Singh

  • To load the uenv.txt file & runs the uenvcmd which boot mode should I keep sd card or emmc boot mode!

    The U-Boot loads the uEnv.txt from a FAT partition based on the "mmcdev" & "bootpart" variables. This means if the "mmcdev" & "bootpart" variables are initially set to "0" & "0:1" respectively, the U-Boot will try to load the uEnv.txt from the eMMC UDA 1st partition supposedly formatted as a FAT partition.

  • Hello Prashant,

    The tar file which I am flashing into eMMC contains boot loader, kernel, device tree and root file system. so how should I convert u-boot to FAT format whether I will have to convert the entire tar file!

    https://dev.ti.com/tirex/explore/node?node=A__AdNWBqCVds4ZSqU9osT1tQ__AM62-ACADEMY__uiYMDcq__LATEST

    Here, U-Boot firmware can be written to the boot0 partition on the eMMC, so should i convert boot0 partition into fat format!

    root@am62xx-evm:~# lsblk -f
    NAME         FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
    mtdblock0                                                                           
    mtdblock1                                                                           
    mtdblock2                                                                           
    mtdblock3                                                                           
    mtdblock4                                                                           
    mtdblock5                                                                           
    mtdblock6                                                                           
    mmcblk0                                                                             
    |-mmcblk0p1  ext4               8b245263-6433-49aa-b77e-6ab071421694                
    `-mmcblk0p2  ext4               1e482006-bcaf-4570-9544-1a89d36bd7c8                
    mmcblk0boot0 vfat               EC4D-EA00                                           
    mmcblk0boot1                                                                        
    mmcblk1                                                                             
    |-mmcblk1p1  vfat         boot  8EEE-F9C6                             100.9M    21% /boot
    `-mmcblk1p2  ext4         root  5705506c-36bb-42ec-b2a4-b69fc6c072a2  464.1M    84% /
    

    Regards,

    Suraj 

  • You would need to reformat the eMMC with the first partition formatted as FAT & any other number of partitions for storing your rootfs filesystems. Then, you could set "mmcdev=0" & "bootpart=0:2" initially in the U-Boot enviroment to boot the Linux Kernel by default from the 2nd partition.

    With this, the flow would looks like:

    • U-Boot loads uEnv.txt from the eMMC 1st partition.
    • If uEnv.txt does not modify the "mmcdev" & "bootpart" variables, U-Boot will boot the Linux Kernel from the default 2nd partition otherwise it will boot Kernel from the modified values of those variables.

    Please note you are very much open to evaluating how the uEnv.txt is loaded.

    This is the environment variable used to load the uEnv.txt. You could modify it according to your convenience.

    loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}

  • Hello Prashant,

    I understood your point, you are saying that if I do not change both the variables in uEnv.txt then the board will by default boot from the eMMC 2nd partition
    Now I want to ask one thing, if I want to boot from another 3rd partition of eMMC then what will I have to add in uenv.txt?

    This is the environment variable used to load the uEnv.txt. You could modify it according to your convenience.

    loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}

    should i include this in am62x.env file?

    Best Regards,

    Suraj

  • Now I want to ask one thing, if I want to boot from another 3rd partition of eMMC then what will I have to add in uenv.txt?

    This will be something like: uenvcmd='setenv mmcdev 0;setenv bootpart 0:3"

    should i include this in am62x.env file?

    No. If you try to understand how the U-Boot is loading the uEnv.txt file, you would find it uses the `loadbootenv` environment variable (already defined) to load the uEnv.txt file. What I suggested is you are very much open to modifying how the uEnv.txt is loaded by modifying the `loadbootenv` variable.

  • Hello Prashant,

    root@am62xx-evm:~# lsblk -f
    NAME         FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
    mtdblock0                                                                           
    mtdblock1                                                                           
    mtdblock2                                                                           
    mtdblock3                                                                           
    mtdblock4                                                                           
    mtdblock5                                                                           
    mtdblock6                                                                           
    mmcblk1                                                                             
    |-mmcblk1p1  vfat         boot  CC62-856E                             100.9M    21% /boot
    `-mmcblk1p2  ext4         root  cf0f9e98-5a1f-4c2b-ace3-fb01699b379d  419.7M    85% /
    mmcblk0                                                                             
    |-mmcblk0p1  vfat               3ECA-AA84                                           
    |-mmcblk0p2  ext4               4ff24423-c2fe-43c1-8e26-69a92476f34a                
    `-mmcblk0p3  ext4               4c46ad85-4776-4f88-9796-195d11a1d836                
    mmcblk0boot0                                                                        
    mmcblk0boot1 
    
    
    
    
    root@am62xx-evm:~# cat /etc/fstab 
    # stock fstab - you probably want to override this with a machine specific one
    
    /dev/root            /                    auto       defaults              1  1
    proc                 /proc                proc       defaults              0  0
    devpts               /dev/pts             devpts     mode=0620,ptmxmode=0666,gid=5      0  0
    tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
    tmpfs                /var/volatile        tmpfs      defaults              0  0
    
    # uncomment this if your device has a SD/MMC/Transflash slot
    #/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0
    
    UUID=CC62-856E  /boot   vfat    defaults        0       0
    
    The device is in sd card boot mode . I copied uEnv.txt file and bootloaders into first partition of emmc. 
    Now I have flashed the kernel, device tree and root file system in the remaining 2 partitions of emmc. Now I booted the board via emmc, so

    1. Will uboot load the uEnv.txt file now?
    2. Is the process correct? I have attached fstab, do I need to make any changes in it?

    This will be something like: uenvcmd='setenv mmcdev 0;setenv bootpart 0:3"

    I created uEnv.txt file and edited it. I have attached uEnv.txt file too.

    root@am62xx-evm:/boot# cat uEnv.txt 
    optargs="maxcpus=2"
    name_overlays=k3-am625-sk-dual-core.dtbo
    uenvcmd='setenv mmcdev 0;setenv bootpart 0:3'
    

    => run envboot
    switch to partitions #0, OK
    mmc0(part 0) is current device
    SD/MMC found on device 0
    Failed to load 'boot.scr'
    Failed to load 'uEnv.txt'
    

    uboot failed to load the uEnv.txt file.

    Regards,

    Suraj

  • Hello,

    Can you check if the "uEnv.txt" is really present in the eMMC with "ls mmc 0:1"?

  • Hello Prashant,

    Can you check if the "uEnv.txt" is really present in the eMMC with "ls mmc 0:1"?

    No, it's not present there, but i have copied i am pretty sure! 

    Actually after image creation there is no uenv.txt file in boot folder but when I am flashing the same image to emmc then uenv.txt file is getting generated.

    The device is in sd card boot mode . I copied uEnv.txt file and bootloaders into first partition of emmc. 
    Now I have flashed the kernel, device tree and root file system in the remaining 2 partitions of emmc. Now I booted the board via emmc,

    The process I am following is correct, isn't it?

    Regards,

    Suraj

  • Hello Prashant,

    => part list mmc 0
    
    Partition Map for MMC device 0  --   Partition Type: DOS
    
    Part    Start Sector    Num Sectors     UUID            Type
      1     2048            2095105         a819b8ed-01     83
      2     2099200         23066625        a819b8ed-02     83
      3     25167872        36993024        a819b8ed-03     83
    => ls mmc 0:1
       295502   tiboot3.bin
      1182907   tispl.bin
       987115   u-boot.img
          107   uEnv.txt
    
    4 file(s), 0 dir(s)
    
    => ls mmc 0:2
    <DIR>       4096 .
    <DIR>       4096 ..
    <DIR>      16384 lost+found
    <SYM>          7 bin
    <DIR>       4096 boot
    <DIR>       4096 dev
    <DIR>       4096 etc
    <DIR>       4096 home
    <SYM>          7 lib
                   7 log_lock.pid
    <DIR>       4096 media
    <DIR>       4096 mnt
    <DIR>       4096 proc
    <DIR>       4096 run
    <SYM>          8 sbin
    <DIR>       4096 srv
    <DIR>       4096 sys
    <DIR>       4096 tmp
    <DIR>       4096 usr
    <DIR>       4096 var
    => ls mmc 0:3
    <DIR>       4096 .
    <DIR>       4096 ..
    <DIR>      16384 lost+found
    <SYM>          7 bin
    <DIR>       4096 boot
    <DIR>       4096 dev
    <DIR>       4096 etc
    <DIR>       4096 home
    <SYM>          7 lib
                   7 log_lock.pid
    <DIR>       4096 media
    <DIR>       4096 mnt
    <DIR>       4096 proc
    <DIR>       4096 run
    <SYM>          8 sbin
    <DIR>       4096 srv
    <DIR>       4096 sys
    <DIR>       4096 tmp
    <DIR>       4096 usr
    <DIR>       4096 var
    

    Can you check if the "uEnv.txt" is really present in the eMMC with "ls mmc 0:1"?

    I flashed again and now uEnv.txt is in the first partition , and i have attached partitions details please find ASAP!

    root@am62xx-evm:~# lsblk -f
    NAME         FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
    mtdblock0                                                                           
    mtdblock1                                                                           
    mtdblock2                                                                           
    mtdblock3                                                                           
    mtdblock4                                                                           
    mtdblock5                                                                           
    mtdblock6                                                                           
    mmcblk0                                                                             
    |-mmcblk0p1  vfat               26D6-3861                                           
    |-mmcblk0p2  ext4               518057be-6cb1-4b1b-bb2f-c4f881657af8    7.6G    24% /
    `-mmcblk0p3  ext4               5989b1b2-00af-4d7b-9d9b-75e8f7018b96                
    mmcblk0boot0                                                                        
    mmcblk0boot1                                                                        
    

    Regards,

    Suraj

  • Hello Prashant,

    => run envboot
    switch to partitions #0, OK
    mmc0(part 0) is current device
    SD/MMC found on device 0
    Failed to load 'boot.scr'
    107 bytes read in 14 ms (6.8 KiB/s)
    Loaded env from uEnv.txt
    Importing environment from mmc0 ...
    Running uenvcmd ...
    Unknown command 'setenv mmcdev 0;setenv bootpart 0:3' - try 'help' or use 'run' command
    => printenv bootpart
    bootpart=0:2
    
    
    
    root@am62xx-evm:/boot# cat uEnv.txt 
    optargs="maxcpus=2"
    name_overlays=k3-am625-sk-dual-core.dtbo
    uenvcmd='setenv mmcdev 0;setenv bootpart 0:3'
    

    I have attached the log, now it is able to load uEnv.txt but showing "Unknown command ('setenv mmcdev 0;setenv bootpart 0:3'). Please find attached log ASAP.

    Regards,

    Suraj

  • Can you try without quotes like:

    uenvcmd=setenv mmcde 0; setenv bootpart 0:3

  • Hello Prashant,

    I wanted to extend my heartfelt thanks for your assistance in resolving the issue I was facing with the AM62xx EVM. Your guidance and prompt responses were invaluable, and I truly appreciate the expertise you provided.

    Thanks to your support, the problem has been fully resolved.

    Looking forward to working with you in the future!

    Best Regards,

    Suraj