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.

TMS320F28335: Behavior of un-Initialized global variable RAM

Part Number: TMS320F28335

Hi Experts,

My customer's initilize sequence of their application relys on serverial global variable that has no initial value on their declaration. It appears that their application would break if the initial value appear to some certain values (due to their logic design). 

  1. If the global variable has no initial at the declartion, what's the inital value? We obsere in different board that the value is different and may happens to be one or two certain values.
  2. If it depends on the value on RAM, What's the initial value of RAM upon power cycle?
  3. If it is ramdom, what about the RAM used by boot rom? For the address that falls into the range that used byt boot ROM, when the CPU run to main, Is the value on the address fixed? or it may varies? What's the factor of the variation?

Regards,

Hang

  • Hi Hang,

    Let me check with the team and get back to you.

    Thanks and Regards,

    Ira

  • Hi Ira, 

    Is there any update?

  • Hi Hang,

    The startup routine calls the _c_int00 function which should ideally assign 0 value to all the uninitialized global variables which are placed in the .bss section of memory. This will happen when you power cycle the board, before main() gets executed. 

    Even though the TI C runtime should zero-initialize all global variables, you mentioned seeing different values on different launchpads. This could happen for a few specific reasons:

    1. Missing or Corrupted Startup Code: If the startup files were modified or if there's an issue with the toolchain, the zeroing of .bss might be skipped.
    2. Memory Corruption: Another part of your code might be writing to these variables before you check them.
    3. Optimization Issues: Aggressive compiler optimizations might affect the behavior of variables if they are not properly used.
    4. Volatile Variables: If the variables are not declared volatile but are being accessed by multiple threads or ISRs, their values might appear to change unexpectedly.

    Thanks,

    Ira

  • Hi Ira,

    Assuming the zero-initialization are skip, what would be its value when power on? 

  • We are finding the root cause to the variation between boards. Since all boards runs the same software, I believe the items above would not introduce variation between boards, right? 

  • Hi Hang, 

    It is hard to say what the exact value will be if the cinit routines are skipped. It will depend on whatever was in RAM before, which can change based on

    1. board to board power-up state differences

    2. reset type (did you use external reset/ watchdog reset)

    3. some previous application that was loaded on the device

    So it can be indeterminate/garbage value.

    Thanks,

    Ira

  • Can you check if the _c_int00 function is getting called? Is your program jumping to main() when you load it or are you entering through somewhere else?

    Thanks,

    Ira

  • Hi Ira,

    We will check the initialization process again. 

    In the meantime, we want to know more about the initial state of the ram. 

    As you mentioned:

    1. board to board power-up state differences

    2. reset type (did you use external reset/ watchdog reset)

    3. some previous application that was loaded on the device

    Let's only focus on the first time the board is powered. in this case we should be able to ignore factor 2 and 3.(is it?)

    For item 1, what's the board-to-board differences you refer to? Could you give examples that which board-to-board differences that might affect the value of RAM the device is powered for the first time?

    Note that we are not trying to actually identify what's affect the RAM initial values, we are just trying to rule out or confirm the possibilities that the RAM may hold different values on different boards after power on, even though the hardware design and software are the same.

    Regards,

    Hang

  • Hi Hang,

    Can you tell me when exactly are you seeing different RAM values? Is it right after the POR or somewhere else in program? Have you placed any functions/variables in the .noinit (like your global variables) section of the linker? When you do a POR, the bootROM should initialize all RAM to 0. Also where is your .bss section placed in the linker?