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] AM64,AM243: How to optimize authentication time in SBL to achieve fast boot?

Part Number: AM6442

Is there a way to optimize the authentication time for AM64 and AM243 devices, as it is currently too large and is impacting the overall boot time?

  • The high authentication time is caused by using authentication type 1, which is slower compared to authentication type 2. Switching to authentication type 2 will significantly reduce your SBL boot time.

    Requirement for authentication type-2:

    When using authentication type 2, SYSFW uses some memory to temporarily load the appimage for authentication (usually denoted by the gAppimage buffer). In the SDK examples, DDR is used for this. If your custom device doesn't have DDR (like the am243-lp device) or any additional memory that can accommodate your appimage, then it might not be possible to use authentication type 2 due to memory constraints. However, if your application is small enough to fit into MSRAM, then it is OK to use authentication type 2 for these devices as well.

    To switch to authentication type-2, you will have to follow these steps:

    Step 1: Change Authentication Type for your Multicore/Linux Appimage to 2:

    To use authentication type-2 for any appimage, you will have to modify the signing command in the makefile of that example and change --authtype parameter from 1 to 2, For reference, you can check the following patch for the hello_world example:

    diff --git a/examples/hello_world/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile b/examples/hello_world/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile
    index 2f8ad35e..977f7eaa 100644
    --- a/examples/hello_world/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile
    +++ b/examples/hello_world/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile
    @@ -312,10 +312,10 @@ ifeq ($(DEVICE_TYPE), HS)
     # Sign the appimage using appimage signing script
     ifeq ($(ENC_ENABLED),no)
            @echo Boot image signing: Encryption is disabled.
    -       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS)
    +       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 2 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS)
     else
            @echo Boot image signing: Encryption is enabled.
    -       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS)
    +       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 2 --key $(APP_SIGNING_KEY) --enc y --enckey $(APP_ENCRYPTION_KEY) --output $(BOOTIMAGE_NAME_HS)
            $(RM) $(BOOTIMAGE_NAME)-enc
     endif
            $(RM) $(BOOTIMAGE_NAME)
    @@ -323,7 +323,7 @@ endif
            @echo  .
     else
     # Sign the appimage for HS-FS using appimage signing script
    -       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 1 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS)
    +       $(PYTHON) $(APP_IMAGE_SIGN_CMD) --bin $(BOOTIMAGE_NAME) --authtype 2 --key $(APP_SIGNING_KEY) --output $(BOOTIMAGE_NAME_HS_FS)
            $(RM) $(BOOTIMAGE_NAME)
            @echo  Boot image: am64x:r5fss0-0:nortos:ti-arm-clang $(BOOTIMAGE_PATH)/$(BOOTIMAGE_NAME_HS_FS) Done !!!
            @echo  .

    You will have to make similar changes for your applicaiton.

    Step 2: Rebuild App Images

    After making the authtype changes, rebuild your appimages with the new authentication type settings.

    Step 3: Apply Bootloader Patch for AuthType 2

    diff --git a/source/drivers/bootloader/bootloader.c b/source/drivers/bootloader/bootloader.c
    index 8f222f42..b4217760 100644
    --- a/source/drivers/bootloader/bootloader.c
    +++ b/source/drivers/bootloader/bootloader.c
    @@ -727,7 +727,7 @@ int32_t Bootloader_verifyMulticoreImage(Bootloader_Handle handle)
     #ifdef  BOOTLOADER_SCRATCH_MEM_SUPPORT
                         if(config->enableScratchMem == BOOTLOADER_SCRATCH_MEM_ENABLE){
                             /* At this point the image is in RAM, change bootmedia from OSPI to memory */
    -                        gMemBootloaderArgs.appImageBaseAddr = (uint32_t)(config->scratchMemPtr) + certLen;
    +                        gMemBootloaderArgs.appImageBaseAddr = (uint32_t)(config->scratchMemPtr);    //For authtype 2, SYSFW removes certificate and wri
    te only the image back to scratchMemPtr
                             gMemBootloaderArgs.curOffset = 0U;
     
                             config->fxns = &gBootloaderMemFxns;

    Step 4: Rebuild Libraries and SBL

    After applying the bootloader.c patch, you must rebuild the libraries and SBL. 

    Refer to this to rebuild the libraries: https://software-dl.ti.com/mcu-plus-sdk/esd/AM64X/11_02_00_24/exports/docs/api_guide_am64x/MAKEFILE_BUILD_PAGE.html#autotoc_md614 

  • Test Results:

    Size of Multicore Appimage: 228kB (ipc_rpmsg_echo_linux)

    Size of Linux Appimage: 988kB

    Default Boot time with Auth type 1:

    DMSC Firmware Version 11.0.7--v11.00.07 (Fancy Rat)
    DMSC Firmware revision 0xb
    DMSC ABI revision 4.0
    
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media       : undefined 
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Image Size  : 0 KB 
    KPI_DATA: [BOOTLOADER_PROFILE] Cores present    : 
    KPI_DATA: [BOOTLOADER PROFILE] System_init                      :      25676us 
    KPI_DATA: [BOOTLOADER PROFILE] Drivers_open                     :       1636us 
    KPI_DATA: [BOOTLOADER PROFILE] Board_driversOpen                :     115879us 
    KPI_DATA: [BOOTLOADER PROFILE] App_loadLinuxImages              :     238094us                                                                
    KPI_DATA: [BOOTLOADER PROFILE] App_loadImages                   :      75741us                                                                
    KPI_DATA: [BOOTLOADER_PROFILE] SBL Total Time Taken             :     457028us

    Boot time with Auth type 2:

    DMSC Firmware Version 11.0.7--v11.00.07 (Fancy Rat)
    DMSC Firmware revision 0xb
    DMSC ABI revision 4.0
    
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media       : undefined                                                                                   
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Image Size  : 0 KB                                                                                        
    KPI_DATA: [BOOTLOADER_PROFILE] Cores present    :                                                                                             
    KPI_DATA: [BOOTLOADER PROFILE] System_init                      :      25670us                                                                
    KPI_DATA: [BOOTLOADER PROFILE] Drivers_open                     :       1636us                                                                
    KPI_DATA: [BOOTLOADER PROFILE] Board_driversOpen                :     115680us                                                                
    KPI_DATA: [BOOTLOADER PROFILE] App_loadLinuxImages              :      44313us                                                                
    KPI_DATA: [BOOTLOADER PROFILE] App_loadImages                   :      31293us                                                                
    KPI_DATA: [BOOTLOADER_PROFILE] SBL Total Time Taken             :     218594us