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.

AM62P: SBL with android partition layout

Part Number: AM62P
Other Parts Discussed in Thread: SYSCONFIG, UNIFLASH

Hello,

I'm trying to run the SDK SBL example using the Android partitions, without success. Although the SPL seems to be working fine, when executing the Bootloader_parseMultiCoreAppImage function, it fails.

Partition layout:
=> mmc part                                                                                                                                                                         
                                                                                                                                                                                    
Partition Map for MMC device 0  --   Partition Type: EFI                                                                                                                            
                                                                                                                                                                                    
Part    Start LBA       End LBA         Name                                                                                                                                        
        Attributes                                                                                                                                                                  
        Type GUID                                                                                                                                                                   
        Partition GUID                                                                                                                                                              
  1     0x00002800      0x000067ff      "bootloader"                                                                                                                                
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   2e6bff3e-e8f8-604e-b078-271fe40c09f5                                                                                                                                
  2     0x00002000      0x000027ff      "tiboot3"                                                                                                                                   
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   07dbea06-fe2b-2949-9533-aed11b974fec                                                                                                                                
  3     0x00006c00      0x00006fff      "misc"                                                                                                                                      
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   e69515ae-007e-c04e-a6cc-0906687e3fcc                                                                                                                                
  4     0x00007000      0x0001afff      "boot_a"                                                                                                                                    
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   df131c31-2d1b-2e49-9652-d3789ef0a240                                                                                                                                
  5     0x0001b000      0x0002efff      "boot_b"                                                                                                                                    
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   a71712bd-93bd-ed42-8fe9-885b77789490                                                                                                                                
  6     0x0002f000      0x0003efff      "vendor_boot_a"                                                                                                                             
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   c0ffcdf9-da79-114e-9171-2288f5780e07                                                                                                                                
  7     0x0003f000      0x0004efff      "vendor_boot_b"                                                                                                                             
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   1c62fc47-8bf2-3e4d-bb0f-a275fddee3bd                                                                                                                                
  8     0x0004f000      0x00052fff      "init_boot_a"                                                                                                                               
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   47feb651-07ab-b74f-86cc-13bc63aee674                                                                                                                                
  9     0x00053000      0x00056fff      "init_boot_b"                                                                                                                               
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   b3f75435-c92d-774a-9abd-80e3af6e5b71                                                                                                                                
 10     0x00057000      0x0005afff      "dtbo_a"                                                                                                                                    
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   c93899dd-cf5c-9a49-bdcd-c1d3ce19a5a6                                                                                                                                
 11     0x0005b000      0x0005efff      "dtbo_b"                                                                                                                                    
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   49a83e25-9b73-834b-99e4-25e20a827b8a                                                                                                                                
 12     0x0005f000      0x0005f07f      "vbmeta_a"                                                                                                                                  
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   b3f4c13e-8e37-5141-8c9f-9c6e7a46c150                                                                                                                                
 13     0x0005f080      0x0005f0ff      "vbmeta_b"                                                                                                                                  
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   3c940d44-a89a-1a46-8067-0439768b6b08                                                                                                                                
 14     0x0005f100      0x0095f0ff      "super"                                                                                                                                     
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   8fd58137-a70e-c14c-b0fb-d4fa41e5fbd1                                                                                                                                
 15     0x0095f100      0x009670ff      "metadata"                                                                                                                                  
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   e29466b3-03d2-a644-8d4d-b4e92375a663                                                                                                                                
 16     0x00967100      0x009770ff      "persist"                                                                                                                                   
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   28237f13-a293-bf46-a91e-2a1d5a320582                                                                                                                                
 17     0x00977100      0x03b47fde      "userdata"                                                                                                                                  
        attrs:  0x0000000000000000                                                                                                                                                  
        type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7                                                                                                                                
        guid:   fa2843af-8aa1-b946-b841-e17e7738138d 


After adding some traces, I understood that the information read from the eMMC doesn't match what I expected to read, but I don't understand why.

When reading, within the Bootloader_verifyMulticoreImage function, partition 1 of the eMMC is opened (which in this case should be the bootloader).
The first two data read are: 0x30 and 0x82, but then the length is different and the verification fail.

