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.

AM2634: TMDSCNCD263

Part Number: AM2634

Hello,

How I can disable the auto initialization of the variables in the bss? This makes the output image large, I don't want to include the variables in the RAM in my binary.



I tried to use linker options --zero_init=off and --ram_model but also the variable are getting initialized.


Yours,
Abdelrhman Afifi

  • Hi Abdelrhman,

    You can try to use something like:

        .bss.log_shared_mem  (NOLOAD) : {} > LOG_SHM_MEM

    in linker.cmd file

  • Like this, I need to loop over all the variables in the bss?

    and in my example I need to try: .bss.buffer_memory (NOLOAD) : {} > BUFFER_MEMORY?

  • I tried it but still not working as expected.

  • Hi Abdelrhman,

    You will need to define the data section:  .bss.buffer_memory in your program and you will need to all your data buffers you do not want to initialize in there. The good example is the 

    put gAppImageBuf[] into .bss.filebuf in the sbl_uart_am243x-lp_r5fss0-0_nortos_ti-arm-clang.

    The .bss.filebuf will be put into the MSRAM_2 memory region (specified in the linker.cmd file) without loading at run time.

    The other way to avoid c_int00 to auto zero out the uninitialized data buffers is turn off the --zero_init:

    Best regards,

    Ming

  • Hello Ming,

    It is working inside the SDK but not with the MCAL.

    In the SDK the whole .bss section is uninitialized also the other sections, and the gAppImageBuf example is working as you mentioned.


    But in the MCAL not like this, the section is not mentioned as uninitialized.


    I think there is something to do with the flags, can you provide me with the flags used inside the SDK?, or if there are more differences between the MCAL and the SDK?

    I didn't use the SDK, so I am unaware of its details.

    Yours,

  • Hi Abdelrhman,

    In ANSI C, global and static variables that are not explicitly initialized must be set to 0 before program execution. The C/C++ compiler supports preinitialization of uninitialized variables by default. This can be turned off by specifying the linker option --zero_init=off.

    Make sure your MCAL makefile set option --zero_init=off.

    Also make sure your program do not explicitly set the buffer to 0 (like int buffer[100] = {0};)

    Best regards,

    Ming

  • Hi Ming,

    I am using setting this option already.

    I got your point but this initialization occurs in the startup, not inside the binary image itself.

    If you compared the two images you will find that the .bss is set to be (UNINITIALIZED)  inside the map file generated from the SDK.

    But in the map file generated from the MCAL, there is no (UNINITIALIZED) so like this, the whole .bss section is initialized by zero.

    Yours,

  • Hi Abdelrhman,

    I am not a MCAL expert, so I will forward your question to our MCAL expert for further help.

    Best regards,

    Ming

  • Hi

    Please comment this `_system_pre_init` call here in the below asm file 

    This function is basically initializing the BSS section with the below code, 

    Please follow the above steps and let me know if you're still seeing the issue.,

    Thanks,
    G Kowshik