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.

TMS320F28027: when do global variables generate?

Part Number: TMS320F28027

For example, I have bootloader project and app1 project on the device, and would like to upgrade the app project to app2 project.

In main.c of app1 project, there are code below:

int a=1;//global variables

main{}

In main.c of app2 project, there are code below:

int a=1;//global variables

float b=0.5;//global variables

main{}

1. After I upgrade the app project, the app2 project is on flash, the initial value of global variables are on the flash of the device, but how about the global variables "a and b" themselves?

2. I know that the initial value of global variables are copied to the global variables in the function c_int00, but after upgrade the app project, I can not run to c_int00 to initialize the global variables because c_int00 will finally run to main() function(bootloader project), but i would like to run into the app code, how can I initialize the global variables after upgrading the app project and also run to app code?

Thanks.

  • Howard

    1. The C boot routine copies the data from these tables in flash to initialized variables in the .ebss RAM section.
    2. See 7.9.1 Boot Hook Functions for System Pre-Initialization of the guide below. That might do what you want. Going to move to compiler forum to get confirmation from experts.

    See www.ti.com/.../spru514o.pdf

    Best regards
    Chris
  • Thanks for you reply, but I'm wondering when does the global variables themselves generate, not how they are initialized. Because after the app code upgrade, the number of global variables may increase, thus the .ebss will take larger RAM space, when does the device allocate larger space for these variables?
  • Howard,

    Can you clarify what you mean by "generate"? It's not clear what you are asking.

    Best regards
    Chris
  • For example, after I upgrade the app project, the number of global variables may increase, thus the device need larger memory space to store .ebss, when will the device allocate larger RAM space to store .ebss?

  • Howard Zou said:
    when will the device allocate larger RAM space to store .ebss?

    It doesn't work that way.  When you build, and the compiler sees the definition of a global variable, it emits assembler directives that reserve space in the .ebss section for that object file.  The linker combines these .ebss sections from all the object files into one output section also named .ebss.  The linker command file tells the linker where in memory to allocate this .ebss output section.  The linker part of this process is described in the article Linker Command File Primer.

    Thanks and regards,

    -George

  • Thank you very much.

    The information about the .ebss space requirement, for example it takes 0x080. This information is stored in flash, right? After the device powered up, when will the RAM allocate exactly such a space to store global variables? I mean there should be such an instant.

    For example, if I upgrade the app project on the device and do not power down and power up the device, the .ebss space requirement information is stored on flash, but when does it take effect?

  • No, this is all decided at link time. The linker decides exactly where the .ebss will be located, and the executable file has the start address. At reset/power on time, the .ebss area is not created - it is just there. The only way you'd know it is .ebss is that the executable file says so. To the program, it's just another region of memory.