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.

MSPM0G3519: Problem in retriving data stored in memory after Reset

Part Number: MSPM0G3519

Hi,

 

I am using MSPM0G3519 Launchpad, By using this I am developing code for firmware upgrade.

I am using custom Bootloader.

I am doing following.

  1. Bootloader Code: This code runs after reset. Handles Flash copy (Temporary memory to Application Memory). Check whether upgrade requested using  a flag at memory 0x00007C00.

      2. Application Code: This is the 1st Firmware running . It stays at 0x00008000. It runs after         bootloader checks if any valid data present at 0x00008000. 

This code receives updates via BLE. the new firmware received is storing in 0x00058000. after completely receiving of the firmware, storing an update flag at location 0x00007C00. 

My Expectations:

After Reset, bootloader code will check whether update flag is present in 0x00007C00, if yes then it should copy the data from 0x00058000 to 0x00008000, then it should run the application.

But after reset, I am not getting any data at 0x00058000. Why it is getting erased after Reset?

Is there any settings I need to follow?

In runtime I already checked this by copying the data from 0x00058000 to 0x00008000, it is working fine. Now I want to copy after reseting the board.

Please guide me.

I got stucked at this point.

 

Thanks

  • 0x58000 is Flash bank 1

    0x08000 is Flash bank 0

    Both write operation to bank 0 and 1 need Flash API with Flashctl peripherals.

    But after reset, I am not getting any data at 0x00058000. Why it is getting erased after Reset?

    If you select the erase entire chip between resets when you try to start other debug session, there is possibility that 0x58000 is erased by debugger.

    Please double check after BLE received, 0x58000 has data.

    Only two possible method to erase the Flash: debugger and CPU run Flash API erase command.

    Is there any settings I need to follow?

    Try to check your debugger erase method, if you are using XDS110, try to select erase necessary region only.

  • Hi,

    Thanks. Before write I need to unprotect. It soved my issue.

    I am working on firmware upgrade. The code is working fine when I am upgrading a firmware of size <1KB. When I am taking a firmware of size 3KB it's not upgrading. What could be the reason.

    here I am sending the copy function to copy data from temp area to applicaiton area, as well as the jump to application function. I doubt the copy function is not copying the entire file. How to debug in run time, I don't understand.

    void jump_to_application(void)
    {
        __disable_irq();
        uint32_t sp = *(uint32_t *)APP_BASE;
        uint32_t reset = *(uint32_t *)(APP_BASE + 4);  
        if(sp != 0xFFFFFFFF)
        {
                DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
                delay_cycles(8000000);
                DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_2_PIN);

        }
        SCB->VTOR = APP_BASE;  
        ((void (*)(void))reset)();
    }
    #define FLASH_SECTOR_SIZE   2048

    void erase_application_area(void)
    {
        for (uint32_t addr = APP_BASE;
             addr < TEMP_BASE;
             addr += FLASH_SECTOR_SIZE)
        {
            __disable_irq();
            DL_FlashCTL_executeClearStatus(FLASHCTL);
            DL_FlashCTL_unprotectSector(
                FLASHCTL,
                addr,
                DL_FLASHCTL_REGION_SELECT_MAIN);

            DL_FlashCTL_eraseMemory(
                FLASHCTL,
                addr,
                DL_FLASHCTL_COMMAND_SIZE_SECTOR);
            DL_FlashCTL_waitForCmdDone(FLASHCTL);
            __enable_irq();
           
        }
       
    }
    RAMFUNC void copy_temp_to_application(void)
    {
        uint32_t offset = 0x00000000;
        uint32_t buffer[2];
        uint32_t current_sector = 0xFFFFFFFF;
       
        __disable_irq();
      //  NVIC_DisableIRQ(UART_1_INST_INT_IRQN);

        while (offset < firmware_size)
        {
           
            uint32_t app_addr = APP_BASE + offset;            
           
            /* Read 8 bytes from TEMP area */
            buffer[0] = *(uint32_t *)(TEMP_BASE + offset);
            //__BKPT(0);        
            buffer[1] = *(uint32_t *)(TEMP_BASE + offset + 4);
           
               if(*(uint32_t *)app_addr == 0xFFFFFFFF){
                DL_FlashCTL_unprotectSector(
                    FLASHCTL,
                    app_addr,
                    DL_FLASHCTL_REGION_SELECT_MAIN);
               gCmdStatus = DL_FlashCTL_programMemoryFromRAM64WithECCGenerated(
                FLASHCTL, app_addr , buffer);
               
                DL_FlashCTL_waitForCmdDone(FLASHCTL);
                }        
            offset += 8;
         
        }
      //  NVIC_EnableIRQ(UART_1_INST_INT_IRQN);
        __enable_irq();
           
    }
    In main loop I am doing following:
     if(is_update_requested())  
               {            
                clear_update_flag();
                erase_application_area();
                copy_temp_to_application();
               // NVIC_SystemReset();
               
               jump_to_application();
               }
    please help me on this
  • Hi, This demo have all the related API for your firmware update reference:

    C:\ti\mspm0_sdk_2_10_00_04\examples\nortos\LP_MSPM0G3519\bsl\secondary_bsl_uart

    For example:

    CMD_API_Flash_Range_Erase
    CMD_API_Program_Data
    CMD_API_Memory_Read_back
    CMD_API_startApplication

    Above BSL demo will help you a lot I think, here is the BSL docs:

    MSPM0 Bootloader User's Guide - Protocol

    https://www.ti.com/lit/pdf/slau887

    MSPM0 Bootloader (BSL) Implementation - How to use

    https://www.ti.com/lit/pdf/slaae88

    The code is working fine when I am upgrading a firmware of size <1KB. When I am taking a firmware of size 3KB it's not upgrading. What could be the reason.

    Recommend to follow BSL logic, Erase 1kB, program 1kB, then erase second 1kB, program 1kB. Or you can erase all 3kB first, then program firmware one by one.

    Also, you need to keep all the firmware region Flash empty, not overwrite by bootloader or other function.

    here I am sending the copy function to copy data from temp area to applicaiton area, as well as the jump to application function. I doubt the copy function is not copying the entire file. How to debug in run time, I don't understand.

    Don't test the entire flow at same time.

    You can enable one module one by one, test them one by one.

    Using other method, like send firmware to UART to double check.