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.

MCU-PLUS-SDK-AM243X: How to change the boot section after a boot failure

Part Number: MCU-PLUS-SDK-AM243X

Tool/software:

Hi team,

I develop sbl_ospi of mcu_plus_sdk_am243x.

If booting fails, I'm considering a method to boot from another section.

Currently, if authentication fails, the boot section is changed as follows.

However, since Bootloader_parseMultiCoreAppImage() is usually used only once,

I am concerned that using it multiple times may cause problems with variable initialization, etc.

Is there any problem using it like this?

    /* Initialize PRU Cores if applicable */
    Bootloader_Config *cfg = (Bootloader_Config *)bootHandle;
    bootConfig = (Bootloader_Config *)bootHandle;
    bootConfig->scratchMemPtr = gAppimage;
    if(TRUE == cfg->initICSSCores)
    {
        status = Bootloader_socEnableICSSCores(BOOTLOADER_ICSS_CORE_DEFAULT_FREQUENCY);
        DebugP_assert(status == SystemP_SUCCESS);
    }
    
    /* If booting from 0x100000 fails, switch to 0x200000 */
    uint32_t BootSelect=0;
    if(BootSelect==0){
        ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = 0x100000;
        DebugP_log("Change boot section to 0x100000\r\n");
        status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
        if(status != SystemP_SUCCESS){
            BootSelect = 1;
        }
    }
    if(BootSelect==1){
        ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = 0x200000;
        DebugP_log("Change boot section to 0x200000\r\n");
        status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
        if(status != SystemP_SUCCESS){
        }
    }

Best regard

