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: MCUBoot Example Code: Memory Read Operation

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

Hello TI Team,

I'm using CC2340R5 with SDK 8.40 and MCUBoot example code for self FOTA implementation using UART through external interface.

Right now, I did write some data into application code using NVM API's at a fixed address. Below is the code snippet.

I want to read the same flag in MCUBoot at the same address to cross verify but not sure how to do it.

Because I guess NVM related files or access is disabled in MCUBoot.

I just want to understand how to access same memory region in both Application code & MCUBoot code?

         uint32_t flag = 0xA5A5A5A5;

         nvsHandle2 = NVS_open(MCUBOOT_TRIG_FLG_ADDR, NULL);

         nvsRes = NVS_write(nvsHandle2, 0, (uint8_t *)&flag, 4, NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
         if(nvsRes != NVS_STATUS_SUCCESS)
         {
             return nvsRes;
         }

         //Inform to boot-loader that new image is available.
         /*This is tested now that the Application is jumping to MCUBoot*/
        #ifdef SECURE_BOOT
            HapiSbSetId( 3 ); // Indicate to secure boot that new image is ready
        #endif

        SystemReset();
  • Hi Rushikesh,

    MCUboot will typically not use TI Drivers such as NVS in order to remain lightweight and consume the least amount of Flash memory.  You can find flash open/close/read/erase/write operations inside of flash_map_backend/flash_map_backend.c of the MCUboot project workspace, and all sorts of usage inside of the bootutil/src folder.  Either these APIs or the NVS equivalents have similar paremeters and ultimately lead to Flash driverlib APIs, thus you should be enabled to interpret between application and MCUboot usage.  You can follow the "Debug an OAD Project" section of the BLE OAD SLA for additional debug guidance.

    Regards,
    Ryan

  • Hello Ryan,

    Thanks for your inputs.

    I'm directly reading the data at the same address as application sets up the flag at. 

    Below is how I read the data:

    void mcuboot_flash_read(uint32_t addr, void *dst, uint32_t len)
    {
            if (!is_valid_range(addr, len))
               return; // or assert

          memcpy(dst, (const void *)addr, len);
    }

    This approach is working in my case and now I'm able to read a particular flag value set by application at a fixed location.

    I did verify it in MCUBoot using LED blink as a confirmation.

    I have a follow up question for you:

    Below is how I've configured memory map in syscfg of MCUBoot example code & I get the error for this configuration as: Description Resource Path Location Type
    #10325-D creating memory range $BOUND$0x7c000 to accommodate BOUND section ".TI.bound:flashBuf0" mcuboot_LP_EM_CC2340R5_nortos_ticlang C/C++ Problem

    If there's anything wrong am I doing here, then please can you correct me?

    MCUboot - NVS

      

    MCUBoot 

    BLE Dual Image Example Code Memory map:

    CONFIG_NVSINTERNAL

    CONFIG_NVSINTERNAL1

    CONFIG_NVS_APP

  • By creating the NVS module instance in the SysConfig file of your MCUboot project, you are creating a reserved section of memory that is not accounted for inside of the command linker file (mcuboot_cc2340r5.cmd).  This is typically a warning (saying your application could potentially run into NVS reserved areas) which does not prevent CCS from completing the project build.  You could modify the *.cmd but it is unnecessary to add the NVS instance to your MCUboot project since you are not using the NVS TI Driver APIs and the command linker file is configured such that the MCUboot flash never intersects 0x7C000-0x7FFFF.

    Regards,
    Ryan

  • Hi Jan,

    So, which part of memory should I use in MCUBoot for internal operations. The same, I'll be using in application as well.

    For example, I set a flag or update some metadata in Application at some fixed address in internal memory & want to access the same in MCUBoot to verify that flag/metadata.

    Best Regards,

    Rushikesh.

  • The application's NVRAM (0x7C000-0x7FFFF) is fine to access through MCUboot, I was simply discussing how you would configure the MCUboot project to ensure that the project build never overlaps with or overwrites the NV memory section which is what your linker step produced the warning for.

    https://software-dl.ti.com/ccs/esd/documents/ccs_files_in_projects.html
    https://software-dl.ti.com/ccs/esd/documents/sdto_cgt_Linker-Command-File-Primer.html

    Regards,
    Ryan