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.

CC2340R5: After adding the OAD function in the project, it takes about 4 seconds for the app to run after power-on. How can I quickly enter the app program?

Part Number: CC2340R5

Tool/software:

After adding the OAD function in the project, it takes about 4 seconds for the app to run after power-on. How can I quickly enter the app program?From the documentation, I learned that after the device is powered on, the mcuboot program will verify the integrity of the app. So, how can I skip the verification under specific requirements?

  • Hi,

    Which SDK are you using?

    It seems the default mcuboot in 9.10 F3 SDK already bypasses image validation, which contributes some seconds of time between power-on and application starting: MCUBOOT_VALIDATE_PRIMARY_SLOT

    Please refer to some related threads:

    1. CC2340R5: MCUBoot verification has delay to start application - Bluetooth forum - Bluetooth®︎ - TI E2E support forums
    2. CC2340R5: MCUBoot speed optimization - Bluetooth forum - Bluetooth®︎ - TI E2E support forums

    Thanks,
    Toby

  • 1.我使用的 SDK 版本是 simplelink_lowpower_f3_sdk_8_10_01_02。在这个版本中,似乎没有启用 MCUBOOT_VALIDATE_PRIMARY_SLOT。

    2.定义 slot 时,主 slot 不应该是一个 app 程序吗? 第二个插槽是持久性程序吗? 因此,我将它的宏定义修改为

    然而,经过这样的修改后,没有任何效果。从待机模式运行到 app 程序仍然需要大约 4 秒。

  • I have now built the MCUBoot project using the new SDK version, which is 9_11_00_18. The time it takes for the built project to wake up from standby mode and run to the app program still seems to be around 4 seconds, without any acceleration. Moreover, I found that when building the MCUBoot project, there is no <Release> build method, only the <DeBug> build method.

  • Hi,

    You can start by disabling the LED function as well. The LED function's take up about 1.5 seconds as well. Try commenting out all the LED functions.

    You can set a flag and store it in the internal flash. 
    Based on the flag value you can decide whether or not the image validation must be done.

    The "mcuboot_flag" shown below can be set during OAD once and can be cleared from your main application code to zero.

    boot_image_check(struct boot_loader_state *state, struct image_header *hdr,
                     const struct flash_area *fap, struct boot_status *bs)
    {
        TARGET_STATIC uint8_t tmpbuf[BOOT_TMPBUF_SZ];
        uint8_t image_index;
        int rc;
        FIH_DECLARE(fih_rc, FIH_FAILURE);
    
    #if (BOOT_IMAGE_NUMBER == 1)
        (void)state;
    #endif
    
        (void)bs;
        (void)rc;
    
        image_index = BOOT_CURR_IMG(state);
    
    #ifdef MCUBOOT_ENC_IMAGES
        if (MUST_DECRYPT(fap, image_index, hdr)) {
            rc = boot_enc_load(BOOT_CURR_ENC(state), image_index, hdr, fap, bs);
            if (rc < 0) {
                FIH_RET(fih_rc);
            }
            if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs)) {
                FIH_RET(fih_rc);
            }
        }
    #endif
    
        if(mcuboot_flag[0] == 0x01)
        {
            fih_rc = FIH_SUCCESS;
            FIH_RET(fih_rc);
        }
        else
        {
        FIH_CALL(bootutil_img_validate, fih_rc, BOOT_CURR_ENC(state), image_index,
                 hdr, fap, tmpbuf, BOOT_TMPBUF_SZ, NULL, 0, NULL);
    
        FIH_RET(fih_rc);
        }
    }

  • Thanks Sandeep for sharing your insight!

    Hi Cherry,

    built project to wake up from standby mode and run to the app program

    Can you clarify one thing for us to better help you?
    Based on your statement here, it seems the 4sec is measured from standby to wakeup. Please note that MCUBoot only runs after a reset (either power on or low signal input to RST). 

    Thanks,
    Toby

  • Sorry, it was my statement that was incorrect. To be precise, it takes approximately 4 seconds for the app to run from the shutdown mode after being awakened. By observing the current, it can be found that when it is awakened from shutdown, the current at the time of awakening is about 2-3mA, and it takes about 4 seconds to run to the app program. Through testing, I found that when waking up from shutdown, it neither runs mcuboot nor persistent. Therefore, it is very difficult to understand where it starts running and it is impossible to precisely locate the problem.

  • It is indeed a good approach to determine whether to skip validation by setting a flag bit in the internal flash. However, perhaps my statement is not quite correct. Regarding the time it takes for the CC2340 to run from mcuboot to the app program after power-on, I am more concerned about how to shorten the time from 4 seconds after waking up from shutdown mode to the app program. Because when I wake up from shutdown mode, the CC2340 has not run mcuboot. The persistent program was not run either, which made me unsure where the program would start running when waking up after adding the OAD function. Because when I don't add the OAD function, the program is an app program that runs immediately after being awakened from shutdown mode.

  • After I added the flag bit in the mcuboot program, the time for the module to run from shutdown wake-up to the app was shortened from 4 seconds to about 1.8 seconds. But could this time be even shorter? From the phenomenon of the led in the mcuboot program, when no flag bit is added, the red light will flash first when powered on. About 2 seconds later, after the successful verification of the app program, the green light will flash three times. When the marker bit is added, after power-on, it directly skips the red light for about 2 seconds and flashes the green light three times. I guess that after adding the flag bit, the shortened time is the 2 seconds it takes for the red light to be on, which is the time for verifying the app program. Later, I will try to comment out the statement where the green light flashes three times to verify whether the time can be shorter.

  • Thank you very much, Sandeep and Toby.

    After I added the flag bit and disabled the led, the time from power-on to the app program, including from shutdown wake-up to the app program, all reached the ideal situation.

    To sum up the issue, when power is on or reset, the mcuboot program will run normally (i.e., the led light will be turned on), but when waking up from shutdown mode, the led light will not be turned on when running the mcuboot program. Currently, it is unknown what causes this. Due to the above issues, when I woke up from shutdown mode, the led light did not light up, which led me to mistakenly believe that the program was running abnormally, resulting in my failure to understand the program's operation mode.

    Thanks,

    Cherry