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.

OAD with __no_init variables

Other Parts Discussed in Thread: CC2541

Hello,

I have an CC2541 application that includes the OAD features.

Is there a good way to configure __no_init variables for an exact address?

To make sure I can find the values after a firmware upgrade, i.e. both application versions knows were to find them.

Regards,

TMA

  • Hi TMA,

    It seems IAR allows you to place a __no_init variable in XDATA using a pragma:

    #pragma location=0x1000
    __no_init uint8 myExactAddressVariable;
    
    int main(void)
    {
      myExactAddressVariable = 0xF;
    ....
    }

    .:svend

  • FYI: Depending on what you are trying to achieve it might be worth noting that a __no_init variable will keep its new set value through a SW reset when doing OAD.
  • But does it? I've been testing this with OAD and yes, the __no_init variables keeps their set values if I only update the image id (e.g. from A to B).
    On the other hand, they do not retain values if really updating to a modified new firmware and I guess that makes sense since it's effectively a new firmware running after the SW reset... or am I misstaken here?
  • It seems that way. Running the following program will cause the code to end up in the else clause.

    Note that the variable is in RAM which is not overwritten by updating the flash image. The BIM (boot loader image) might have overwritten it though.
    When doing "Download and debug" in IAR the variable value is cleared however. This is due to the pin reset being done by the debugger.

    #pragma location=0x1000
    __root __no_init uint8 myExactAddressVariable;
    
    #pragma optimize=none
    int main(void)
    {
      if(myExactAddressVariable != 0xAA) {
        myExactAddressVariable = 0xAA;
      }
      else {
        while(1); -> Code ends up here when doing "Debug without download"
      }
      SystemReset();
      while(1);
    
    }