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.

TM4C1294NCPDT: CallApplication(ui32StartAddr) API is not executing

Part Number: TM4C1294NCPDT

Tool/software:

Hi E2E Team,

We are trying modify usb_stick_update example code to upgrade the firmware over air (FOTA), but unfortunately application code isn't executing

Please find the below details of our setup,

-> In bootloader code following ports are activated,

  • UART6 : Debugging
  • SSI3 : Serial Flash (8 Mb)

-> Serial Flash is used to store the firmware binary file downloaded from ftp server

-> Storing operation of firmware in serial flash is successful in application program

-> Then reset operation is performed using below code in application program

HWREG(FORCE_UPDATE_ADDR) = u32_updateResource; //Here FW upgrade resource information is available

HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;

(*((void (*)(void))(*(uint32_t *)0x2c)))();

-> In bootloader code, serial flash data (for FW upgrade) reading is done following manner

uint32_t ui32Data = 0;
int16_t i16_dataByte = 0;

static int i32_bytesReadCount = FIRMWARE_FILE_SIZE;

for(i16_dataByte = 0; i16_dataByte < SF_DATA_CHUNK; i16_dataByte++)
{
SSIDataPut(SSI3_BASE, (uint32_t)0xFF);
SSIDataGet(SSI3_BASE, &ui32Data);

g_ui8SectorBuf[i16_dataByte] = (uint8_t)(ui32Data & 0xFF);
}

g_ui8SectorBuf[SF_DATA_CHUNK] = 0;

i32_bytesReadCount -= SF_DATA_CHUNK;

if(i32_bytesReadCount <= 0)
return 0;
else
return i32_bytesReadCount;

Through UART debugging what we have observed,

-> All necessary peripheral initialization is successful

-> Stack Pointer and Program Counter value is found valid

-> The moment CallApplication(ui32StartAddr) API is invoked,

  • Program is getting stuck
  • No execution of application code, even after controller reset and power restart operation
  • Application code start address : 0x00008000
  • Firmware File name PROJECTBIN
  • Firmware Max File size : 9000000
  • FORCE UPDATE ADDR : 0x20004000
  • FLASH SIZE : 1 MB (1024 * 1024)

Please help to resolve this issue by making application code run after upgradation of firmware

Thanks

  • -> Storing operation of firmware in serial flash is successful in application program

    ok. I assume your new firmware is successfully programmed to the external serial flash. 

    How did you program the external serial flash? The usb_stick_update example assumes the firmware is already stored in the usb stick. The usb stick is pre-stored with the firmware using the PC filesystem. You must have your own means of storing the firmware to the serial flash, right? 

    -> Then reset operation is performed using below code in application program

    HWREG(FORCE_UPDATE_ADDR) = u32_updateResource; //Here FW upgrade resource information is available

    HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;

    (*((void (*)(void))(*(uint32_t *)0x2c)))();

    I suppose this is the code in your bootloader, correct? I can see the similar code in usb_stick_update.c file. 

    When you run HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ, it is going to do software reset. Why do you put (*((void (*)(void))(*(uint32_t *)0x2c)))() after it? I don't think it will get executed since the reset has already happened. What do you have the at vector 0x2C? Are you even using it?

    -> The moment CallApplication(ui32StartAddr) API is invoked,

    Is the ui32StartAddr equal to 0x8000?

    • No execution of application code, even after controller reset and power restart operation
    • Application code start address : 0x00008000
    • Firmware File name PROJECTBIN
    • Firmware Max File size : 9000000
    • FORCE UPDATE ADDR : 0x20004000
    • FLASH SIZE : 1 MB (1024 * 1024)

    Your firmware is 9MB unless you you mistype for 900kB. How do you run the entire firmware? You can only read a partial portion of the 9MB and store them on the internal flash. The internal flash is only 1MB max and it starts at 0x8000. 

  • 1. ok. I assume your new firmware is successfully programmed to the external serial flash. ...

    In example code usb is available but we have implemented external serial flash

    2. Is the ui32StartAddr equal to 0x8000?

    Yes

    3. I suppose this is the code in your bootloader, correct? I can see the similar code in usb_stick_update.c file.  ...

    It's usuage is mentioned in bootloader code, we have used in application code

    4. Your firmware is 9MB unless you you mistype for 900kB. How do you run the entire firmware?  ...

    Thanks for pointing, it's a typo error

    But program file it is correct only.

    So max executable binary file size can go upto 900000, but considering current program file it is 218kb only

    As I mentioned, application code call api isn't executing and there is no SP or PC register error

  • HI,

    uint32_t ui32Data = 0;
    int16_t i16_dataByte = 0;

    static int i32_bytesReadCount = FIRMWARE_FILE_SIZE;

    for(i16_dataByte = 0; i16_dataByte < SF_DATA_CHUNK; i16_dataByte++)
    {
    SSIDataPut(SSI3_BASE, (uint32_t)0xFF);
    SSIDataGet(SSI3_BASE, &ui32Data);

    g_ui8SectorBuf[i16_dataByte] = (uint8_t)(ui32Data & 0xFF);
    }

    g_ui8SectorBuf[SF_DATA_CHUNK] = 0;

    i32_bytesReadCount -= SF_DATA_CHUNK;

    if(i32_bytesReadCount <= 0)
    return 0;
    else
    return i32_bytesReadCount;

      I don't see in your pasted code how you program the internal flash. I only see you reading the external serial flash. I suppose you have program your 218kB of firmware to the internal flash successfully at 0x8000. Is that correct? Can you use the memory browser to view the internal flash content starting at 0x8000 and make sure your new firmware is indeed programmed?

    -> Then reset operation is performed using below code in application program

    HWREG(FORCE_UPDATE_ADDR) = u32_updateResource; //Here FW upgrade resource information is available

    HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;

    (*((void (*)(void))(*(uint32_t *)0x2c)))();

    I'm still not clear with the above code? Is this part of the firmware that will start at 0x8000? Or is the above code part of the bootloader that starts at 0x0?

  • Thanks for your response

    There was an issue with external serial flash

    It's working fine now ....