Oyama

  • Hi Oyama,

    However, since Bootloader_parseMultiCoreAppImage() is usually used only once,

    I don't see any issues with this method, there is no restriction in reference to calling this API only one time.

    I am concerned that using it multiple times may cause problems with variable initialization, etc.

    This shouldn't cause an issue if your image is failing at the authentication stage, but if you do observe any issues with this then you can try using different variable for different sections.

    Best regards,

    Meet.

  • Hi Meet,

    you can try using different variable for different sections

    What does variable refer to?

    After reading an empty section filled with 0xFF,

    Bootloader_parseMultiCoreAppImage() always returns an error even though the section it read was correct.

    Is there a way to avoid this?

        /* From offset 0x100000, it is filled with "0xFF"*/
        uint32_t BootSelect=0;
        if(BootSelect==0){
            ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = 0x100000;
            DebugP_log("Change boot section to 0x100000\r\n");
            status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
            if(status != SystemP_SUCCESS){
                BootSelect = 1;
            }
        }
         /* From offset 0x200000, it is Normal image data*/
        if(BootSelect==1){
            ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = 0x200000;
            DebugP_log("Change boot section to 0x200000\r\n");
            status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
            if(status != SystemP_SUCCESS){
                //It will reach this section
            }
        }

    Best regard

    Oyama

  • After reading an empty section filled with 0xFF,

    Bootloader_parseMultiCoreAppImage() always returns an error even though the section it read was correct.

    Could you elaborate this, I wasn't completely able to understand this. What is the usecase behind reading an empty section using Bootloader_parseMultiCoreAppImage, this API is used to read the appimage, it expects the appimage in a certain format with x509 certificate in the header, if you try to read any random part of the memory then it is expected that this API gives an error.

    What does variable refer to?

    bootHandle:https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/11_00_00_15/exports/docs/api_guide_am243x/group__DRV__BOOTLOADER__MODULE.html#ga8c2fc1e55aeabdc0aeb19b979fa8d662

    This is configured from gBootloaderConfig variable generated by syscfg.

    bootImageInfo: https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/11_00_00_15/exports/docs/api_guide_am243x/structBootloader__CpuInfo.html

    This data structure contains information related all CPUs, this is filled by Bootloader_parseMultiCoreAppImage.

    Best Regards,

    Meet.

  • Hi Meet,

    Even if it fails to boot at offset 0x100000, I want it to boot from 0x200000.

    However, if the data at offset 0x100000 is uncertified random data,

    not only will it return an error, but subsequent boots from 0x200000 may also fail.

    Best regard

    Oyama

  • Hi Oyama,

    not only will it return an error, but subsequent boots from 0x200000 may also fail.

    Could you please explain what issue you are observing while booting form 0x200000? Is there any error message in the logs or the program is stuck somewhere? Could you share the boot logs from UART terminal.

    Best regards,

    Meet.

  • Hi Meet,

    I tried it on AM243x-LP.

    I added this code to sbl_ospi_am243x-lp.

                /* Initialize PRU Cores if applicable */
                Bootloader_Config *cfg = (Bootloader_Config *)bootHandle;
                bootConfig = (Bootloader_Config *)bootHandle;
                bootConfig->scratchMemPtr = gAppimage;
                if(TRUE == cfg->initICSSCores)
                {
                    status = Bootloader_socEnableICSSCores(BOOTLOADER_ICSS_CORE_DEFAULT_FREQUENCY);
                    DebugP_assert(status == SystemP_SUCCESS);
                }
    
                uint32_t ImageOffset=0;
    
                ImageOffset=0x200000;
                ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = ImageOffset;
                DebugP_log("Change boot section from 0x200000\r\n");
                DebugP_log("There is no data in this section\r\n");
                status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
                if(status==SystemP_SUCCESS){
                    DebugP_log("Success boot from 0x%x\r\n",ImageOffset);
                }
                else{
                    DebugP_log("False boot from 0x%x : status=0x%x\r\n",ImageOffset,status);
                }
    
                ImageOffset=0x80000;
                ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = ImageOffset;
                DebugP_log("Change boot section from 0x80000\r\n");
                DebugP_log("This section contains the default hs_fs applications\r\n");
                status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
                if(status==SystemP_SUCCESS){
                    DebugP_log("Success boot from 0x%x\r\n",ImageOffset);
                }
                else{
                    DebugP_log("False boot from 0x%x : status=0x%x\r\n",ImageOffset,status);
                }
    
                ImageOffset=0x80000;
                ((Bootloader_FlashArgs *)(cfg->args))->appImageOffset = ImageOffset;
                DebugP_log("Try again boot section from 0x80000\r\n");
                DebugP_log("This section contains the default hs_fs applications\r\n");
                status = Bootloader_parseMultiCoreAppImage(bootHandle, &bootImageInfo);
                if(status==SystemP_SUCCESS){
                    DebugP_log("Success boot from 0x%x\r\n",ImageOffset);
                }
                else{
                    DebugP_log("False boot from 0x%x : status=0x%x\r\n",ImageOffset,status);
                }
            
    
                uint32_t coreVariant = Bootloader_socGetCoreVariant();
                /*Checks the core variant(Dual/Quad) */

    The boot log is as follows

    DMSC Firmware Version 11.0.7--v11.00.07 (Fancy Rat)
    DMSC Firmware revision 0xb
    DMSC ABI revision 4.0
    
    Change boot section from 0x200000
    There is no data in this section
    False boot from 0x200000 : status=0xffffffff
    Change boot section from 0x80000
    This section contains the default hs_fs applications
    False boot from 0x80000 : status=0xffffffff
    Try again boot section from 0x80000
    This section contains the default hs_fs applications
    Success boot from 0x80000
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media       : NOR SPI FLASH
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media Clock : 100.000 MHz
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Image Size  : 272 KB
    KPI_DATA: [BOOTLOADER_PROFILE] Cores present    :
    r5f0-0

    Best regard

    Oyama

  • Hi Oyama,

    I see from the logs that the boot succeeds after you run the bootloader twice for the offset 0x80000, let me try to see what could be the issue here. I will try reproduce this at my end, and update you on the results.

    Best regards,

    Meet.