Note: I modified the offset of my image in the sysconfig of the example. I set it to 0, since my image inside the bootloader partition does not have an offset.

uint32_t Bootloader_getX509CertLen(uint8_t *x509_cert_ptr)
{
    uint32_t certLen = 0;
    uint8_t *pCertLen = (uint8_t *)&certLen;

    DebugP_logError("*x509_cert_ptr: 0x%x, 0x%x, 0x%x, 0x%x\r\n", *x509_cert_ptr, *(x509_cert_ptr+1), *(x509_cert_ptr+2), *(x509_cert_ptr+3));

    if ( *x509_cert_ptr != (uint8_t)0x30)
    {
        return (uint32_t)0;
    }

    *pCertLen = *(x509_cert_ptr + 1);

    /* If you need more than 2 bytes to store the cert length  */
    /* it means that the cert length is greater than 64 Kbytes */
    /* and we do not support it                                */
    if ((certLen > (uint32_t)0x80) &&
        (certLen != (uint32_t)0x82))
    {
        return (uint32_t)0;
    }

    if ( certLen == (uint32_t)0x82)
    {
        *pCertLen = *(x509_cert_ptr + 3);
        *(pCertLen + 1) = *(x509_cert_ptr + 2);
        /* add current offset from start of x509 cert */
        DebugP_logError("certLen: 0x%x\r\n", certLen);
        certLen += 3;
    }
    else
    {
        /* add current offset from start of x509 cert  */
        /* if cert len was obtained from 2nd byte i.e. */
        /* cert size is 127 bytes or less              */
        certLen += 1;
    }

    /* certLen now contains the offset of the last byte */
    /* of the cert from the ccert_start. To get the size */
    /* of certificate, add 1                             */

    return certLen + (uint32_t)1;
}

To check the memory content I did this:

Thank you,

Franco

  • Hello Franco,

    The default bootloader and eMMC driver do not support R/W from UDA partitions. Unless you have made changes in the drivers, the SBL will try to read the image from BOOT0 partition at your defined offset of 0x0.

    So, I would like to know if you have made any changes in the driver already to support R/W from the UDA partition.

    Regards,

    Prashant

  • Hello!

    Thank you for the response!

    I haven't made any changes to the driver yet, just the simple "printf" to try to understand the behavior, but I have already restored the original code.
    I forgot to mention in the original post that I am using SDK 09.01.00.39 (In case it's relevant).

    Regards,
    Franco

  • Hello,

    If you have not made changes then the SBL boots all the images from their defined offsets in Boot0 partition only. Please refer to the below configuration file which is generally used to flash all the listed images at the defined offsets in Boot0 partition by default.

    ~/ti/mcu_plus_sdk/am62p/09_01_00_39
    ❯ cat tools/boot/sbl_prebuilt/am62px-sk/default_sbl_emmc_linux_hs_fs.cfg
    #-----------------------------------------------------------------------------#
    #                                                                             #
    #      DEFAULT CONFIGURATION FILE TO BE USED WITH THE FLASHWRITER SCRIPT      #
    #                                                                             #
    #-----------------------------------------------------------------------------#
    #
    # By default this config file,
    # - points to pre-built flash writer, bootloader for this EVM
    # - The application image points to relative path of the ipc rpmsg linux application image for this EVM
    #   - Make sure this application is built before running this script
    # - You can customized this config file to point to your own bootloader and/or application images
    # - You can use --operation=flashverify-emmc if you just want to verify the flash contents and not flash the file.
    #
    
    
    # First point to sbl_uart_uniflash_stage1 binary, which initialises DDR and receives sbl_uart_uniflash_stage2 binary
    --flash-writer=sbl_prebuilt/am62px-sk/sbl_uart_uniflash_stage1.release.hs_fs.tiimage
    
    # When sending sbl_uart_uniflash_stage2 binary make sure to flash at SOC memory offset 0x0.
    # Points to sbl_uart_uniflash_stage2 binary, which function's as a server to flash one or more files to eMMC
    --file=../../examples/drivers/boot/sbl_uart_uniflash_multistage/sbl_uart_uniflash_stage2/am62px-sk/wkup-r5fss0-0_nortos/ti-arm-clang/sbl_uart_uniflash_stage2.release.appimage.hs_fs --operation=flash --flash-offset=0x0
    
    # Now send one or more files to flash or flashverify as needed. The order of sending files does not matter
    
    # When sending bootloader make sure to flash at offset 0x0. ROM expects bootloader at offset 0x0 of eMMC
    --file=sbl_prebuilt/am62px-sk/sbl_emmc_linux_stage1.release.hs_fs.tiimage --operation=flash-emmc --flash-offset=0x0
    
    # 2nd stage bootloader is flashed at 0x80000 or to whatever offset your bootloader is configured for
    --file=../../examples/drivers/boot/sbl_emmc_linux_multistage/sbl_emmc_linux_stage2/am62px-sk/wkup-r5fss0-0_freertos/ti-arm-clang/sbl_emmc_linux_stage2.release.appimage.hs_fs --operation=flash-emmc --flash-offset=0x80000
    
    # HSM image is flashed at 0x240000 or to whatever offset your bootloader is configured for
    --file=HSMAppimageGen/board/am62px-sk/hsm.appimage.hs_fs --operation=flash-emmc --flash-offset=0x240000
    
    # When sending application image, make sure to flash at offset 0x800000 (default) or to whatever offset your bootloader is configured for
    --file=../../examples/drivers/ipc/ipc_rpmsg_echo_linux/am62px-sk/mcu-r5fss0-0_freertos/ti-arm-clang/ipc_rpmsg_echo_linux.release.appimage.hs_fs --operation=flash-emmc --flash-offset=0x800000
    
    # Linux image is flashed at 0x1200000 or to whatever offset your bootloader is configured for
    --file=linuxAppimageGen/board/am62px-sk/linux.appimage.hs_fs --operation=flash-emmc --flash-offset=0x1200000
    
    # u-boot.img is flashed at 0x280000
    --file=linuxAppimageGen/board/am62px-sk/u-boot.img --operation=flash-emmc --flash-offset=0x280000
    

    After flashing with UART Uniflash and then setting the bootmodes to eMMC alternate boot, the SBL should be up and running booting all the other flashed images.

    Regards,

    Prashant

  • Hello,,

    When you mention the Boot0 partition, I understand that in the Android partition system, it would be the 'bootloader' partition (Start LBA 0x00002800) partition #1.
    If I use the offset relative to the partition, it would be 0. If I use the total offset in the eMMC, it would be 0x500000 (because the blocks are 512 bytes).
    But in either case, I don't get my binary.

    On the other hand, I can't use uniflash to flash the eMMC. Currently, I'm doing it through fastboot from uboot. The flashing process seems to be working fine because if I do a dump, I see my binary exactly where I expected it to be.

  • Hello,

    When you mention the Boot0 partition, I understand that in the Android partition system,

    This is not correct. The eMMC is hardware partitioned like shown below

    +---------+---------+--------+----------------------------------+
    |  boot0  |  boot1  |  rpmb  |          User Data Area          |
    +---------+---------+--------+----------------------------------+

    The Boot0 & Boot1 partitions are used as RAW partitions while generally UDA is logically partitioned using either MBR or GPT partition table. So, when I say the SBL boots all the images from Boot0 partition only, it means the Boot0 hardware partition and has nothing to do with the UDA partition.

    Now, the bootloader and eMMC driver in MCU+ SDK only supports R/W from Boot0 partition so all the images shown in the previous config file are flashed by UART Uniflash tool to Boot0 partition only at the defined offsets. Then, the images boots from the same Boot0 partition as well.

    Regards,

    Prashant

  • Hello,

    Ah, that makes sense! Now I understand my problem. I wasn't familiar with the boot partitions of the memory.
    I just tried it, and it worked perfectly!
    To avoid using uniflash, I used the following sequence:


    mmc read ${loadaddr} 0x00002800 0x1de (${loadaddr} somewhere to temporarily store the binary in RAM, 0x00002800 code partition offset, 0x1de bin size)
    mmc dev 0 1
    mmc write ${loadaddr} 0x0 0x1de (0x0 offset configured in syscfg, 0x1de bin size)

    Thank you very much for your help,
    sorry for the inconvenience
    Regards

    Franco

  • No worries, Franco. Always happy to help!!